On Dec 31 2007, 7:14=A0pm, David W. Cantrell <DWCantr...@[EMAIL PROTECTED]
>
wrote:
> bradeats...@[EMAIL PROTECTED]
wrote:
> > On Dec 30, 11:58=3DA0pm, David W. Cantrell <DWCantr...@[EMAIL PROTECTED]
>
wrot=
e:
> > > "Brian M. Scott" <b.sc...@[EMAIL PROTECTED]
> wrote:
>
> > > > On Sun, 30 Dec 2007 13:22:30 -0800 (PST),
> > > > <bradeats...@[EMAIL PROTECTED]
> wrote in
> > > >
<news:813841bf-5512-4c47-98f9-769d92bde6e0@[EMAIL PROTECTED]
> > > > om>=3D
>
> > > > in alt.algebra.help:
>
> > > > > I am a computer program
>
> > > > And a very good one, too! =3DA0<g>
>
> > > I wonder if it is good enough to pass the Turing Test.
>
> > > > > and not a mathematician. =3DA0I use the equations below to
> > > > > calculate Gallons when I have the Radius, Depth and
> > > > > Length of an oil tank. =3DA0However, sometimes I need to
> > > > > calculate Depth when I have the Radius, Length and
> > > > > Gallons. =3DA0Anyhelpin reworking these formulas would be
> > > > > greatly appreciated.
>
> > > > > If iDepth <=3D iRadius Then
>
> > > > > iGals =3D =A0((iRadius * iRadius * Acos((iRadius - iDepth) /
> > > > > iRadius)) - ((iRadius - iDepth) * Sqrt(2 * iRadius * iDepth -
> > > > > iDepth * iDepth))) * iLength / 231
>
> > > > > Else
> > > > > iGals =3D ((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 =3D =A0 ((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. =3DA0Its 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 aformulathat 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 =3D3D 231 * iGals / iLength; this is the area
> > > > in square inches of the submerged part of a vertical
> > > > cross-section through the tank. =3DA0Its maximum value is of
> > > > course the cross-sectional area of the tank,
> > > > PI * iRadius * iRadius. =3DA0Assume first that
> > > > iArea <=3D3D PI * iRadius * iRadius / 2, so that
> > > > iDepth <=3D3D iRadius.
>
> > > > Take iD to be an initial approximation to iDepth. =3DA0It
> > > > needn't be particularly good;
>
> > > > =3DA0 =3DA0iD =3D3D 2 * iArea / (PI * iRadius)
>
> > > > will do. =3DA0Let
>
> > > > =3DA0 =3DA0iX =3D3D iRadius - iD
>
> > > > and
>
> > > > =3DA0 =3DA0iY =3D3D Sqrt(iRadius * iRadius - iX * iX).
>
> > > > Recalculate iX according to theformula:
>
> > > > =3DA0 =3DA0iX =3D3D iX / 2 + (iRadius * iRadius * Acos(iX /
iRadius)=
-
> > > > iArea) / (2 * iY)
>
> > > > Update iD:
>
> > > > =3DA0 =3DA0iD =3D3D iRadius - iX
>
> > > > This will be a better approximation to iDepth. =3DA0Repeat until
> > > > you reach a satisfactory level of accuracy. =3DA0You can test
> > > > the accuracy in at least two ways. =3DA0First, you can use iD
> > > > for iDepth in yourformulato see whether it yields a value
> > > > for iGals sufficiently close to the known value. =3DA0Secondly,
> > > > you can keep track of the changes in iD and make sure that
> > > > they're small. =3DA0(You may want to use both.) =3DA0Convergence
was=
> > > > very rapid in all of the examples that I tested.
>
> > > > If iArea > PI * iRadius * iRadius / 2, you can proceed as
> > > > follows. =3DA0First let iArea =3D3D PI * iRadius * iRadius -
iArea;
> > > > this is the area of the part of the cross-section that
> > > > *isn't* submerged. =3DA0Next, carry out the procedure described
> > > > above. =3DA0When you've reached a satisfactory level of
> > > > accuracy, replace iD by 2 * iRadius - iD; this will be the
> > > > desired approximation to iDepth.
>
> > Brian and David,
> > Thanks for taking the time tohelpme with this problem.
>
> > David, I can't give you a very good reason as to why there are 2
> > cases. =A0The customer had an excel spreadsheet with those 2 cases and
I=
> > based my VB function on that spreadsheet. =A0Perhaps it's an example
of
> > garbage-in garbage-out. =A0I would be interested in a closed-form
> > approximation if one exists. Unlike Brian I'm not a great programmer
> > and anything that would make this process simpler would be greatly
> > appreciated.
>
> OK, I'll show you one way to approximate iDepth, given iRadius, iLength,
> and iGals. Just as Brian said, we first calculate iArea using
> iArea =3D 231 * iGals / iLength. But now departing from what Brian did,
> note that
>
> iArea =3D iRadius *iRadius * (t - sin(t)) / 2 =A0 =A0 =A0 =A0 =A0 =A0
=A0 =
=A0 =A0[1]
>
> where t is an angle in radians given by
>
> t =3D 2 * Acos(1 - iDepth/iRadius) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=A0=
=A0 =A0 =A0 =A0 [2].
>
> If we could solve equation [1] for t, we could then easily find iDepth
fro=
m
> [2]. But although we can rewrite [1] as
>
> t - sin(t) =3D 2 * iArea / (iRadius * iRadius) =A0 =A0 =A0 =A0 =A0 =A0
=A0=
=A0 [3]
>
> to solve [3] for t, we would need to be able to invert the function
> g(t) =3D t - sin(t); unfortunately, that cannot be done precisely in
close=
d
> form using familiar functions. But the inverse of g can be approximated
in=
> various ways. One way is to truncate an infinite series. Slightly
modifyin=
g
> my second response in "Can Anyone Solve This?", uk.education.maths, 2002
> Dec. 24 at
>
<http://groups.google.com/group/uk.education.maths/msg/a5dcab74c10f79df>:
>
> -------------------------------------------------
>
> t - sin(t) =3D M has solution
>
> t =3D f(cbrt(6*M)) where cbrt denotes the cube root and
>
> f(x) =3D x + x^3/60 + x^5/1400 + x^7/25200 + 43x^9/17248000 +
> =A0 1213x^11/7207200000 + 151439x^13/12713500800000 +
> =A0 33227x^15/38118080000000 + 16542537833x^17/252957982717440000000 +
> =A0 887278009x^19/177399104762880000000 + ...
>
> -------------------------------------------------
>
> For a closed-from approximation, let's just truncate the series for f,
> using only the ten terms given above.
>
> So now here's the whole basic process. Calculate the following, in
order:
>
> iArea =3D 231 * iGals / iLength
> M =3D 2 * iArea / (iRadius * iRadius)
> if M <=3D PI, t =3D f(cbrt(6*M)); else, t =3D 2*PI - f(cbrt(6*(2*PI -
M)))=
> iDepth =3D (1 - cos(t/2)) * iRadius
>
> BTW, the calculation for t was broken into cases because the
approximation=
> for f is not good for large arguments. To give you an idea of the
accuracy=
> of the approximation:
>
> Broken into cases as above, the approximation is worst when M =3D PI.
Then=
we
> should have precisely t =3D PI also, but our approximation yields
3.1408..=
..
> instead, and so the relative error in t is about -0.00024 .
>
> Happy New Year!
>
> David W. Cantrell- Hide quoted text -
>
> - Show quoted text -
Brian and David,
Thank you very much for your help and time. It's much appreciated.


|