Feeds:
Posts

SAGE tip: rewriting expressions

Today I was calculating some stuff with the help of SAGE, and realize that the expressions got a lot (really, a lot) simpler if they where written in terms of  hyperbolic functions instead of exponentials.

$e^x = \cosh(x)+\sinh(x)$

$e^{-x} = \cosh(x)-\sinh(x)$

So I enter the sage-devel channel of IRC (freenode), but there was a lazy day around… Sunday. Therefore I decided to write to the sage-dev group on Google groups.

Francois Maltey answer my question on how to do the transformation… He has written a package that does it!

• Go to page http://wiki.sagemath.org/symbolics/rewrite
look at the second line the “attachement” (in smaller characters)
and get the most recent file.
• Then put this file in your Sage directory
In Sage, type : load “/the/good/file/in/the/good/directory’
Then call the rewrite function.
• Thank you Francois

Example

Suppose the path to the file is “/home/me/rewrite-xxx.sage”

```sage: load "/home/me/rewrite-xxx.sage" sage: A = exp(x) + exp(-x) sage: rewrite(A, 'exp2sinhconh') 2*cosh(x)```

If you go to http://wiki.sagemath.org/symbolics/rewrite, will find all possible commands which perform such transformations.

Enjoy!

Dox