The code below is run in Python 3.6 (Anaconda install), sympy 1.1.1:
#!/usr/bin/env python
import sympy as spy
import sympy.abc as abc
from sympy import pprint

n = abc.n
N = abc.N

EY = 2*N*(1-(1-1/(2*N))**n)
pprint(n-EY)
print('-'*80, '\n')
pprint((n-EY).series(N, x0=spy.oo).simplify())
print('-'*80, '\n')
pprint((n-EY).series(N, x0=spy.oo))
print('-'*80, '\n')
pprint((n-EY).series(N, x0=spy.oo).removeO().simplify())

When the code is run, I see the following output:

      ⎛           n    ⎞    
      ⎜  ⎛     1 ⎞     ⎟    
- 2⋅N⋅⎜- ⎜1 - ───⎟  + 1⎟ + n
      ⎝  ⎝    2⋅N⎠     ⎠    
--------------------------------------------------------------------------------
 

 ⎛1        ⎞
O⎜──; N → ∞⎟
 ⎜ 6       ⎟
 ⎝N        ⎠
--------------------------------------------------------------------------------
 

   6      5        4      3        2             5      4      3      2    
   
  n      n     17⋅n    5⋅n    137⋅n     n       n      n    7⋅n    5⋅n    
n   
───── - ──── + ───── - ──── + ────── - ───   - ──── + ─── - ──── + ──── - 
──  
23040   1536    4608   512    11520    192     1920   192   384    192    
80  
────────────────────────────────────────── + 
─────────────────────────────── +
                     5                                       4              
  
                    N                                       N              
   

   4    3       2           3    2         2                   
  n    n    11⋅n    n      n    n    n    n    n               
 ─── - ── + ───── - ──   - ── + ── - ──   ── - ─               
 192   32    192    32     24   8    12   4    4    ⎛1        ⎞
 ───────────────────── + ────────────── + ────── + O⎜──; N → ∞⎟
            3                   2           N       ⎜ 6       ⎟
           N                   N                    ⎝N        ⎠
--------------------------------------------------------------------------------
 

  ⎛      4                3 ⎛   2          ⎞        2 ⎛ 3      2          
 ⎞  
n⋅⎝5760⋅N ⋅(n - 1) + 960⋅N ⋅⎝- n  + 3⋅n - 2⎠ + 120⋅N ⋅⎝n  - 6⋅n  + 11⋅n - 
6⎠ +
──────────────────────────────────────────────────────────────────────────────
                                                                            
  
                                                                            
  

      ⎛   4       3       2            ⎞    5       4       3        2      
  
 12⋅N⋅⎝- n  + 10⋅n  - 35⋅n  + 50⋅n - 24⎠ + n  - 15⋅n  + 85⋅n  - 225⋅n  + 
274⋅n
──────────────────────────────────────────────────────────────────────────────
       5                                                                    
  
23040⋅N                                                                    
   

      ⎞
 - 120⎠
───────


simplify() seems to be removing all terms in the asymptotic expansion 
(second printed item). The third printed item is correct and does not use 
simplify(). The fourth print item, which uses simplify() after removing the 
O(), is also correct.

Question: If I want to factor()/simplify() each term in the asymptotic 
expansion, what is the best way to do that?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@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/dd7606f8-9c5b-45e1-8ae4-401a453670cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to