Since ice is less dense than water, it floats on it, we all know this. Now suppose, if ice is floating in a glass cup, when the ice melts there should be some change at water level in the glass cup. But when I found this on the internet, it states that the water level will be same. Can someone justify/explain this?  In my way, water level will decrease because ice has greater volume than water, so when it floats, it will displace some water equal to its volume for floating. But when it melts, its volume decreases and hence water level will also decrease.  Is it right or wrong what I am thinking?
I have read the explanation for this in several textbooks, but I am struggling to understand it via Archimedes' principle. If someone can clarify with a diagram or something so I can understand or a clear equation explanation that would be great.
Seeing as C# can't switch on a Type (which I gather wasn't added as a special case because is relationships mean that more than one distinct case might apply), is there a better way to simulate switching on type other than this?  void Foo(object o) {     if (o is A)     {         ((A)o).Hop();     }     else if (o is B)     {         ((B)o).Skip();     }     else     {         throw new ArgumentException("Unexpected type: " + o.GetType());     } } Java: how to parse double from regex MySQL SELECT LAST_INSERT_ID() for compound key. Is it possible? Can I get the LAST INSERT ID() for a compound key in MySQL? Is being a right triangle both necessary and sufficient for the Pythagorean Theorem to hold? I recently encountered a Stack Overflow question (since closed) in which the OP was testing for whether a triangle was right by whether or not it "met" the criteria of the Pythagorean Theorem (i.e. whether or not the square of the hypotenuse is equal to the square of the two sides). The code was to this effect:  public void Test(int a, int b, int c) {    if ((c * c) == ((a * a) + (b * b)) {      System.out.println("This is a right triangle");    }    else {      System.out.println("This is not a right triangle");    } }   (There are obviously some other problems with this code, like the fact that it doesn't validate the input to make sure that the inputs are positive and the fact that it only accepts integers).  The question was asking about something completely different in the code and never directly addressed the test, but I got to thinking: is this a valid test for whether a triangle is a right triangle?  Obviously, the Pythagorean Theorem states that, for all right triangles, $a^2 + b^2 = c^2$ (where $a$ and $b$ are sides and $c$ is the hypotenuse). This will hold for all right triangles, so being a right triangle is a sufficient condition for the Pythagorean Theorem to hold.  Is it also a necessary condition? I.e. if $c^2 = a^2 + b^2$ for some arbitrary triangle, is the triangle necessarily a right triangle? Or are there counterexamples? Must I enter Europe with Schengen visa from the country where I applied? If I applied for a Schengen visa from "country A" and I got the visa but I had some commitments in "country B" and I have to finish it before going to Europe should I get back to "country A" to travel to Europe or can I use the visa from any where? Square roots -- positive and negative Backslash escaping in code regions in comments I've noticed that in comments, when you create `code region` with backticks, the backslash will still work as an escape character within that region (but it should not, IMHO).  To clarify:   In comments, `\\` will be rendered as \, but it should be rendered as \\ In the post body itself, `\\` will be rendered as \\ (i.e., correctly)   This is especially confusing when you enter regular expressions into a comment, since backslash-escaping is very common there, and confusion increases if you are dealing with a regex that is double-escaped for representation in a string.   At some point you lose track how many backslashes you must make so the comment renders correctly, or you don't notice fast enough (or at all) and the comment contains wrong code where the same markup in a question or answer would come out as perfectly correct.   It's just that comments can't be corrected anymore after the grace period, leaving you with the choice of either deleting the comment, thus crippling the conversation, or engaging in a trial-and-error game of writing another comment with even more backslashes to explain the issue.  My question is two-fold:   Will this error be corrected? If yes, existing comments should probably be searched and "fixed" by a routine that tries to do the right thing (this is probably somewhere between hard and impossible) Or, can I rest assured that never ever the behavior of the backslash in comments is going to be changed, so I can start working around this issue by hand, knowing that they won't start displaying incorrectly at some point in the future? Do companies have IT "spyware" on corporate iPhones? Simpler proof - Non atomic measures Suppose that $(X,\mathcal{E},\mu)$ is a non-atomic finite measure space (i.e. for every $E \in \mathcal{E}$ with $\mu(E)&gt;0$ there exists $F \subset E$ measurable such that $0&lt;\mu(F) &lt;\mu(E)$.)  a) Prove that for every $ \varepsilon &gt;0$ there is a finite partition of $X$ in measurable subsets $X_1,..,X_n$ such that $\mu(X_i)\leq \varepsilon$.  b) Prove that for every $\alpha \in [0,\mu(X)]$ there exists $E \in \mathcal{E}$ with $\mu(E)=\alpha$.    I guess that a) is given to prove b) more easily. I have the following idea of solution for a) (inspired from , which proves b)  )  Denote  $$ \Gamma = \{ (X_1,..,X_n) : n &gt;&gt; \mu(X)/\varepsilon, X_i \text{ are disjoint }, \mu(X_i)\leq \varepsilon \}$$ ordered by componentwise inclusion. Totally ordered parts $(Y_\alpha)$ of $\Gamma$ have an upper bound element $(\bigcup Y_\alpha^i)_{i=1}^n$ which is still in $\Gamma$.   By Zorn's lemma $\Gamma$ has maximal elements. If a maximal $(X_1..X_n)$ element is not a partition, then we can replace it with something better, of the form $(X_1,..,X_n\cup A)$ where $A \subset X \setminus (X_1 \cup..\cup X_n)$ and $\mu(A)&gt;0$.     My questions are:  1) Is my solution of a) correct? I feel that the part with the upper bound element may not work, since there might be noncountable unions.  2) What is a simpler solution of a)? Is a clean install better than upgrading? How to use different domains for multilingual sites and keep users logged in? Goal: I have a function $f(x,y)=z$ (two variables for illustration only) which I know almost nothing about--it has a compact domain which I can determine, it is non-negative, and bounded above.  My goal is to find the maximum value $f(x,y)$ takes on its domain.  I can query the function and I know the values at a few points: $f(x_1, y_1)=z_1, f(x_2, y_2)=z_2,..., f(x_n, y_n)=z_n$.  Optimization via Linear Regression:  I have used linear regression (and related methods like the lasso) to model functions like this in the past; this is the method that I am very comfortable with.  Typically, I might try to find a polynomial (of degree $k$) which relatively accurately models the data. The end result would be to say that:   $$f(x,y)\approx \beta_1 + \beta_2 x + \beta_3 y + \beta_4 x^2 + \beta_5 xy + \beta_6 y^2 + ... + \beta_{m}y^{k}.$$  Determining the coefficients is done by solving the .  The "best degree" for the polynomial might be determined using $k$-fold cross validation.  Once the "best" polynomial has been determined, one can choose any of a number of methods to optimize it (Newton's method, gradient descent, hill climbing, etc).  Then, if all goes well, the optimal value on the polynomial corresponds to an optimal value of $f(x,y)$.  Bayesian Optimization:  Recently, I was describing this technique (linear regression) to a colleague who asked: "What is the difference between that and Bayesian Optimization?"  I've been attempting to answer this question for the last couple days, and so far I don't have anything really conclusive.  After reading , trying to read  and getting stuck reading  I think I understand the following about BO:   Start with a prior (a guess as to what family of functions the black box belongs to... or at least some family of functions which you believe might be able to describe $f$ well).  It looks using a  as a prior is popular. Specify whatever is needed to build your prior (for GP this is a covariance function). As you go along, you maintain two evolving functions, a "mean" function $m(x,y)$ and a "confidence interval" function $c(x,y)$.  Basically, you can predict the value at any point by evaluating $m(x,y)$ and you are confident that $f(x,y)\in [m(x,y)-c(x,y), m(x,y)+c(x,y)]$. Bayesian optimization provides a systematic way of updating/exploiting the model by alternatively selecting points where the confidence interval is wide (you are very uncertain about the value) or at optimal points on the model $m(x,y)$.   My Question: Is it fair/correct to say that the major difference between Bayesian Optimization and simply optimizing the linear regression model is that Bayesian Optimization provides the systematic way of sampling with the goal of optimizing the model and reducing uncertainty whereas the linear regression model ignores the idea of uncertainty and doesn't explicitly provide a means of updating the model?  Said another way, is the linear regression model an example of what might be a "mean" function $m(x,y)$ in Bayesian Optimization?  If I stick with linear regression, specify how to compute the uncertainty, and provide a means of updating/improving the model (exploit/explore) am I just doing Bayesian Optimization (without calling it that)?  Background: My background is in pure mathematics (graph theory) but my new job has me working with a lot of data (so I'm self learning statistics).  With that in mind, my statistics vocabulary is somewhat limited (so I appreciate answers that either avoid technical terminology or briefly explain any technical terminology used)--for example, Monday was the first time I heard/read the word "prior" used in a stats sense and I'm still not 100% sure I understand that correctly. Anything I should keep in mind before I start mixing and matching between D&D 3.5e and Pathfinder? Anything I should keep in mind before I start mixing and matching between D&amp;D 3.5e and Pathfinder?  Off the top of my head, the biggest difference is feats every 2/3 levels. Would it affect balance if I picked every 3 levels instead of 2? I think PF options are still pretty solid regardless... Are these intended activities legal to do in the USA under the VWP? I'm a British citizen traveling to the USA next month with an ESTA to see my fiancee. I'm traveling there to plan our wedding, talk about a location to get married, and probably finalise a date and a booking with my fiancee (US citizen). This is the primary reason for my trip to the USA. Am I allowed to do this as a tourist? I would like to know for when the CBP officer asks me if this thing is allowed.  Am I allowed to enter the USA, on a separate trip (probably later this year), for the sole purpose of marrying my fiancee, provided I can persuade the CBP officer I intend to leave at the end of my trip? My fiancee and I are moving to the UK next year. Bypass GPG signature checks only for a single repository I'm giving training to a large group of people remotely and will be covering a number of application shortcut keys.  I've seen 's on-screen display of keystrokes; is there a similar product for Windows?    The other features of MousePose (fancy mouse pointers, etc.) aren't really useful to me, just the OSD of key presses. I am facing this issue on Ubuntu 12.04, which is for my Wimax modem with beceem chipset.    If I replug the device Ubuntu goes in hang state. Its happens very often. If I plug the USB and restart it works most of the time. But it is very annoying to restart every time it hangs. The modem works smoothly in Windows 7. And it used to work OK in  Ubuntu 11.10.   Jun 13 19:25:54 iftekhar-HP-520-Notebook-PC dbus[1102]: [system] Activating service name='org.freedesktop.UDisks' (using servicehelper) Jun 13 19:25:54 iftekhar-HP-520-Notebook-PC dbus[1102]: [system] Successfully activated service 'org.freedesktop.UDisks' Jun 13 19:26:00 iftekhar-HP-520-Notebook-PC goa[2168]: goa-daemon version 3.4.0 starting [main.c:112, main()] Jun 13 19:26:47 iftekhar-HP-520-Notebook-PC udevd[432]: timeout 'cdrom_id --lock-media /dev/sr1' Jun 13 19:26:48 iftekhar-HP-520-Notebook-PC udevd[432]: timeout: killing 'cdrom_id --lock-media /dev/sr1' [1072] Jun 13 19:26:49 iftekhar-HP-520-Notebook-PC kernel: [   85.820162] sr 2:0:0:0: Device offlined - not ready after error recovery Jun 13 19:26:49 iftekhar-HP-520-Notebook-PC udevd[432]: timeout: killing 'cdrom_id --lock-media /dev/sr1' [1072] Jun 13 19:27:20  udevd[432]: last message repeated 31 times Jun 13 19:27:25  udevd[432]: last message repeated 4 times    What can I do to avoid this hangs and restarts? Postgres JDBC connection in Eclipse Help I'm trying to get a postgres jdbc connection working in eclipse. It would be nice to use the Data Source Explorer, but for now I'm just trying to get a basic connection. What I have done so far is download the postgres JDBC connector. I then tried two different things. First, Preferences-> Data Management, I tried to add the postgres connector. Second, I added the jar to my project and tried to load the driver using Class.forName("org.postgresql.Driver"); but neither worked. Does anyone have any ideas?  Thanks,    Charlie When should I use a struct rather than a class in C#? Review of a proof for De Moivre's theorem using mathematical induction The following is a rigorous proof of De Moivre's theorem by means of mathematical induction. The theorem put simply is that:  Any complex number, $z = a+bi$, on a cartesian plane can be expressed in polar form, where $a=r\cos\theta$ and $b=r\sin\theta$ and $r$ is the absolute distance from the origin to the point $z$. In light of this, the expression for the complex number $z$ in polar form is $z=r(\cos\theta+i\sin\theta)$ In order to find the $n^{th}$ power of $z$, the following rule applies: $$\displaystyle z^n=(r(\cos\theta+i\sin\theta))^n=r^n(\cos n\theta+i\sin n\theta)$$ where $n\in\mathbb N$ (I have confined $n$ to the natural numbers given that I intend on using mathematical induction to prove the theorem.  Base step: We must prove that what is stated is true for $n=1$, hence $$z^1=r^1(\cos 1\cdot\theta+i\sin1\cdot \theta)$$ $$=r(\cos\theta+i\sin\theta)$$ which is true. Next we assume it is true for $n=k$, and therefore proceed to the inductive step. Inductive step: When calculating $z^{n+1}$, it's the same as calculating $z^nz$, hence $$z^{n+1}=(r^n(\cos n\theta + i\sin n\theta))(r(\cos \theta+i\sin \theta))$$ $$=r^nr(\cos n\theta+i\sin n\theta)(\cos\theta +i\sin \theta)$$ $$=r^{n+1}(\cos n\theta\cdot\cos\theta+\cos n\theta \cdot i\sin\theta+i\sin n\theta\cdot\cos\theta+i^2\sin n\theta\cdot\sin\theta)$$ from here, $i^2=-1$, and therefore $+i^2\sin n\theta\cdot\sin\theta$ becomes $-\sin n\theta\cdot\sin\theta$. In addition to this, the following trigonometric identities will be used: $$\sin(n\theta + \theta) = \sin n\theta\cdot\cos\theta+\cos n\theta\cdot\sin\theta$$ $$or$$ $$k\sin(n \theta+\theta)=k\sin n \theta\cdot\cos \theta + \cos n\theta\cdot k\sin\theta$$ $$and$$ $$\cos(n \theta + \theta)=\cos n\theta\cdot\cos\theta-\sin n\theta\cdot\sin\theta$$ by using these, the original equation has now become $$=r^{n+1}(\cos(n \theta + \theta) + i\sin(n \theta + \theta))$$ then, after factoring out $\theta$, the theorem becomes $$=r^{n+1}(\cos((n+1)\theta)+i\sin((n+1)\theta))$$ which completes the proof. Question: is this proof correct all the way through? Or have I missed any conditions? If all is well in the case of this proof, could somebody aid me in proving it for $\{n|n\in\mathbb R,n\geq1\}$