Thank you very much Francois, much more explicit than I expected!!!

On Jan 23, 4:39 pm, Francois Maltey <fmal...@nerim.fr> wrote:
> Dox a crit :
>
> > Hi guys! I have an easy question... got an expression with
> > exponentials, say exp(x)+exp(-x), How can I get the result in terms of
> > hyperbolic functions
>
> 1/ First you can use the expr.subs method :
>
> y=exp(x)+exp(-x)
> y.subs(exp(x)==sinh(x)+cosh(x)).subs(exp(-x)=cosh(x)-sinh(x))
>
> [You must call subs for all subexpressions : exp(x) and (exp(-x)]
>
> 2/ Second you can also play with match, find and subs :
>
> w0=SR.wild(0)   # w0 is now a matching subexpression
> y.subs(exp(w0)==cosh(w0)+sinh(w0))
>
> The result is sinh(-x) + sinh(x) + cosh(-x) + cosh(x)
> And then y.subs(exp(w0)==cosh(w0)+sinh(w0)).simplify() is pretty.
>
> I think it's impossible to subs the function exp to the other (sum of)
> function(s) exp=cosh+sinh.
> You must use the regular subexpression SR.wild(0) [look at help about
> find, subs and match]
>
> 3/ Third, you can use the outside Sage function rewrite published 
> athttp://wiki.sagemath.org/symbolics/rewriteand get the attachement file
> rewriteXXXX.sage, load it.
> and call rewrite (y, rules="exp2sinhcosh").
>
> Choice what you prefer !
>
> F.

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

Reply via email to