Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: What's wrong with cumtrapz?
Replies: 2   Last Post: May 4, 2001 10:09 AM

 Messages: [ Previous | Next ]
 Timothy E. Vaughan Posts: 39 Registered: 12/7/04
Re: What's wrong with cumtrapz?
Posted: May 4, 2001 10:09 AM

""Leung, Randolph [COPE/HKG]"" <RckLeung@Copeland-Corp.com> wrote in message
news://9B636583813BD311BE6400508B10481F6C5274@fs83.hk.copeland-sid.com...
>
> I have some experimental time traces to integrate. CUMTRAPZ seems
> to be a simple and easy option for me. To test it, I tried to integrate a
> simple SIN(X) time trace as follows,
>
> x = 0:pi/100:4*pi];
> y = sin( 2*pi*x).
>
> inty = cumtrapz( x', y' );
>
> I would expect a COS(X) time trace after CUMTRAPZ. The integrated
> time trace gave a cos pattern of variation, correct amplitude BUT was
> wrong in phase and shifted upwards, i.e. it is greater than zero for all
> x and gives 0, rather than 1, at x = 0. I am very confused with the
> results.

It seems you may be forgetting a bit of your calculus. You are numerically
taking the INDEFINITE integral of your function. In that case, you must be
prepared to add a constant to your solution. [I think it is really only
shifted "upward", and not really wrong in phase.] You need to determine the
appropriate constant from other conditions of your problem.

Tim

Date Subject Author
5/3/01 "Leung, Randolph [COPE/HKG]"
5/4/01 Nabeel Azar
5/4/01 Timothy E. Vaughan