# Find the value of $h$ from a Kepler-type equation

$$V = \frac{0.5r^{2}\cdot \cos^{-1}(\frac{r-h}{r})\cdot 2-\sin\big(\cos^{-1}(\frac{r-h}{r})\cdot 2\big)}{10^{6}}\tag1$$

This is the equation to find the volume of liquid in a tank in the shape of a capsule. Where $h$ is depth of the liquid, $r$ is radius of the cylinder, and $V$ is volume of liquid.

I need to find the depth of liquid, that is $h$ if the volume $V$ is given.

$\color{blue}{Edit:}$

The volume formula for a capsule (a cylinder with a hemisphere at both ends) is,

$$V_c = \pi r^2 H + \frac{4}{3}\pi r^3$$

while that of a tank (a cylinder with a hemi-oblate spheroid at both ends) is,

$$V_t = \pi r^2 H + \frac{4}{3}\pi c r^2$$

with the capsule being the special case $c = r$. For example, the total fill volume with $H = 192$, $c = 18$, $r=36$ is,

$$V_t = 879444.88\;\text{in}^3 = 3807.12\; \text{US gallons}\tag2$$

while the volume of water in a partially filled tank with water depth $h=48\;\text{in}$ is,

$$V_p = 2710\; \text{US gallons}\tag3$$

both values given in the link below.

Tank volume calculator

• What have you tried so far?please add your efforts in your question or as a comment – Snehil Sinha Jul 28 '15 at 9:16
• @SNEHIL I'm not very good at maths. I'm developing an java application for a petrol pump and I'm stuck here – Bobby Fernandez Jul 28 '15 at 9:24
• I don't think V is analytic meaning you'll have to use convergence if there is closed form solution. It's nearly of the form $x-sin(x)$ – marshal craft Jul 28 '15 at 9:25
• Only numerical methods will do the job. Are you sure about the formula ? – Claude Leibovici Jul 28 '15 at 9:39
• Hint: Using $y=\cos^{-1}(\frac{r-h}{r})$ you will get Kepler's equation $M = y - e \sin y$. With the solution $y$ compute $h = r(1-\cos y)$. – gammatester Jul 28 '15 at 9:55

