Quadrature with data table for input


MPD78
09-01-2009, 10:04 AM
Hello all,

Is there a way to modify quadrature.h in order to numericaly integrate this data?

Here is my raw data.

% A T1 T2

0.00 1125.00 1550.00
10.00 1055.43 1515.14
20.00 980.17 1477.44
30.00 898.77 1436.66
40.00 810.71 1392.55
50.00 715.46 1344.83
60.00 612.44 1293.21
70.00 500.99 1237.38
80.00 380.44 1176.99
90.00 250.05 1111.66
100.00 109.00 1041.00


What I want to do is integrate T1 vs %A and integrate T2 vs %A and then subtract the two areas to obtain the area between the two curves. Very simple problem.

My approach would be to load the two temperatures T1 and T2 into an array and load the %A into an array and then perform the integration.

My problem is this.

How do you read data of this type into the routines in quadrature.h? Also, I am assuming that Trapzd would be perfect for this job. Am I correct in that assumption?

Any help would be greatly appreciated.

Thanks
Matt D.

davekw7x
09-01-2009, 12:46 PM
...
Is there a way...

The routines in quadrature.h are used to integrate functions, not collections of points. (They have to evaluate the functions at arbitrary values, not just at a fixed number of points.)

For a fixed number of points, you can use any of the Newton-Cotes formulas as enumerated in section 4.1 of the text.

If the underlying functions are as smooth as your point values seem to indicate, just use the extended trapezoid rule (Equation 4.1.11) and the extended Simpson's rule (Equation 4.1.13) for each set of points. The differences in the values from the trapezoid and Simpson formulas for a given set of points will give you an error estimate.

You could also try subtracting the point values first and then applying the extended trapezoid formula and extended Simpson formula to those points.



Regards,

Dave

MPD78
09-01-2009, 02:03 PM
Dave,

Thanks for advice. I will proceed in that direction.

Matt

MPD78
09-09-2009, 02:24 PM
For completeness of the thread, I implemented the equations listed above and all worked as desired.

Thanks
Matt