help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: area and volume calculation


From: Ted Harding
Subject: RE: area and volume calculation
Date: Tue, 09 Nov 2004 20:41:50 -0000 (GMT)

On 09-Nov-04 Fred J. wrote:
> is octave able to determine the area between two
> functions, say 
> y = 2x^2 + 10
> y = 4x +  16
> with out me doing pin/paper work first. basically take
> in the functions and get out the area between them.

So long as one function is greater than the other over the
range you are considering, as for instance

  f1(x) = 2*x^2 + 10  <  f2(x) = 4*x + 16

provided -1 < x < 3, then you can integrate f2 numerically
and f1 numerically, then subtract the integral for f1 from
the integral for f2 (or simply integrate f2 - f1).

However, if you are integrating over a range where the two
functions cross, so that f1 < f2 in some parts and f1 > f2
in others, then you would have to decide what you mean by
"the area between them". If your meaning is that the area
is positive if f2 > f1 but negative if f1 < f2, then it
is the same solution as above: integrate (f2(x) - f1(x)).

However, if you mean that the area is positive whichever
way round the fuctions are, i.e. it is the integral of
the positive vertical distance between them, then you
should integrate (f2(x) - f1(x))*sign(f2(x) - f1(x))
where sign(x) is the function (which is in octave) whose
value is +1 if x > 0 and -1 if x < 0.

> what about the volume when the graph is turned about
> the x axis.

Here you might use the theorem of an Ancient Greek (was
it Pappus? -- it was a long time ago that I learned this!)
to the effect that the volume swept out when an area
(which does not intersect the axis) is rotated about an axis
is equal to 2*pi*A*R, where A is the area of the area,
and R is the distance of the centre of gravity of the area
from the axis.

To do this you must first find R. This could be calculated
from

  0.5*integral[ (f1(x) + f2(x))*(f2(x) - f1(x)), dx]

  = R*A

since you already know A. This formula is based on the fact
that the CG of a vertical line is at its midpoint and its
mass is proportional to its length. And, again, this formula
is written on the basis that f2 > f1, and also that f1 > 0.
In cases where either of these might not be true, you will
again have to decide what you mean by "the volume".

Comments for improvement will be welcome (and especially if
I've got anything wrong!).

Best wishes to all,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 09-Nov-04                                       Time: 20:41:50
------------------------------ XFMail ------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]