Wikipedia:Reference desk/Archives/Mathematics/2017 April 29

= April 29 =

Trouble with Wolfram Alpha, calculating height of spherical cap
The volume of a spherical cap of height $$h$$ and sphere radius $$r$$ is
 * $$v = {\pi \over 3} h^2 \left ( 3r-h \right )$$

I want to solve for $$h$$. So I plug it into Wolfram Alpha here: https://www.wolframalpha.com/input/?i=v+%3D+pi%2F3+*+h%5E2+*+(3*r-h),+solve+h

The solution is kind of ugly but can be simplified parametrically as
 * $$h= {a \over b} + {b r^2 \over a} + r$$

where
 * $$a = \sqrt[3]{ \sqrt{3} \sqrt{3 v^2 - 4 \pi r^3 v} + 2 \pi r^3 - 3 v}$$
 * $$b = \sqrt[3]{2 \pi}$$

The problem is that part under radical $$3 v^2 - 4 \pi r^3 v$$. It's always a negative number no matter what I plug in.

For example, if $$r=1$$ then $$v = 2 \pi / 3$$. But plugging those values in results in a negative square root argument, $$-4 \pi^2 / 3$$.

The weird thing is, I've used this before, and it worked. I'm wondering if I made a typo that I'm just not seeing. ~Anachronist (talk) 00:24, 29 April 2017 (UTC)


 * You apparently have an example of casus irreducibilis, in which a cubic equation with three real roots can only be solved algebraically by invoking imaginary numbers. Notice that your non-real expression a appears twice in the solution for h; while it is not obvious, the imaginary parts cancel out, and the expression for h is real. To avoid imaginary numbers, you can use the trigonometric solution in Casus irreducibilis. Loraof (talk) 01:14, 29 April 2017 (UTC)


 * The article you linked gives the area formula as


 * $$V = \frac{\pi h}{6} (3r^2 + h^2)$$


 * This doesn't seem to agree with the area formula you gave. Loraof (talk) 01:37, 29 April 2017 (UTC)
 * look further down... the formula you quoted uses r as the base radius of the cap. Further down there's a formula using the radius of the sphere, which is what I started with above. I'm trying to get the height of the cap, knowing only the volume and the sphere radius.
 * Thanks for the suggestion to try Casus irreducibilis. Unfortunately, that seems to work for problems that can be expressed as $$t^3+pt+q=0 $$ whereas the formula here has $$t$$ in the middle term squared. ~Anachronist (talk) 01:52, 29 April 2017 (UTC)
 * You just need to perform a substitution to depress the cubic, as stated in the very same article. Double sharp (talk) 05:15, 29 April 2017 (UTC)


 * Actually if you know the sphere's radius r, the sphere is fixed; then if you know the volume of the cap, you know the height, so there is only one real solution. The presence of only one real solution is confirmed by the discriminant formula in the casus irreducibilis article, meaning that you don't have casus irreducibilis. So Wolfram's formula must be a non-conventional way of writing the solution, which normally should not involve complex numbers. I'll try to work out the conventional formula. Loraof (talk) 17:18, 29 April 2017 (UTC)


 * So sorry, for at least some cases there really are three real solutions, though two or them are outside the geometrically meaningful range. Loraof (talk) 01:29, 30 April 2017 (UTC)


 * Thanks. After messing with this some more, I gave up in frustration and discarded my model of partially-filled vessel as a spherical cap (or bowl, actually), and instead approximated the shape with a few stacked truncated cones. A truncated cone has a simple clean solution for height as a function of volume. That approximation will serve my purposes. ~Anachronist (talk) 09:04, 30 April 2017 (UTC)


 * As I mentioned earlier, with three real roots, the case you have, you can get a calculator-friendly formula for h using the trig formula given in the casus irreducibilis article. Your equation is


 * $$h^3-3rh^2+3v/\pi=0.$$


 * Using h = x + r gives


 * $$x^3-3r^2x+(3v/\pi-2r^3)=0.$$


 * Letting $$p=-3r^2, \, \, q=3v/\pi-2r^3$$ and using the trig formula gives


 * $$h=x+r=2\sqrt{-p/3}\times \cos \left((1/3)\arccos ((3q/2p)\sqrt{-3/p})-2\pi k/3\right)+r$$


 * for each of k = 1, 2, 3. One of those k values will give you an answer with 0 < h < 2r, and that is the answer you are looking for. Loraof (talk) 21:03, 30 April 2017 (UTC)


 * That's amazing, thanks. When I looked at the casus irreducibilis formula, I wasn't sure if it was valid to create new parameters as different (and interrelated) functions of r. I appreciate the advice.
 * It's also amazing to me that such a simple geometry requires such a messy-looking solution. At first glance, the problem "derive a formula for the height of a spherical cap, given its volume and radius" sounds like a high school math problem, but it turns out to be quite a bit more advanced than high school math (at least, when I went to high school decades ago). ~Anachronist (talk) 00:22, 1 May 2017 (UTC)

