HP Forums
[bug]Calculate a conditional re-integration - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: [bug]Calculate a conditional re-integration (/thread-12785.html)



[bug]Calculate a conditional re-integration - yangyongkang - 04-11-2019 12:57 PM

Not much to say, directly on the code
Code:
∫(∫(min(x^2,y^2),y,0,1),x,0,3)
The XCAS terminal gives a big push warning
Code:
Warning, integration of abs or sign assumes constant sign by intervals (correct if the argument is real):
Check [abs(taylorx10^2-taylorx11^2)]
Discontinuities at zeroes of taylorx10^2-taylorx11^2 were not checked
No checks were made for singular points of antiderivative (taylorx10^2*taylorx11+(taylorx11^3)/3-(-(taylorx11^3)/3+taylorx10^2*taylorx11)*sign(taylorx10^2-taylorx11^2))/2 for definite integration in [0,1]
Warning, integration of abs or sign assumes constant sign by intervals (correct if the argument is real):
Check [sign(taylorx10^2-1)]
Discontinuities at zeroes of taylorx10^2-1 were not checked
Warning, integration of abs or sign assumes constant sign by intervals (correct if the argument is real):
Check [sign(taylorx10^2-1)]
Discontinuities at zeroes of taylorx10^2-1 were not checked



XCAS also gives the answer
Code:
1



But it is the wrong answer

WolframAlpha: ∫(∫(min(x^2,y^2),y,0,1),x,0,3)

Wolfram Alpha is right


Looking forward to the update of hp prime firmware in 2019


RE: [bug]Calculate a conditional re-integration - parisse - 04-11-2019 06:30 PM

You have been warned that some checks were not done, it's not that surprising that the answer is wrong. Now ask yourself, how can I solve this exacty in an algorithm? You must find an antiderivative of min(x^2,y^2), and to do that you must rewrite min(x^2,y^2) algebraically, which is
x^2+y^2-(x^2-y^2)*sign(x^2-y^2)
then you can integrate w.r.t. y, since sign is constant by interval, g:=int((x^2+y^2)/2-abs(x^2-y^2)/2,y)
giving
(y^3/3+x^2*y)/2-sign(x^2-y^2)*(-y^3/3+x^2*y)/2
Then you would substitute between 0 and 1,
h:=g(y=1)-g(y=0)
but that's not sufficient, because you should take care of the points where sign(x^2-y^2) is not continuous and add the right/left limit difference. And that means solving an equation. I have decided not to solve it if it is a parametric equation (here the equation in y depends on x), because it would raise endless loops or fail, instead I issue a warning.
Let's correct it :
h1:=limit(g,y,x,1)-limit(g,y,x,-1)
We must correct the integral by substracting this step, for x in [0,1], i.e substract int(h1,x,0,1)=1/6.
I guess mathematica does more complete checks, but at some point, you will certainly be able to make it return wrong answer as well. I do not have a staff of people trying a lot of weird integrals to improve/implement automatic checks, you will have to be a little bit more smart, and fix answers when you have been warned.