Re: Compute area between curves [message #62881 is a reply to message #62821] |
Mon, 13 October 2008 22:35   |
mystea
Messages: 16 Registered: October 2007
|
Junior Member |
|
|
Hi everyone,
I am also working on a topic where I need to numerically calculate an
integral
of a tabulated function. However, what I need is an indefinite
integral, namely,
the area under a curve as a function of x-coordinate.
The procedure int_tabulated only calculates the definite integral,
given tabulated
f and its x-coordinates x. Let's say both f and x are double array of
length nl.
I tried the following fix:
integral=dblarr(nl)
for i=1, nl-1 do integral[i]=int_tabulated(x[0:i],f[0:i])
I thought it will work but not quite! Turns out that in general, the
result
integral will not be monotone even if f are always positive. I
believe this has something
to do with the algorithm of int_tabulated? How can I produce a
consistent calculation of
the indefinite integral?
Best Regards,
Gene
On Oct 13, 9:42 pm, Craig Markwardt
<craigm...@REMOVEcow.physics.wisc.edu> wrote:
> James Kuyper <jameskuy...@verizon.net> writes:
>> A more general approach would would work regardless of the shapes of
>> the two curves. Just connect the two curves to create a single
>> combined curve that starts by listing all the points on one curve in
>> clockwise order, then continues by listing all of the points of the
>> other curve in counter-clockwise order. As a result, the combined
>> curve encloses the area that lies between the two curves. Then use
>> POLY_AREA to calculates the area enclosed by the combined curve.
>
> ...
>
> James, I had that thought as well, but I believe POLY_AREA will not
> work as expected. When a polygon's edges self-intersect, then the
> polygon is no longer "simple." In that case, the POLY_AREA method
> will compute the *signed* total area. Polygonal segments where the
> path traverses clockwise will contribute in a positive sense, and
> counter-clockwise in the negative sense. The result will not be the
> 'total' area as we commonly expect, but some kind of non-intuitive
> 'net' area.
>
> I still think the original questioner doesn't really know what he
> needs yet.
>
> Craig
>
> --
> ------------------------------------------------------------ --------------
> Craig B. Markwardt, Ph.D. EMAIL: cbmarkwardt+use...@gmail.com
> ------------------------------------------------------------ --------------
|
|
|