Pi formulas

63 views
Skip to first unread message

Fredrik Johansson

unread,
Mar 11, 2016, 8:03:43 AM3/11/16
to sympy
Hi,

To celebrate Pi Day (three days from now) and the 1.0 release of
SymPy, I propose collecting ways to produce the symbolic result "pi"
with SymPy.

I have created a git repository
(https://github.com/fredrik-johansson/314) to collect such pi
examples, using my old list of "100 mpmath one-liners for pi" as the
starting point. Feel free to contribute!

A useful project would be to go through all of the mpmath examples and
improve SymPy's symbolic capabilities to the point where it can
simplify all those formulas to pi (perhaps after the user invokes the
right simplification and rewriting commands).

I have a added a few SymPy examples; there are many more that could be
added straight away. There are also many examples that currently won't
work (of course, nsimplify could be used, but that's cheating). The
first disappointment is that SymPy doesn't seem to be able to simplify
Machin's formula 16*acot(5)-4*acot(239). Another simple case that
should be more robust is pi_005: 2*I*simplify(log((1-I)/(1+I)))
produces pi, but simplify(2*I*log((1-I)/(1+I))) doesn't.

Fredrik

Gaurav Dhingra

unread,
Mar 11, 2016, 8:57:17 AM3/11/16
to sy...@googlegroups.com
How are you numbering the `tests`, (i don't understand). Is there some
maths sequence that you are following.
pi_001, pi_002, pi_005, pi_008, pi_010, pi_027

Gaurav

Fredrik Johansson

unread,
Mar 11, 2016, 10:32:39 AM3/11/16
to sympy
On Friday, March 11, 2016 at 2:57:17 PM UTC+1, Gaurav Dhingra wrote:
How are you numbering the `tests`, (i don't understand). Is there some
maths sequence that you are following.
pi_001, pi_002, pi_005, pi_008, pi_010, pi_027

It's arbitrary. They are just numbered in the order the examples were added.

Fredrik

Sumith 1896

unread,
Mar 11, 2016, 10:36:57 AM3/11/16
to sympy

Even I was trying to deduce some math series :')


--
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 https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0607ad3c-8e13-436d-9089-7763d6a2841a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Meurer

unread,
Mar 11, 2016, 3:15:34 PM3/11/16
to sy...@googlegroups.com
SymPy gives I*pi for sqrt(-12*polylog(2,-1)). According to
http://docs.sympy.org/latest/modules/functions/special.html#sympy.functions.special.zeta_functions.polylog,
polylog(s, -1) is the same as dirichlet_eta(s). The definitions for
polylog in the sympy and mpmath docs look the same, so is SymPy wrong
here, or am I missing something (WolframAlpha seems to agree with
mpmath)?

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/CAFeyqwOMVnzX1Xtnv3jNLRVdxX%3Dx4ALJ1%3D3tdTzYpq_LXnMrQQ%40mail.gmail.com.

Fredrik Johansson

unread,
Mar 11, 2016, 3:36:21 PM3/11/16
to sympy
On Friday, March 11, 2016 at 9:15:34 PM UTC+1, Aaron Meurer wrote:
SymPy gives I*pi for sqrt(-12*polylog(2,-1)). According to
http://docs.sympy.org/latest/modules/functions/special.html#sympy.functions.special.zeta_functions.polylog,
polylog(s, -1) is the same as dirichlet_eta(s). The definitions for
polylog in the sympy and mpmath docs look the same, so is SymPy wrong
here, or am I missing something (WolframAlpha seems to agree with
mpmath)?

It should be polylog(s,-1) = -dirichlet_eta(s).

Fredrik

Aaron Meurer

unread,
Mar 11, 2016, 4:07:16 PM3/11/16
to sy...@googlegroups.com
Fixed at https://github.com/sympy/sympy/pull/10799.

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 https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/669f9afa-fbed-4002-aa77-f7f1cdbdec85%40googlegroups.com.

Aaron Meurer

unread,
Mar 11, 2016, 4:54:37 PM3/11/16
to sy...@googlegroups.com
I translated all the mpmath ones to SymPy
https://github.com/fredrik-johansson/314/pull/4. There are quite a few
that don't work, so there's lots of room for improvement in SymPy's
algorithms. I also found a few bugs (I opened issues in SymPy for the
bugs, but I didn't open any issues for the things that just don't
work, or functions that aren't implemented yet; if someone wants to do
that feel free).

Someone ought to go in and add a bunch of ways of representing pi
using SymPy's geometry module. Maybe the stats module as well, if
there are any useful statistical representations of pi. Perhaps
physics as well.

I think there are also a lot of opportunities for the solvers, since
the only ones that are there are sin(x) = 0 and cos(x/2) = 0.

Aaron Meurer
Reply all
Reply to author
Forward
0 new messages