+1

On Nov 13, 2008, at 8:48 PM, Ondrej Certik wrote:

>
> The simplifications were already implemented for cosh(), so this  
> patch fixes it
> for sinh() and tanh() as well.
> ---
> sympy/functions/elementary/hyperbolic.py           |   28 +++++++++++ 
> ++++++--
> .../functions/elementary/tests/test_hyperbolic.py  |   10 ++++++-
> 2 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/sympy/functions/elementary/hyperbolic.py b/sympy/ 
> functions/elementary/hyperbolic.py
> index fe9b0db..ebb29ec 100644
> --- a/sympy/functions/elementary/hyperbolic.py
> +++ b/sympy/functions/elementary/hyperbolic.py
> @@ -52,6 +52,17 @@ class sinh(Function):
>                 if coeff.is_negative:
>                     return -cls(-arg)
>
> +            if isinstance(arg, asinh):
> +                return arg.args[0]
> +
> +            if isinstance(arg, acosh):
> +                x = arg.args[0]
> +                return sqrt(x-1) * sqrt(x+1)
> +
> +            if isinstance(arg, atanh):
> +                x = arg.args[0]
> +                return x/sqrt(1-x**2)
> +
>     @staticmethod
>     @cacheit
>     def taylor_term(n, x, *previous_terms):
> @@ -152,12 +163,12 @@ class cosh(Function):
>                 if coeff.is_negative:
>                     return cls(-arg)
>
> -            if isinstance(arg, acosh):
> -                return arg.args[0]
> -
>             if isinstance(arg, asinh):
>                 return sqrt(1+arg.args[0]**2)
>
> +            if isinstance(arg, acosh):
> +                return arg.args[0]
> +
>             if isinstance(arg, atanh):
>                 return 1/sqrt(1-arg.args[0]**2)
>
> @@ -261,6 +272,17 @@ class tanh(Function):
>                 if coeff.is_negative:
>                     return -cls(-arg)
>
> +            if isinstance(arg, asinh):
> +                x = arg.args[0]
> +                return x/sqrt(1+x**2)
> +
> +            if isinstance(arg, acosh):
> +                x = arg.args[0]
> +                return sqrt(x-1) * sqrt(x+1) / x
> +
> +            if isinstance(arg, atanh):
> +                return arg.args[0]
> +
>     @staticmethod
>     @cacheit
>     def taylor_term(n, x, *previous_terms):
> diff --git a/sympy/functions/elementary/tests/test_hyperbolic.py b/ 
> sympy/functions/elementary/tests/test_hyperbolic.py
> index 1d5c7eb..e42df20 100644
> --- a/sympy/functions/elementary/tests/test_hyperbolic.py
> +++ b/sympy/functions/elementary/tests/test_hyperbolic.py
> @@ -306,9 +306,17 @@ def test_acoth():
>
> def test_simplifications():
>     x = Symbol('x')
> -    assert cosh(acosh(x)) == x
> +    assert sinh(asinh(x)) == x
> +    assert sinh(acosh(x)) == sqrt(x-1) * sqrt(x+1)
> +    assert sinh(atanh(x)) == x/sqrt(1-x**2)
> +
>     assert cosh(asinh(x)) == sqrt(1+x**2)
> +    assert cosh(acosh(x)) == x
>     assert cosh(atanh(x)) == 1/sqrt(1-x**2)
>
> +    assert tanh(asinh(x)) == x/sqrt(1+x**2)
> +    assert tanh(acosh(x)) == sqrt(x-1) * sqrt(x+1) / x
> +    assert tanh(atanh(x)) == x
> +
> def test_issue1037():
>     assert cosh(asinh(Integer(3)/2)) == sqrt(Integer(13)/4)
> -- 
> 1.5.6.5
>
>
> >

--------------------
Fabian Seoane
http://fseoane.net






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to