Post Reply 
Issues with integral
08-19-2020, 09:03 PM
Post: #1
Issues with integral
Hello,

i try to compute this integral
int(1/(sqrt(cos(x))+sqrt(sin(x)))^4,x,0,pi/2)

The calculator simply hang, i can't stop computing. in the emulator it show some messages and don't do the computation.

When i do the same computation on Nspire or wolfram, i have to right answer (1/3).

I have tested with xcas on Linux (icas), it can't compute this integral.
Find all posts by this user
Quote this message in a reply
08-20-2020, 12:23 AM
Post: #2
RE: Issues with integral
(08-19-2020 09:03 PM)Mordicus1973 Wrote:  int(1/(sqrt(cos(x))+sqrt(sin(x)))^4,x,0,pi/2)

XCas> gaussquad(1/(sqrt(cos(x))+sqrt(sin(x)))^4,x,0,pi/2)     → 0.333333333333

Doing integral symbolically, let t = tan(x) → dt = sec(x)^2 dx

\(\Large{1 \over (\sqrt{\cos x}+\sqrt{\sin x})^4} = {\sec^2 x \over (1+\sqrt{\tan x})^4} \)

XCas> F := int(1/(1+sqrt(t))^4, t)      → \(\Large
\frac{2 (-3\cdot \sqrt{t}-1)}{6 \left(\sqrt{t}+1\right)^{3}}\)

Limit of x = 0 to pi/2, same as t = 0 to +inf

XCas> preval(F,0, inf, t)                     → = 0 - (-1/3) = 1/3
Find all posts by this user
Quote this message in a reply
08-20-2020, 12:44 PM
Post: #3
RE: Issues with integral
(08-19-2020 09:03 PM)Mordicus1973 Wrote:  Hello,

i try to compute this integral
int(1/(sqrt(cos(x))+sqrt(sin(x)))^4,x,0,pi/2)

The calculator simply hang, i can't stop computing. in the emulator it show some messages and don't do the computation.

When i do the same computation on Nspire or wolfram, i have to right answer (1/3).

I have tested with xcas on Linux (icas), it can't compute this integral.

Interestingly...
It works perfectly fine if you enter the integral in Home mode...gives you an instantaneous .333333333... or 1/3.

It's usually the other way round for me .... CAS will frequently solve things Home won't.

I was bored and tried this problem on about 20 calculators I had within arm's reach. Every one got it right. Even the old HP-48 eats it right up.
The TI-89 CAS got it right. Same with the HP50g, 40gs, 49g, some Casios.

ENTER > =
Find all posts by this user
Quote this message in a reply
08-20-2020, 12:52 PM
Post: #4
RE: Issues with integral
If you turn off exact mode in CAS setup, it works fine in CAS, as well.

(But it certainly does 'blow up' if exact is left checked.)

ENTER > =
Find all posts by this user
Quote this message in a reply
08-20-2020, 02:42 PM
Post: #5
RE: Issues with integral
In cas:

∫(1/sin2costan((sqrt(cos(x))+sqrt(sin(x)))^4),x,0,π/2) returns 1/3

-road
Find all posts by this user
Quote this message in a reply
08-20-2020, 03:30 PM
Post: #6
RE: Issues with integral
(08-20-2020 02:42 PM)roadrunner Wrote:  In cas:

∫(1/sin2costan((sqrt(cos(x))+sqrt(sin(x)))^4),x,0,π/2) returns 1/3

-road

Thanks for the trick. Yes works on the Prime under XCAS exact mode now. But only after displaying a screen of scary warnings....

Prime Non exact XCAS mode works fine and get 0.3333 instantly with or without the sin2costan and with no warning page.

Any explanation on that interesting behavior of XCAS ?
Find all posts by this user
Quote this message in a reply
08-20-2020, 04:06 PM (This post was last modified: 08-20-2020 04:41 PM by Mordicus1973.)
Post: #7
RE: Issues with integral
(08-20-2020 12:52 PM)trojdor Wrote:  If you turn off exact mode in CAS setup, it works fine in CAS, as well.

(But it certainly does 'blow up' if exact is left checked.)

Yes, thank you for the tips.

Also, in the Function application, i can compute the integral (signed area i think in english) and it return 0.333333...
Find all posts by this user
Quote this message in a reply
08-21-2020, 07:12 PM
Post: #8
RE: Issues with integral
(08-20-2020 03:30 PM)Chr Yoko Wrote:  ...Any explanation on that interesting behavior of XCAS ?

