05-21-2021, 07:17 PM
Here is an integral, from a very old (2006) thread: So your HP can INTEGRATE ...
Solution from Valentin:
I tried in emu71, and showed timing and IBOUND
>A=1/4 @ P=1E-12
>X1=COS(A) @ Y1=SIN(A)
>T=TIME @ X2=INTEG(0,A,P,COS(IX)/SQRT(IX))/2 @ TIME-T, IBOUND
40.58 -9.93754844068E-13
>T=TIME @ Y2=INTEG(0,A,P,SIN(IX)/SQRT(IX))/2 @ TIME-T, IBOUND
.11 8.2963337046E-14
>X2, Y2, X1*X2+Y1*Y2
.496880004382 4.14810242686E-2 .491695777984
X2 required much time to calculate. But, IBOUND numbers seems good ...
However, if we rewrite integral, letting x=t^2, dx=2t dt, we get different numbers.
(we might as well do Y2 too, to compare effect of x=t^2 substitution)
>T=TIME @ X2=INTEG(0,.5,P,COS(IX*IX)) @ TIME-T, IBOUND
.11 4.96884313442E-13
>T=TIME @ Y2=INTEG(0,.5,P,SIN(IX*IX)) @ TIME-T, IBOUND
.17 4.14807134341E-14
>X2, Y2, X1*X2+Y1*Y2
.496884029215 4.14810242685E-2 .491699677694
We get exact result (all 12 digits correct !), using much less time.
---
X2 (with sqrt denominator), after u-transformation, end-point is not zero !
INTEGRAL assumed zero endpoints (both side), thus bad results.
\(\displaystyle \int_0^{1\over4} {\cos(x)\over2\sqrt{x}} dx
= \int_0^1 {\cos(t/4)\over4\sqrt{t}} dt
= \int_0^1 {6u(1-u)\cos(u^2(3-2u)/4)\over4\sqrt{u^2(3-2u)}} du
= {\sqrt{3}\over2}\int_0^1 \left(1-{2u\over3}-{u^2\over6}\;-\;...\right) du
\)
However, u-transformed plot looks like a straight line !
IBOUND numbers were fooled, suggesting excellent estimate, which it isn't.
Code:
/ Inf
I1 = | sin(x)*sin(x^2) .dx
/ 0
Code:
This is a very difficult integral to compute numerically to any decent accuracy ...
Fortunately, there's a nifty closed form for a generalized family of similar integrals,
this being but one of the simplest cases, namely:
/ A / A
I1 = (Cos(A)* | Cos(x)/Sqrt(x).dx + Sin(A)* | Sin(x)/Sqrt(x).dx )/2
/ 0 / 0
where A=1/4 and both non-elementary integrals are particular cases of Fresnel functions.
I tried in emu71, and showed timing and IBOUND
>A=1/4 @ P=1E-12
>X1=COS(A) @ Y1=SIN(A)
>T=TIME @ X2=INTEG(0,A,P,COS(IX)/SQRT(IX))/2 @ TIME-T, IBOUND
40.58 -9.93754844068E-13
>T=TIME @ Y2=INTEG(0,A,P,SIN(IX)/SQRT(IX))/2 @ TIME-T, IBOUND
.11 8.2963337046E-14
>X2, Y2, X1*X2+Y1*Y2
.496880004382 4.14810242686E-2 .491695777984
X2 required much time to calculate. But, IBOUND numbers seems good ...
However, if we rewrite integral, letting x=t^2, dx=2t dt, we get different numbers.
(we might as well do Y2 too, to compare effect of x=t^2 substitution)
>T=TIME @ X2=INTEG(0,.5,P,COS(IX*IX)) @ TIME-T, IBOUND
.11 4.96884313442E-13
>T=TIME @ Y2=INTEG(0,.5,P,SIN(IX*IX)) @ TIME-T, IBOUND
.17 4.14807134341E-14
>X2, Y2, X1*X2+Y1*Y2
.496884029215 4.14810242685E-2 .491699677694
We get exact result (all 12 digits correct !), using much less time.
---
X2 (with sqrt denominator), after u-transformation, end-point is not zero !
INTEGRAL assumed zero endpoints (both side), thus bad results.
\(\displaystyle \int_0^{1\over4} {\cos(x)\over2\sqrt{x}} dx
= \int_0^1 {\cos(t/4)\over4\sqrt{t}} dt
= \int_0^1 {6u(1-u)\cos(u^2(3-2u)/4)\over4\sqrt{u^2(3-2u)}} du
= {\sqrt{3}\over2}\int_0^1 \left(1-{2u\over3}-{u^2\over6}\;-\;...\right) du
\)
However, u-transformed plot looks like a straight line !
IBOUND numbers were fooled, suggesting excellent estimate, which it isn't.