Integral fails, NIntegral correct
Solved
I use Geogebra Classic 5.0.445(Desktop):
I have point-list with 4 points and construct 3 cubic splines:
pointL = {(0.1, 0.2), (0.4, 1.2), (2.2, 1), (3, 2)}
the splines:
f_s(x) = If(x < 0.4, 0(0.4 - x)³ - 3.65(x - 0.1)³ + 0.67 (0.4 - x) + 4.33 (x - 0.1), 0) +
If(0.4 ≤ x < 2.2, -0.61(2.2 - x)³ + 0.36(x - 0.4)³ + 2.64 (2.2 - x) - 0.6 (x - 0.4), 0) +
If(2.2 ≤ x, 0.8(3 - x)³ + 0(x - 2.2)³ + 0.74 (3 - x) + 2.5 (x - 2.2), 0)
now the integrals differ significantly:
NIntegral(f_s, 0.1, 3) -> 3.98 (which is correct)
Integral(f_s, 0.1, 3) -> 14.28 !!!!!!!!
Is something wrong in the upper commands or is it a bug?
Files:
build_splines.ggb
In the meantime I have found a workaround that helps:
g(x)=If(0.1 ≤ x ≤ 3, f_s(x))
Strange enough this yield the correct integral-number with Integral-command!
If you look at Integral(f_s) you'll see the problem (it's not continuous)
I can't see this (in my version of the program); I added a screenshot - as you can see even the derivative of f_s is
continuous, even the derivative of the derivative - splines must have this property.
Seems - we both see different things on the screen (therefore the screenshot!) - but thank you for thinking over it!
Sorry - I missed the point! You spoke of Integral(f_s) not f_s! But why is the integral-function F_s discontinuous?
As I see it, it should be
F_s(x):= int_a^x f_s(t)\, dt with "a" some real constant.
??? Can you explain, please!
The integration is done piecewise. If you define this (for the appropriate value of a!)
and then
then you can get accurate integrals with:
We've made an improvement for the next release (v448) so that Integral() and NIntegral() give the same answer for your example.
The approach above (defining F(x) first) is more robust and accurate though.
Also it's better to define such functions with one If() if possible, eg
Thank you Michael for your elaborate explanation - I must commit, I assumed the Integral-functions are also continuous - an error! Because my splines are built with Javascript as a "string", it's no problem to build a "one If" statement instead of an "If-sum";
After your proposal I think that it may be better to integrate my splines in javascript (polynomials should not be an obstacle), handle it over to geogebra, and take the derivative there - if I need an integration, I could use the "original" F_s- function with F_s(b)-F_s(a) (as you suggested)
Thank you once again - I've learned a lot!
Hans
v448 online now :)
Comments have been locked on this page!