ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 26 Jul 2015 15:29:13 +0200Can Sage verify (some) hyperbolic identities?https://ask.sagemath.org/question/28694/can-sage-verify-some-hyperbolic-identities/ If I enter `bool( cosh(x) == (exp(x)+exp(-x))/2 )`, the output is `False`. This happens with other hyperbolic identities. Is it possible to verify them in Sage? If so, what is the correct way?Fri, 24 Jul 2015 14:35:00 +0200https://ask.sagemath.org/question/28694/can-sage-verify-some-hyperbolic-identities/Answer by eric_g for <p>If I enter <code>bool( cosh(x) == (exp(x)+exp(-x))/2 )</code>, the output is <code>False</code>. This happens with other hyperbolic identities. Is it possible to verify them in Sage? If so, what is the correct way?</p>
https://ask.sagemath.org/question/28694/can-sage-verify-some-hyperbolic-identities/?answer=28696#post-id-28696Hi,
As far as I know, there is no simple way to verify such identities with Sage yet. A related issue is that Sage is currently unable to simplify `cosh(x) - (exp(x)+exp(-x))/2` to `0`:
sage: (cosh(x) - (exp(x)+exp(-x))/2).simplify_full()
1/2*(2*cosh(x)*e^x - e^(2*x) - 1)*e^(-x)
But there is a workaround: the `rewrite` extension written by François Maltey. To use it, download the file `rewrite-20110123.sage` from [this page](http://wiki.sagemath.org/symbolics/rewrite?action=AttachFile); then in a Sage session, you may ask to rewrite the hyperbolic functions in terms of exp, so that the outcome of the check is now `True`:
sage: %runfile rewrite-20110123.sage
sage: bool( rewrite(cosh(x), 'sinhcosh2exp') == (exp(x)+exp(-x))/2 )
True
Equivalently, you may also ask to rewrite the whole identity:
sage: bool( rewrite(cosh(x) == (exp(x)+exp(-x))/2, 'sinhcosh2exp') )
True
See [here](http://wiki.sagemath.org/symbolics/rewrite) for the documentation of `rewrite`.
Hopefully, it shall be included in main Sage some day.
Fri, 24 Jul 2015 21:54:31 +0200https://ask.sagemath.org/question/28694/can-sage-verify-some-hyperbolic-identities/?answer=28696#post-id-28696Answer by rws for <p>If I enter <code>bool( cosh(x) == (exp(x)+exp(-x))/2 )</code>, the output is <code>False</code>. This happens with other hyperbolic identities. Is it possible to verify them in Sage? If so, what is the correct way?</p>
https://ask.sagemath.org/question/28694/can-sage-verify-some-hyperbolic-identities/?answer=28706#post-id-28706You might want to familiarize with the Maxima and SymPy parts of Sage. With Maxima you can do
sage: ex = cosh(x) - (exp(x)+exp(-x))/2
sage: ex._maxima_().exponentialize().sage()
0
Here the Maxima function `exponentialize` does the rewrite. In Sympy:
sage: ex = cosh(x) - (exp(x)+exp(-x))/2
sage: import sympy
sage: sympy.simplify(ex)
0
Sun, 26 Jul 2015 15:29:13 +0200https://ask.sagemath.org/question/28694/can-sage-verify-some-hyperbolic-identities/?answer=28706#post-id-28706