Thank you.
I had already done something similar.
I just wanted to make sure I wasn't re-inventing the wheel if a built-in function is available.? Built-in
functions also make the code much faster and cleaner.
________________________________
From: Jaime Villate <villate at fe.up.pt>
To: Ether Jones <maxima at etherjones.us>
Cc: maxima <maxima at math.utexas.edu>
Sent: Tuesday, September 17, 2013 5:09 PM
Subject: Re: [Maxima] integrating a list
On 17-09-2013 18:48, Ether Jones wrote:
I have a list of ordered pairs (t,speed) representing the speed of an object vs time.
>
>
>Is there a built-in Maxima function to generate the associated list of ordered pairs (t,distance)?
>
>
>The "t" values are equally spaced apart.
>
>
Hi,
I'm not aware of any built-in functions, but you could implement the
trapezoid (or other) rule:
list_integrate(x) := block([y: [[x[1][1], 0]]],
??????????????? for i:2 thru length(x) do
???????????????????? y:endcons( [x[i][1], y[i-1][2] + (x[i][1]-x[i-1][1])*(x[i-1][2] + x[i][2])/2],y),
? ? ? ? ? ? ? ? y)$
and use it like this:
list_integrate( [[1,4], [2,3], [3,6]] )?? ----> [[1,0], [2,7/2],
[3,8]]
I hope this helps. Regards,
Jaime