Talk About Network

Google




Education > Algebra help > Re: Formula Hel...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 1944 of 2170
Post > Topic >>

Re: Formula Help

by David W. Cantrell <DWCantrell@[EMAIL PROTECTED] > Jan 1, 2008 at 12:14 AM

bradeatspoo@[EMAIL PROTECTED]
 wrote:
> On Dec 30, 11:58=A0pm, David W. Cantrell <DWCantr...@[EMAIL PROTECTED]
> wrote:
> > "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>=
>
> > > in alt.algebra.help:
> >
> > > > I am a computer program
> >
> > > And a very good one, too! =A0<g>
> >
> > I wonder if it is good enough to pass the Turing Test.
> >
> > > > and not a mathematician. =A0I use the equations below to
> > > > calculate Gallons when I have the Radius, Depth and
> > > > Length of an oil tank. =A0However, sometimes I need to
> > > > calculate Depth when I have the Radius, Length and
> > > > Gallons. =A0Any 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. =A0Its 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 =3D 231 * iGals / iLength; this is the area
> > > in square inches of the submerged part of a vertical
> > > cross-section through the tank. =A0Its maximum value is of
> > > course the cross-sectional area of the tank,
> > > PI * iRadius * iRadius. =A0Assume first that
> > > iArea <=3D PI * iRadius * iRadius / 2, so that
> > > iDepth <=3D iRadius.
> >
> > > Take iD to be an initial approximation to iDepth. =A0It
> > > needn't be particularly good;
> >
> > > =A0 =A0iD =3D 2 * iArea / (PI * iRadius)
> >
> > > will do. =A0Let
> >
> > > =A0 =A0iX =3D iRadius - iD
> >
> > > and
> >
> > > =A0 =A0iY =3D Sqrt(iRadius * iRadius - iX * iX).
> >
> > > Recalculate iX according to the formula:
> >
> > > =A0 =A0iX =3D iX / 2 + (iRadius * iRadius * Acos(iX / iRadius) -
> > > iArea) / (2 * iY)
> >
> > > Update iD:
> >
> > > =A0 =A0iD =3D iRadius - iX
> >
> > > This will be a better approximation to iDepth. =A0Repeat until
> > > you reach a satisfactory level of accuracy. =A0You can test
> > > the accuracy in at least two ways. =A0First, you can use iD
> > > for iDepth in your formula to see whether it yields a value
> > > for iGals sufficiently close to the known value. =A0Secondly,
> > > you can keep track of the changes in iD and make sure that
> > > they're small. =A0(You may want to use both.) =A0Convergence was
> > > very rapid in all of the examples that I tested.
> >
> > > If iArea > PI * iRadius * iRadius / 2, you can proceed as
> > > follows. =A0First let iArea =3D PI * iRadius * iRadius - iArea;
> > > this is the area of the part of the cross-section that
> > > *isn't* submerged. =A0Next, carry out the procedure described
> > > above. =A0When 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 to help me with this problem.
>
> David, I can't give you a very good reason as to why there are 2
> cases.  The customer had an excel spreadsheet with those 2 cases and I
> based my VB function on that spreadsheet.  Perhaps it's an example of
> garbage-in garbage-out.  I 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 = 231 * iGals / iLength. But now departing from what Brian did,
note that

iArea = iRadius *iRadius * (t - sin(t)) / 2                  [1]

where t is an angle in radians given by

t = 2 * Acos(1 - iDepth/iRadius)                             [2].

If we could solve equation [1] for t, we could then easily find iDepth
from
[2]. But although we can rewrite [1] as

t - sin(t) = 2 * iArea / (iRadius * iRadius)                 [3]

to solve [3] for t, we would need to be able to invert the function
g(t) = t - sin(t); unfortunately, that cannot be done precisely in closed
form using familiar functions. But the inverse of g can be approximated in
various ways. One way is to truncate an infinite series. Slightly
modifying
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) = M has solution

t = f(cbrt(6*M)) where cbrt denotes the cube root and

f(x) = x + x^3/60 + x^5/1400 + x^7/25200 + 43x^9/17248000 +
  1213x^11/7207200000 + 151439x^13/12713500800000 +
  33227x^15/38118080000000 + 16542537833x^17/252957982717440000000 +
  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 = 231 * iGals / iLength
M = 2 * iArea / (iRadius * iRadius)
if M <= PI, t = f(cbrt(6*M)); else, t = 2*PI - f(cbrt(6*(2*PI - M)))
iDepth = (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 = PI. Then
we
should have precisely t = 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
 




 6 Posts in Topic:
Formula Help
bradeatspoo@[EMAIL PROTEC  2007-12-30 13:22:30 
Re: Formula Help
"Brian M. Scott"  2007-12-30 22:16:11 
Re: Formula Help
David W. Cantrell <DWC  2007-12-31 04:58:05 
Re: Formula Help
bradeatspoo@[EMAIL PROTEC  2007-12-30 21:22:33 
Re: Formula Help
David W. Cantrell <DWC  2008-01-01 00:14:29 
Re: Formula Help
bradeatspoo@[EMAIL PROTEC  2008-01-03 15:00:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Tue Jan 6 11:19:11 PST 2009.