Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.
|
|
|
Re: [mg7943] Area under Curve
Posted:
Jul 30, 1997 2:34 AM
|
|
On Fri, 25 Jul 1997, Sankar Baruah wrote:
> I am new to Mathematica and would really appreciate some pointers from > experienced users. I have a 2 variable data set of about 50 > observations. I want to plot each obseravtion and calculate the area > under the curve. How do I do this in Mathematica ? > Are there examples in the Mathematica Book and/or are there separate > application notes etc. available ? > Thanks. > Sankar. > > >
Hi Sankar,
there is no need to be experienced to solve this problem. You have many solutions to do this (take also a look at the Mma books):
1. your data is really: {..., {xi, f[xi]}, ... }
- try ListIntegrate - try an Interpolation + Integration - write a simple Trapez system as the one below.
2. you data is {..., {xi,yi}, ... } - a closed curve.
- I do not know the function but, the following simple function functioned pretty well:
Cint[ data_ ] := Module[{mylist,intg}, imax = Length[data]; mylist = Append[ data, data[[1]] ]; intg = 0; Do[ intg += 0.25 (mylist[[i,2]] + mylist[[i+1,2]]) (mylist[[i+1,1]] - mylist[[i,1]]); intg += - 0.25 (mylist[[i,1]] + mylist[[i+1,1]]) (mylist[[i+1,2]] - mylist[[i,2]]) , {i,imax} ]; Print[ intg / 4524., " [MJ /m^3]"] ]
a + andrei
|
|
|
|