Hyperbolic Secant

40 views
Skip to first unread message

Ondřej Čertík

unread,
Mar 19, 2014, 1:57:49 PM3/19/14
to sympy
Hi,

Should we add functions like hyperbolic secant into SymPy? Mpmath as
well as Mathematica has them:

http://docs.sympy.org/dev/modules/mpmath/functions/hyperbolic.html#sech
http://reference.wolfram.com/mathematica/ref/Sech.html

I needed it today when playing with solutions of Korteweg–de Vries equation:

https://en.wikipedia.org/wiki/Korteweg%E2%80%93de_Vries_equation#Soliton_solutions

Ondrej

Aaron Meurer

unread,
Mar 19, 2014, 2:57:24 PM3/19/14
to sy...@googlegroups.com
Yes, we should have all combinations of trig, arc trig, hyperbolic
trig, and arc hyperbolic trig functions.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVD-xiOGDjoO8-ijF_oBYXD73AzgY5ShiL4RDsmATZ%2BDTg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Aaron Meurer

unread,
Mar 19, 2014, 2:59:35 PM3/19/14
to sy...@googlegroups.com
And everything should work with them, if possible (rewrites,
evaluation, series expansion, simplification). Most of it is easy, you
just need to understand the math and the basic way that you write down
the rules in SymPy. It would be nice if we could figure out some way
to reduce duplication when writing down the trig functions, though.

Aaron Meurer

Ondřej Čertík

unread,
Mar 19, 2014, 4:34:32 PM3/19/14
to sympy
On Wed, Mar 19, 2014 at 12:59 PM, Aaron Meurer <asme...@gmail.com> wrote:
> And everything should work with them, if possible (rewrites,
> evaluation, series expansion, simplification). Most of it is easy, you
> just need to understand the math and the basic way that you write down
> the rules in SymPy. It would be nice if we could figure out some way
> to reduce duplication when writing down the trig functions, though.

For the sin/cos/tan, there is super nice way to unify the
simiplification, see this file:

https://github.com/certik/sympy/blob/trig/t.py

and I suspect there might be something similar for other functions.

Ondrej

Aaron Meurer

unread,
Mar 19, 2014, 7:42:55 PM3/19/14
to sy...@googlegroups.com
I think evaluation is pretty straightforward. You just evaluate one
(like sin), and then the rest are easily defined in terms of it. I
like your approach.

But what about the other things, like the series expansion or meijerg
table entries? And probably the biggest are the simplification rules
(e.g., for the Fu algorithm). And can we somehow get basically all of
the hyperbolic functions automatically from
http://mathworld.wolfram.com/OsbornesRule.html?

I wouldn't block on this, though. If you want to add a missing
function or functionality, you can just do it the duplicating way, and
we can figure out how to remove the duplication later. Just make sure
the tests verify the mathematical correctness of the functions.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVB2b0bLTiB8%3DWB%2BW0VnbgtFcsitTZRYYhH%2B_2YXVrXk%3Dg%40mail.gmail.com.

Ondřej Čertík

unread,
Mar 20, 2014, 2:55:14 AM3/20/14
to sympy
On Wed, Mar 19, 2014 at 5:42 PM, Aaron Meurer <asme...@gmail.com> wrote:
> I think evaluation is pretty straightforward. You just evaluate one
> (like sin), and then the rest are easily defined in terms of it. I
> like your approach.
>
> But what about the other things, like the series expansion or meijerg
> table entries? And probably the biggest are the simplification rules

I think the series expansion can be unified too, it looks quite similar.

> (e.g., for the Fu algorithm). And can we somehow get basically all of
> the hyperbolic functions automatically from
> http://mathworld.wolfram.com/OsbornesRule.html?

These two I don't know. We should look at some other software like
Axiom, Maxima or Sage.

>
> I wouldn't block on this, though. If you want to add a missing
> function or functionality, you can just do it the duplicating way, and
> we can figure out how to remove the duplication later. Just make sure
> the tests verify the mathematical correctness of the functions.

Hopefully I'll have some time over the summer to do this.

Ondrej

Aaron Meurer

unread,
Mar 20, 2014, 11:42:41 AM3/20/14
to sy...@googlegroups.com
On Thu, Mar 20, 2014 at 1:55 AM, Ondřej Čertík <ondrej...@gmail.com> wrote:
> On Wed, Mar 19, 2014 at 5:42 PM, Aaron Meurer <asme...@gmail.com> wrote:
>> I think evaluation is pretty straightforward. You just evaluate one
>> (like sin), and then the rest are easily defined in terms of it. I
>> like your approach.
>>
>> But what about the other things, like the series expansion or meijerg
>> table entries? And probably the biggest are the simplification rules
>
> I think the series expansion can be unified too, it looks quite similar.
>
>> (e.g., for the Fu algorithm). And can we somehow get basically all of
>> the hyperbolic functions automatically from
>> http://mathworld.wolfram.com/OsbornesRule.html?
>
> These two I don't know. We should look at some other software like
> Axiom, Maxima or Sage.

Or just prove whatever rule we use rigorously. Trig functions aren't
that complicated, it should be possible to do so.

>
>>
>> I wouldn't block on this, though. If you want to add a missing
>> function or functionality, you can just do it the duplicating way, and
>> we can figure out how to remove the duplication later. Just make sure
>> the tests verify the mathematical correctness of the functions.
>
> Hopefully I'll have some time over the summer to do this.
>
> Ondrej

Great. There are also some useful notes here
https://github.com/sympy/sympy/wiki/About-implementing-special-functions.

Aaron Meurer

>
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVAUH-H8FmnHtdMWRsBVT7kmOM309Dea0Lpq3hGdE6fLQg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages