Hi,

I'm reading data points from a graph.  The points could for example be
(0, 0), (1, 3), (2, 8).  I would like to calculate the integral of the
piecewise linear segments that these points span.

Ideally, I want a command of this type: integral( (0, 0), (1, 3), (2,
8) ).  Does such a command exist in Sage?

I found trapezoid_integral_approximation, for instance, but this one
is messy compared to what I want.  Here you need to define the
interval and local function for each segment, instead of just listing
the points.

Below is an attempt to use trapezoid_integral_approximation in the
fashion I desire.  It's bulky and does not work.

y_0, s_0, y_1, s_1, y = var('y_0, s_0, y_1, s_1, y');

f (y_0, s_0, y_1, s_1, y)= (y - y_0) * ((s_1 - s_0) / (y_1 - y_0)) +
s_0;

sigma = Piecewise([[ (0, 1), f (0, 100, 1, 300) ]]);
print f.trapezoid_integral_approximation(4);

Regards,
hpon
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to