$V=10^6(\frac{r^2}{2}2\cos^{-1}(\frac{r-h}{r})-\sin(2\cos^{-1}(\frac{r-h}{r}))$ and $V=2710$, $r=36$ find a function of $h(V)$?

There is no way to obtain the asked volume from the expression $10^6(\frac{r^2}{2}2\cos^{-1}(\frac{r-h}{r})-\sin(2\cos^{-1}(\frac{r-h}{r}))$.

I don't think it requires numerical methods to show this but being as it would have required them to have some way of calculating values of $h$ given a specific volume; I proceed with numerical methods.

Notice $V$ is nearly of the form $x-\sin(x)$ and is of a general Keplarian$^{1}$ form where the eccentric anomoly is commonly sought from the mean anomoly in the gravitation two body problem. This problem of solving $y=x-\sin(x)$ for $x$ is not algebraic. There is no closed or finite algebraic series representing $x=f(y)$. Newton's method which relies on the derivative, can be used to approximate $x=f(y)$ to arbitrary accuracy.

Newton's Method

$x_n=x_{n-1}-\frac{f(x_{n-1})}{f'(x_{n-1})}$

$V=g(x)$ where $g(x)$ is as above, then we can define $f(x)=g(x)-V$ and use Newton's method to find a zero of $f(x)$ because Newton's method finds zeros. $x :f(x)=0$ implies $V=g(x)$ and so if you give me a $V$ I can find the corresponding $x$ value and this is how we can express $g^{-1}(V)=x$. There is no other way in the sense that any other way will be an infinite sequence or recursive sequence.

Note

Label $2\cos^{-1}(\frac{r-h}{r})$ as $x$, then we get a new expression for $V$.

$V=10^6(\frac{r^2}{2}x-\sin(x))$ and $f(x)=10^6(\frac{r^2}{2}x-\sin(x))-V$

$\frac{d}{dx}f(x)=10^6(\frac{r^2}{2}\frac{d}{dx}x-\frac{d}{dx}\sin(x))=10^6(\frac{r^2}{2}-\cos(x))$

$x_n=x_{n-1}-\frac{10^6(\frac{r^2}{2}x_{n-1}-\sin(x_{n-1}))-V}{10^6(\frac{r^2}{2}-\cos(x_{n-1}))}$ (don't you dare cancel those $10^6$ haha)

Java

In java I found it was best to use a for loop, I tried recursive method for elegance but started getting stack overflows at over 1000 iterations.

public static double CalculateX(double Volume, double Radius, double  n, double x)
{
for(int i = 0; i < n; i++)
{
}
return x;
}


Running this method I found a zero at $x=4182098.763994463$. This is the value $x$ must take on in order for your expression for $V$ to be valid. The problem is that earlier we knew $x=2\cos^{-1}(\frac{r-h}{r})$ and

$2091049.3819972315=\cos^{-1}(a)$ is not possible for any $a \in \Bbb R$. Arc cosine has a range of at most $\pi$. And so we know now for any $h$ this expression can never equal the Volume asked for.

• No idea if there is such a thing as "Keplarian" form? – marshal craft Aug 1 '15 at 3:05
• Note there may be one loop whole that java does trig in radians and if the asker's formula is in degrees. I don't think this is a loop whole but I have not covered it because my program computes an x value that is in radians. Interested to see if it was transcribed incorrectly? Where does this formula come from? – marshal craft Aug 1 '15 at 3:21
• I've edited the OP's post to give more details. While it is easy to find total volume $(2)$, it is hard to arrive at the value $(3)$ using formula $(1)$. I think there is an error in his formula. – Tito Piezas III Aug 1 '15 at 7:04
• @Tito Piezas III will run the program for that value and see new x . – marshal craft Aug 1 '15 at 7:07
• I think $1$ is still wrong. It is not algebraic in that there is not closed form inverse of it for $h$. Basically we have done substitution of similar arc cos term for x. then it is of form x-sinx. I used newton method to solve for x given the volume and it converges so I KNOW his equation can not obtain the necessary volume. for volume in cubic inches x converges to 1.357168024689821E9. So $2cos^{-1}(\frac{r-h}{r})$ needs to equal that large number which is impossible unless there is some kind of arccos that extends it's range that I am not familar with? That or I miss something? – marshal craft Aug 1 '15 at 7:17

Ok there is another question that ask's for the formula for volume itself. I won't derive the formula but as the other answer suggests, is the formula for the spatial volume of a tank given those dimensions; is not equation $1$. Instead it is this.

$V=H\left( R^2 cos^{-1}(\frac{R-h}{R})+(h-R)\sqrt{h(2R-h)}\right) + \frac{\pi C h^2}{3R}(3R-h)$

Rather than discussing the possibility of finding a form for $h$ given $V$ that is $h(V)$, I premptively turn to Newton's method. Here it is in java.

   public static double CalculateHeightFromVolume(double H, double R, double C, double Volume, double guess, double n)
{
for(int i = 0; i < n; i++)
{
guess = guess - (H*(Math.pow(R, 2.0)*Math.acos((R-guess)/R)+(guess-R)*Math.pow((guess*(2*R-guess)), 0.5))+Math.PI*C*Math.pow(guess, 2.0)/(3.0*R)* (3.0*R-guess)- Volume)
/
(H*(R/(Math.pow(1-Math.pow((R-guess)/R, 2.0), 0.5))+Math.pow((2.0*R*guess-Math.pow(guess, 2.0)), 0.5)-Math.pow((guess-R), 2.0)/Math.pow((2.0*R*guess-Math.pow(guess, 2.0)), 0.5)+(Math.PI*C/R)*(2.0*R*guess-Math.pow(guess, 2.0))));
}
return guess;
}


I did not rule out the possibility of an explicit representation of $h(V)$ though and it may perhaps exist.

For example: $V=500000 in^3$ then $h=39.8086897150784$ or 2164.5 gallons we would see a height(depth) of roughly 40 inches.

• interesting just a fraction of an inch is many gallons ! – marshal craft Aug 1 '15 at 23:02