simplify(summation(j/((j+2)*(j+4)*(j+8)), (j, 1, oo))) returns 521/25200 instead of 4/35

47 views
Skip to first unread message

Sébastien Labbé

unread,
Feb 24, 2016, 10:36:20 AM2/24/16
to sympy
Dear sympy,

My teaching assistant found this bug while preparing some exercices on sympy:

In [1]: from sympy import summation, oo, simplify
In [2]: from sympy.abc import j
In [3]: s = summation(j/((j+2)*(j+4)*(j+8)), (j, 1, oo))
In [4]: s
Out[4]: 4*(-526 + 484*exp_polar(0))/(225*(-672 + 672*exp_polar(0))) + 7*(-73 + 85*exp_polar(0))/(225*(-336 + 336*exp_polar(0)))
In [5]: simplify(s)
Out[5]: 521/25200
In [6]: _.n()
Out[6]: 0.0206746031746032
In [7]: 4/35.
Out[7]: 0.11428571428571428
In [8]: import sympy
In [9]: sympy.__version__
Out[9]: '0.7.6.1'


┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 7.1.beta3, Release Date: 2016-02-11               │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: j = var('j')
sage: sum(j/((j+2)*(j+4)*(j+8)), j, 1, oo)
4/35

Cheers,

Sébastien Labbé

Ondřej Čertík

unread,
Feb 24, 2016, 10:42:14 AM2/24/16
to sympy
Hi Sébastien,

On Wed, Feb 24, 2016 at 7:28 AM, Sébastien Labbé <sla...@gmail.com> wrote:
> Dear sympy,
>
> My teaching assistant found this bug while preparing some exercices on
> sympy:
>
> In [1]: from sympy import summation, oo, simplify
> In [2]: from sympy.abc import j
> In [3]: s = summation(j/((j+2)*(j+4)*(j+8)), (j, 1, oo))
> In [4]: s
> Out[4]: 4*(-526 + 484*exp_polar(0))/(225*(-672 + 672*exp_polar(0))) + 7*(-73
> + 85*exp_polar(0))/(225*(-336 + 336*exp_polar(0)))
> In [5]: simplify(s)
> Out[5]: 521/25200
> In [6]: _.n()
> Out[6]: 0.0206746031746032
> In [7]: 4/35.
> Out[7]: 0.11428571428571428
> In [8]: import sympy
> In [9]: sympy.__version__
> Out[9]: '0.7.6.1'

Thanks a lot for reporting this. Something looks fishy there:

In [2]: var("j")
Out[2]: j

In [3]: summation(j/((j+2)*(j+4)*(j+8)), (j, 1, oo))
Out[3]:
⎛ 0⎞ ⎛ 0⎞
4⋅⎝-526 + 484⋅ℯ ⎠ 7⋅⎝-73 + 85⋅ℯ ⎠
─────────────────── + ───────────────────
⎛ 0⎞ ⎛ 0⎞
225⋅⎝-672 + 672⋅ℯ ⎠ 225⋅⎝-336 + 336⋅ℯ ⎠

In [4]: summation(j/((j+2)*(j+4)*(j+8)), (j, 1, oo)).n()
Out[4]: 0.e+133

In [5]: summation(j/((j+2)*(j+4)*(j+8)), (j, 1, oo)).simplify()
Out[5]:
521
─────
25200

Essentially, exp_polar(0) is 1. But if you do this substitution in
this expression, then you get division by zero. So the returned answer
in [3] is incorrect. [4] then fails as well due to this. Finally, [5]
seems also incorrect.

We need to look into the summation algorithm to see what is going on.

Ondrej

>
>
> ┌────────────────────────────────────────────────────────────────────┐
> │ SageMath Version 7.1.beta3, Release Date: 2016-02-11 │
> │ Type "notebook()" for the browser-based notebook interface. │
> │ Type "help()" for help. │
> └────────────────────────────────────────────────────────────────────┘
> ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
> ┃ Warning: this is a prerelease version, and it may be unstable. ┃
> ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
> sage: j = var('j')
> sage: sum(j/((j+2)*(j+4)*(j+8)), j, 1, oo)
> 4/35
>
> Cheers,
>
> Sébastien Labbé
>
> --
> 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/86d25a77-e426-41d8-9c9f-6b2f58cb242c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages