Re: [sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

2010-03-13 Thread descopau



You can use something like this

   

dêkuji
merci
thank you for all the answers

always annoying to guess wether you should call maxima or not.

--
Guillaume

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread Guillaume

 No, AFAIK, nothing other than explicit substitution with .subs().

Hello,

there are a few weird results. I'd like to solve this homogenous edo :

 $tx'=x+\sqrt{x^2+y^2}$.

using x=tu

sage: t=var('t')
sage: x(t) = function('x',t)
sage: id(t)=t
sage: u=function('u',t)
sage: d=diff(u*id,t)

apparently, you can't substitute inside diff

sage: DE=(t*d==x+sqrt(t**2+x**2)).subs_expr(x==u*id)
sage: desolve(DE,[u,t])
arcsinh(u(t)) == c + integrate(abs(t)/t^2, t)
sage:  assume(t0)
sage: desolve(DE,[u,t])
arcsinh(u(t)) == c + integrate(1/t, t)
sage: desolve(DE,[u,t],[1,0])

oups, first problem :

Division by 0
#0: ic1(soln=asinh(u) = 'integrate(abs(t)/t^2,t)+%c,xc=t = 0,yc=u = 1)
(ode2.mac line 297)
 -- an error. To debug this try: debugmode(true);

sage: sol=desolve(DE,[u,t]).simplify_exp()
arcsinh(u(t)) == c + log(t)

OK

sage: desolve(DE,[u,t],[0,1]).simplify_exp()

but the problem reamins the same. Welle, let's make the substitution
by hand :

sage: solp=sol.subs(c=0)
sage: solp
arcsinh(u(t)) == log(t)
sage: Sol=solve(solp,u)[0]
sage: Sol
u(t) == sinh(log(t))
sage: x(t)=t*Sol.rhs()
sage: x(t)
t*sinh(log(t))

here comes our hyp2exp problem...

sage: sh(a)=(exp(a)-exp(-a))/2
sage: x(t).substitute_function(sinh,sh).simplify_full()
t*sinh(log(t))

argh

sage: x
t |-- t*sinh(log(t))

x is what we expect. Is it t ?

sage: x(a).substitute_function(sinh,sh).simplify_full()
a*sinh(log(a))

no...and now, weirder and weirder...

sage: a*sinh(log(a)).substitute_function(sinh,sh).simplify_full()
1/2*a*log(a) - 1/2
sage: t*sinh(log(t)).substitute_function(sinh,sh).simplify_full()
1/2*t^2 - 1/2

this 1/2*a*log(a) - 1/2 is a bit unexpected...

well, I'm discovering sage but these results look strange.

cheers,
Guillaume

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread ma...@mendelu.cz


On 12 bře, 16:48, Burcin Erocal bur...@erocal.org wrote:
 On Fri, 12 Mar 2010 15:23:43 +0100

 Paul Zimmermann paul.zimmerm...@loria.fr wrote:
  is there a way in Sage to convert expressions involving trigonometric
  or hyperbolic functions to exponentials, like the convert/exp
  function of Maple?

   convert(sinh(log(t)),exp);
                                            1
                                     t/2 - ---
                                           2 t

   convert(cos(log(t)),exp);  
                       1/2 exp(ln(t) I) + 1/2 exp(-I ln(t))

 No, AFAIK, nothing other than explicit substitution with .subs().


You can use something like this

desolve(t*diff(x,t)==x
+sqrt(x^2+t^2),x)._maxima_().ev(logarc=true).sage()
t == (sqrt(x(t)^2/t^2 + 1) + x(t)/t)*c

desolve(t*diff(x,t)==x+sqrt(x^2+t^2),x)
t == c*e^(arcsinh(x(t)/t))

Robert


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread ma...@mendelu.cz

On 12 bře, 21:19, Guillaume desco...@yahoo.fr wrote:
  No, AFAIK, nothing other than explicit substitution with .subs().

 Hello,

 there are a few weird results. I'd like to solve this homogenous edo :

  $tx'=x+\sqrt{x^2+y^2}$.

 using x=tu

 sage: t=var('t')
 sage: x(t) = function('x',t)
 sage: id(t)=t
 sage: u=function('u',t)
 sage: d=diff(u*id,t)


Is this what you want?

sage: t=var('t')
sage: x= function('x',t)
sage: id(t)=t
sage: u=function('u',t)
sage: d=diff(u*id,t)
sage: assume(t0)
sage: DE=(t*d==x+sqrt(t**2+x**2)).subs_expr(x==u*id)
sage: A=desolve(DE,u)
sage: C=var('C')
sage: A._maxima_().ev(logarc=true).sage().solve(u)[0].subs(c=log(C))

u(t) == C*t - sqrt(u(t)^2 + 1)


sage: eq = u == C*t - sqrt(u^2 + 1)
sage: ((eq-C*t)^2).solve(u)

[u(t) == 1/2*(C^2*t^2 - 1)/(C*t)]


The fact that the integral in A in not evaluated is probably a bug.
You may want to open trac on this and test, if this bug is inside
Maxima or in Sage interface to Maxima.

Robert


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread Yann
And I guess the answer to Paul's question is then:

sage: (sinh(log(t)))._maxima_().exponentialize().sage()
1/2*t - 1/2/t

sage: (cos(log(t)))._maxima_().exponentialize().sage()
1/2*e^(-I*log(t)) + 1/2*e^(I*log(t))

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org