Chain Rule for Canonical Form
I am a bit confused about the principal part of the PDE, and what its roots mean for the  dy/dx = λ , and and how that came about. I understand that the sign of the discriminant b squared minus 4ac determines whether the PDE is Hyperbolic, Parabolic, or Elliptic, but as to the roots of from the related quadratic equation, I am a bit mystified. I understand that the roots are used to determine the coefficients of x in PDE's that might have general solutions such as f( m1x + y) + g(m2x + y ), where m1 and m2 are the roots, and therefore the coefficients of x in this form of solution, but as to stuff about the canonical form, I am confused. I see that for this, where we have the principal part of the PDE of second order being Auxx + Buxy + Cuyy, where for example, uxx is just the second partial derivative of u with respect to x, and so on, then we have a change of coordinates, letting xi = xi(x,t), and tau = tau(x,t), so that in terms of these new coordinates, by the Chain Rule, we have :   ux = xix*Uxi + taux*Utau, and ut = xit*Uxi + taut*Utau, and that makes sense, but then I do not get why the second derivative of u with respect to x is what it is. I thought it would simply be partial d/dx of this ux expression, but done by the power rule, so that d/dt[xix*Uxi], would be in the form of f'g +g'f, with f = xix, and f' = xixx, being the its derivative with respect to x, and therefore that  g = Uxi, and g' = Uxi,x, being the its derivative with respect to x, that is, partial d squared U over partial xi partial x. I hope this is clear, and I am sorry I have not been able as yet to master Latex, so I can only portray the derivatives in another way I hope can be understood. So what I do not understand is why the uxx has squared terms, and other things, and where it has come from. From this, also, what the Canonical Form means, and what it is meant to look like. Thank You. Chris the Russian Christopher Lilly  06:07, 29 April 2017 (UTC)
 * If you are not comfortable using LaTeX, then I suggest using subscript notation. Subscripts can be inserted using the tag. For example, the second partial derivative of u with respect to x is denoted as u xx. It's very hard to follow what you're saying, especially with the additional subscript i.--Jasper Deng (talk) 09:46, 29 April 2017 (UTC)

Is the following Subset Sum Problem variant NP-hard?
Is the following problem NP-hard:

Input: $$A\subset\Z,k\in\N$$

Question: is there a multiset of indices $$I$$, such that $$|I|=k$$ and $$\sum_{i\in I} a_i = 0$$?

For example, on the input $$A=\{-1,2\},k=3$$, we can take $$I=\{1,2,2\}$$ and thus we get $$|I|=3$$ and $$a_1+a_1+a_2=(-1)+(-1)+2=0$$, as desired. 213.8.204.26 (talk) 07:28, 29 April 2017 (UTC)
 * Since you are asking for a multiset, I am assuming we can only have linear combinations of members of A with nonnegative coefficients. Then this problem is known as the unbounded subset sum problem and is NP-complete. I am not sure exactly why; Knapsack Problems gives a proof of this, and that text is very reputable, but that particular proof seems to be flawed (or I am misunderstanding it). A few months ago, I asked your question to Christos Papadimitriou and he told me it's NP-complete, and that it can be founded in Computers and Intractability (although a perusal of that book by me failed to turn it up; I might have looked at the wrong edition or something). See also the coin problem, which is NP-hard and is very related to this problem.--Jasper Deng (talk) 08:44, 29 April 2017 (UTC)
 * Actually I misread your original question: you are requiring that the multiset have a specific size. However, that remains NP-hard, because this is basically a decision version of the change-making problem, which is an NP-hard optimization problem.--Jasper Deng (talk) 19:24, 29 April 2017 (UTC)

Remove peaks from data/rank articles by pageviews
Let's say I want to rank Wikipedia articles by their mean pageviews (from most popular to least popular). But there are such articles as Dr. Seuss, that makes this list not so reliable (if using standart mean formula). What could you suggest to have those peaks "removed"? -- Edgars2007  (talk/contribs) 21:08, 29 April 2017 (UTC)


 * I'm guessing the days with peaks ten times higher than the typical pageview counts were days when Dr. Suess was in the news. I would argue that that's part of the article's popularity, and that you should not remove the peaks. But if you don't like the peaks, you could compute the median number of pageviews for each article, and compare them. Loraof (talk) 22:25, 29 April 2017 (UTC)


 * The median, or any other robust statistics. — Preceding unsigned comment added by 2601:184:4980:7220:8985:A0E6:B3F7:E214 (talk) 00:20, 30 April 2017 (UTC)


 * Yes, I don't have anything much in my statistics background, so I may say something silly, but. Median doesn't sound like a good option. I was thinking about something like this: if I see some peak, that is X times higher than typical (average?) number of pageviews, remove it and recalculate average value again. Maybe somebody could translate it to mathematical expressions? I won't do it by hands/in Excel, that will done in Python programm, so it doesn't have to be something very very simple. And wouldn't standard deviation help in some way? -- Edgars2007  (talk/contribs) 09:43, 30 April 2017 (UTC)


 * That is the sort of thing that led to scientists not noticing the Antarctic ozone hole for nearly a decade. Why do you want to completely ignore 'outliers' when calculating popularity - what exactly does it mean to you? Anyway how about doing a Moving average if you want to consider longer time periods or see Exponential smoothing. Dmcq (talk) 11:58, 30 April 2017 (UTC)


 * I want to remove them, because in my case I treat popularity as "notability" of subject (let's not discuss how good or bad observation is that). If article A is viewed 1,000,000 times in a year and views doesn't have any big peaks, it's more popular/notable than article B, that is viewed 1,100,000 times in a year, but with peaks for ten days, each of them is let's say 100,000. So in my list I would like to rank article A higher than article B. -- Edgars2007  (talk/contribs) 15:24, 30 April 2017 (UTC)
 * Perhaps this is going off-topic, but Wikipedia already has well establish criteria for what should be an article and number of hits is not one of them. This isn't TigerBeat.com and we don't have an article on Rydell Lynch's night routine, though if we did it would probably get more page views than Spectral theory of ordinary differential equations. That's not to say that there's no correlation at all and a page which gets less than 100 views in a year shouldn't have its notability checked, but page views isn't, and shouldn't be imo, a criterion for inclusion. --RDBury (talk) 18:02, 30 April 2017 (UTC)


 * Don't get me wrong, this data/rank is only for my use, it won't get used to propose something to AfD or put some maintaince tags. If somebody else uses this data to do that, that's his problem :) -- Edgars2007  (talk/contribs) 19:43, 30 April 2017 (UTC)


 * Smoothing should give you plenty of ideas. Or you could calculate the average and standard deviation using the full data set, then remove all points outside x number of standard deviations from the average, and then repeat until the data set and average stabilize.--Wikimedes (talk) 20:28, 30 April 2017 (UTC)
 * For really large spikes, median would probably be a better starting point than average; using the average might lead to throwing out the entire data set on the first iteration.--Wikimedes (talk) 21:14, 30 April 2017 (UTC)