"Brian M. Scott" <b.scott@[EMAIL PROTECTED]
> wrote:
> On Sun, 30 Dec 2007 13:22:30 -0800 (PST),
> <bradeatspoo@[EMAIL PROTECTED]
> wrote in
> <news:813841bf-5512-4c47-98f9-769d92bde6e0@[EMAIL PROTECTED]
>
> in alt.algebra.help:
>
> > I am a computer program
>
> And a very good one, too! <g>
I wonder if it is good enough to pass the Turing Test.
> > and not a mathematician. I use the equations below to
> > calculate Gallons when I have the Radius, Depth and
> > Length of an oil tank. However, sometimes I need to
> > calculate Depth when I have the Radius, Length and
> > Gallons. Any help in reworking these formulas would be
> > greatly appreciated.
>
> > If iDepth <= iRadius Then
>
> > iGals = ((iRadius * iRadius * Acos((iRadius - iDepth) /
> > iRadius)) - ((iRadius - iDepth) * Sqrt(2 * iRadius * iDepth - iDepth *
> > iDepth))) * iLength / 231
>
> > Else
> > iGals = ((PI * iRadius * iRadius) - ((iRadius * iRadius *
> > Acos((iRadius - (2 * iRadius - iDepth)) / iRadius)) - ((iRadius - (2 *
> > iRadius - iDepth)) * Sqrt(2 * iRadius * (2 * iRadius - iDepth) - ((2 *
> > iRadius - iDepth) * (2 * iRadius - iDepth)))))) * iLength / 231
>
> > End If
I'm curious to know why you chose to break up the calculation of iGals
into
two cases. After all, for any iDepth from 0 through 2*iRadius, we can use
just
iGals = ((iRadius * iRadius * Acos((iRadius - iDepth) /
iRadius)) - ((iRadius - iDepth) * Sqrt(2 * iRadius * iDepth - iDepth *
iDepth))) * iLength / 231
> Judging from these formulae, it's a cylindrical tank lying
> on its side. Its length in inches is iLength, its radius in
> inches is iRadius, and iDepth is the depth of the fluid in
> inches, measured at the centre of the tank.
>
> The problem isn't amenable to solution in closed form:
> you're not going to get a formula that gives you iDepth in
> terms of iGals, iRadius, and iDepth.
Right. There is no precise solution in closed form. But an approximate
solution in closed form could be given, for example. [The problem is
equivalent to solving a special case of Kepler's equation.]
To the computer program:
I suppose that the iterative method Brian gave below will work well. But
if
you would prefer a closed-form approximation instead, let me know.
David
> The easiest practical
> solution is probably to write a routine that gets a
> sufficiently accurate value by successive approximation,
> using the formulae that you already have.
>
> For convenience I'll introduce some additional variables.
> First, set iArea = 231 * iGals / iLength; this is the area
> in square inches of the submerged part of a vertical
> cross-section through the tank. Its maximum value is of
> course the cross-sectional area of the tank,
> PI * iRadius * iRadius. Assume first that
> iArea <= PI * iRadius * iRadius / 2, so that
> iDepth <= iRadius.
>
> Take iD to be an initial approximation to iDepth. It
> needn't be particularly good;
>
> iD = 2 * iArea / (PI * iRadius)
>
> will do. Let
>
> iX = iRadius - iD
>
> and
>
> iY = Sqrt(iRadius * iRadius - iX * iX).
>
> Recalculate iX according to the formula:
>
> iX = iX / 2 + (iRadius * iRadius * Acos(iX / iRadius) -
> iArea) / (2 * iY)
>
> Update iD:
>
> iD = iRadius - iX
>
> This will be a better approximation to iDepth. Repeat until
> you reach a satisfactory level of accuracy. You can test
> the accuracy in at least two ways. First, you can use iD
> for iDepth in your formula to see whether it yields a value
> for iGals sufficiently close to the known value. Secondly,
> you can keep track of the changes in iD and make sure that
> they're small. (You may want to use both.) Convergence was
> very rapid in all of the examples that I tested.
>
> If iArea > PI * iRadius * iRadius / 2, you can proceed as
> follows. First let iArea = PI * iRadius * iRadius - iArea;
> this is the area of the part of the cross-section that
> *isn't* submerged. Next, carry out the procedure described
> above. When you've reached a satisfactory level of
> accuracy, replace iD by 2 * iRadius - iD; this will be the
> desired approximation to iDepth.
>
> Brian


|