Ask Your Question
1

why canonicalize_radical() gives a wrong answer ?

asked 2021-11-04 21:30:54 +0200

mignonph75 gravatar image

updated 2021-11-04 21:36:58 +0200

Hello,

Here is the script :

var('epsilon t')
y=function('y')(t)

de = diff(y,t,2)+2*epsilon*diff(y,t,1)+y == 0

assume(epsilon<1)
assume(epsilon>-1)
u(t) = desolve(de,y,ivar=t)

var('k_1')
sol=solve(diff(u(t).subs(_K2=0),t).subs(t=0).subs(_K1=k_1)==1,k_1)
sol[0].rhs().simplify_full()

u(t).subs(_K2=0).subs(_K1=sol[0].rhs().simplify_full())

gives the right answer:

2e^(-epsilont)sin(1/2sqrt(-4epsilon^2 + 4)t)/sqrt(-4*epsilon^2 + 4)

but

(u(t).subs(_K2=0).subs(_K1=sol[0].rhs().simplify_full())).canonicalize_radical()

gives a wrong answer (sinh instead of sin):

e^(-epsilont)sinh(sqrt(epsilon + 1)sqrt(epsilon - 1)t)/(sqrt(epsilon + 1)*sqrt(epsilon - 1))

Could anyone tell me why ?

Thank you

edit retag flag offensive close merge delete

Comments

Hint :

sage: sinh(I*x)
I*sin(x)
sage: sin(I*x)
I*sinh(x)

Also, see ?exponentialize.

And remember that Sage tends to rewrite some expressions "his way", no matter what...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-11-05 14:23:57 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-01-01 22:38:05 +0200

Emmanuel Charpentier gravatar image

Sage is somewhat recalcitrant to work with power (inluding radix) simplification,for excellent reasons. Similarly, it tends to pull imaginary quantities out of trig/hyperbolic functions (see remark above).

After

var('epsilon t')
y=function('y')(t)
de = diff(y,t,2)+2*epsilon*diff(y,t,1)+y == 0
assume(epsilon<1)
assume(epsilon>-1)
u(t) = desolve(de,y,ivar=t)
var('k_1')
sol=solve(diff(u(t).subs(_K2=0),t).subs(t=0).subs(_K1=k_1)==1,k_1)
sol[0].rhs().simplify_full()
E1=u(t).subs(_K2=0).subs(_K1=sol[0].rhs().simplify_full())
E2=E1.canonicalize_radical()

E1/E2 is

$$ \frac{2 \, \sqrt{\epsilon + 1} \sqrt{\epsilon - 1} \sin\left(\frac{1}{2} \, \sqrt{-4 \, \epsilon^{2} + 4} t\right)}{\sqrt{-4 \, \epsilon^{2} + 4} \sinh\left(\sqrt{\epsilon + 1} \sqrt{\epsilon - 1} t\right)} $$

but giac somewhat recklessly can deduce :

sage: (E2/E1)._giac_().simplify()._sage_().factor()
1

HTH,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-11-04 21:30:54 +0200

Seen: 126 times

Last updated: Jan 01 '22