All i know is CAS frequently seems to be happier when SIN is eliminated in the equation.
Find all posts by this user
Quote this message in a reply
08-22-2020, 06:12 AM
Post: #9
RE: Issues with integral
I just checked with a TI 89 and with a TI CX Nspire CAS, the integral is computed in approx mode, not in exact mode. On the Prime in CAS exact mode, the CAS tries to compute the integral exactly, and unfortunately this raises large computations that are hard to interrupt.
If you are interested in an approx value inside the CAS, just replace one boundary by an approx value, e.g. 0 by 0.0 and you will get almost instant the approx answer.
∫(1/(sqrt(cos(x))+sqrt(sin(x)))^4,x,0.0,π/2)
For an exact answer, you must help the CAS, like with roadrunner trick.
Find all posts by this user
Quote this message in a reply
08-22-2020, 07:23 AM
Post: #10
RE: Issues with integral
(08-22-2020 06:12 AM)parisse Wrote:  For an exact answer, you must help the CAS, like with roadrunner trick.

Hello Parris,
Thank for your reply and the tips.

The real issue here is not getting or not the answer, the real issue is that the calculator hang.
If it happen during exam it can be catastrophic for the student. He have to push reset button but he will need a needle (the hole is realy small).

Doing the same with icas :

int(1/(sqrt(cos(x))+sqrt(sin(x)))^4,x,0,pi/2)
Simplification en supposant x near 0
Simplification en supposant x near 0
Simplification en supposant x near 0
Simplification en supposant x near 0
Extension algébrique non autorisée dans un rootof
Extension algébrique non autorisée dans un rootof
Attention, on choisit une racine de [1,0,%%%{-4,[1,0]%%%},0,%%%{4,[0,2]%%%}]aux valeurs de paramètre [18,-49]
Attention, on choisit une racine de [1,0,%%%{-4,[1,0]%%%},0,%%%{4,[0,2]%%%}]aux valeurs de paramètre [-64,2]
Simplification en supposant x near pi/4
Simplification en supposant x near pi/4
Attention, on choisit une racine de [1,0,%%%{-2,[1,1]%%%}+%%%{-2,[1,0]%%%},0,%%%{1,[2,2]%%%}+%%%{-2,[2,1]%%%}+%%%{1,[2,0]%%%}]aux valeurs de paramètre [31,-21]
integration(1/(sqrt(cos(x))+sqrt(sin(x)))^4,x,0,pi/2)
// Time 0.18

If the G2 do the same, then he can try alternative method to compute the intergral
Find all posts by this user
Quote this message in a reply
08-22-2020, 04:16 PM
Post: #11
RE: Issues with integral
Nice explanations and tricks, thanks.

Bernard,
Could you please explain the first warning in the message from the console?

Simplification assuming taylorx0 near π/4
Simplification assuming taylorx0 near π/4
Warning, choosing root of [1,0,%%%{-2,[1,1]%%%}+%%%{-2,[1,0]%%%},0,%%%{1,[2,2]%%%}+%%%{-2,[2,1]%%%}+%%%{1,[2,0]%%%}] at parameters values [-72,58]
Warning, 1/4*π not checked

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
08-25-2020, 07:12 AM
Post: #12
RE: Issues with integral
@Mordicus1973: The code executed on the Prime is not always the same as on a PC. One reason is that exceptions are not enabled on the Prime, and this make keyboard interruption harder to handle. Another reason is that some optimizations are not enabled on the Prime for various reasons, e.g. it is not possible to link with the GPL libraries like on a PC.

@pinkman: this is an expert diagnostic message. Xcas handles simplification of sqrt or fractional powers by constructing a unique algebraic extension. Sometimes extracting a square root or fractional power inside an extension requires choosing a branch. For numeric sqrt, this is done by checking approx values. If the sqrt argument depends on a parameter, the system must still choose, and it does that by replacing the parameter with random numeric values. If you make assumptions on the parameter, the assumption is taken in account in the random choice.
Find all posts by this user
Quote this message in a reply
08-25-2020, 08:12 PM
Post: #13
RE: Issues with integral
Thanks for taking the time to answer. The CAS symbolic engine is really a masterpiece.

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)