Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sums that have limits involving log can fail to evaluate #20953

Open
peteroupc opened this issue Feb 12, 2021 · 1 comment
Open

Sums that have limits involving log can fail to evaluate #20953

peteroupc opened this issue Feb 12, 2021 · 1 comment
Labels

Comments

@peteroupc
Copy link

peteroupc commented Feb 12, 2021

Unlike with ordinary limits with integers or symbols, certain sums with non-trivial limits that evaluate to an integer, such as those involving base-2 logarithms, can fail to be evaluated. An example follows:

In [32]: # Limits involving logs  
    ...: mm1=(S(1)/5)-Sum((S(1)/2)*(S(1)/(8*2**k-4)),(k,0,log(n,2)-1))  
    ...: # -- Powers of 2  
    ...: pprint([mm1.subs(n,2**i).doit() for i in range(2,5)])  
    ...: # -- n() produces wrong results here; see also #20937  
    ...: pprint([mm1.subs(n,2**i).n() for i in range(2,5)])  
    ...: # Ordinary integer limits  
    ...: mm1=(S(1)/5)-Sum((S(1)/2)*(S(1)/(8*2**k-4)),(k,0,n))  
    ...: pprint([mm1.subs(n,i).doit() for i in range(4,10)])  
    ...: pprint([mm1.subs(n,i).n() for i in range(4,10)])  
    ...:                                                                                                                
⎡         log(4)                        log(8)                        log(16)             ⎤
⎢    -1 + ──────                   -1 + ──────                   -1 + ───────             ⎥
⎢         log(2)                        log(2)                         log(2)             ⎥
⎢        ____                          ____                          ____                 ⎥
⎢        ╲                             ╲                             ╲                    ⎥
⎢         ╲           1                 ╲           1                 ╲            1      ⎥
⎢1         ╲     ────────────  1         ╲     ────────────  1         ╲      ────────────⎥
⎢─ -       ╱       ⎛   k    ⎞, ─ -       ╱       ⎛   k    ⎞, ─ -       ╱        ⎛   k    ⎞⎥
⎢5        ╱      2⋅⎝8⋅2  - 4⎠  5        ╱      2⋅⎝8⋅2  - 4⎠  5        ╱       2⋅⎝8⋅2  - 4⎠⎥
⎢        ╱                             ╱                             ╱                    ⎥
⎢        ‾‾‾‾                          ‾‾‾‾                          ‾‾‾‾                 ⎥
⎣       k = 0                         k = 0                         k = 0                 ⎦
[-0.00083689405191147, -0.00083689405191147, -0.00083689405191147]
⎡ 27    11     1411    -5869    -1459235    -4840333  ⎤
⎢────, ────, ───────, ────────, ──────────, ──────────⎥
⎣8680  9765  9921240  16866108  2462451768  6771742362⎦
[0.00311059907834101, 0.00112647209421403, 0.000142220125710093, -0.00034797595272128, -0.000592594348024607, -0.00071
4783986343277]
@oscargus
Copy link
Contributor

oscargus commented Aug 22, 2021

This seems to be solved by #21911 when that is finished.

In [9]: pprint([mm1.subs(n,2**i).doit() for i in range(2,5)])
⎡       13       ⎤
⎢1/30, ───, 1/140⎥
⎣      840       ⎦

oscargus added a commit to oscargus/sympy that referenced this issue Aug 22, 2021
oscargus added a commit to oscargus/sympy that referenced this issue Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants