MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Area under Curve



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




  • Prev by Date: Button Palette MMA 3.0
  • Next by Date: Re: How to select unique elements in a list?
  • Previous by thread: Area under Curve
  • Next by thread: [Q]contour integral in MMA3.0