I am having a bit of trouble with direct integration on the attached sheet. I have a data set provided in Excel format which I have converted to matrix/vector form and then to function form using cubic spline interpolation. Unfortunately I am having trouble integrating the resulting function in x and am receiving a "This calculation does not converge to a solution" error message.
I have tried changing TOL to ridiculous values like 1E-50, with no luck.
Any assistance would be greatly appreciated.
Many thanks and kind regards
Solved! Go to Solution.
Without seeing your worksheet...
Why do you think that creating a spline from a data vector and integrating along that spline would give you a better (more accurate?) result than just summing all data points?
A spline is no more than a nice curve along your data points and, unless there is other/prior knowledge about the system that creates the data points, you cannot add accuracy by creating a spline.
Assuming that Alan solved the problem, and you now know the result of integration: compare that with simply adding up the data points. Then decide if creating the spline is worth all the trouble...
You are wondering why in Alan's sheet the integral utot works now for you? The reason is that he disabled your TOL setting and so the default TOL=10^-3 is valid now.
Setting the value of TOL to lower values (10^-4 or lower, as you did) increases the chance of the integral NOT converging!
Your approach with U.vol works without vectorization if you use an undefined variable (quickplot) or a range as argument:
As to the trapezoid rule - here is an approach using your raw data:
Worksheet in MC15 format attached.
This is what I'm talking about.
Note that the definition of integration is nothing else than summing vertical bars of infinitesimally small width, and height equal to the function value at the (ordinate) mid point of each bar.
Now you choose the best approximation.
I agree that its more elegant to replace the for-loop by the summation operator:
We should not assume that the X-values are equidistant.
In case of the data in the sheet, most x-values are 10^-4 but just very few have the distance 2*2^10^-4.
Other datasets might have bigger differences, though.