Re: [sympy] Re: Possible bug in simplify() and a question

2018-04-12 Thread Aaron Meurer
Looks like the issue comes from as_numer_denom. I opened
https://github.com/sympy/sympy/issues/14622 for this.

Aaron Meurer

On Thu, Apr 12, 2018 at 8:03 AM,   wrote:
> To factor/simplify each term, the best way appears to be to use collect and
> pass the simplification function as an argument. So I can use the following
> syntax:
>
> spy.collect((n-EY).series(N,x0 = spy.oo).removeO(),N, spy.factor)
>
> It would be really nice if sympy can support collect() as a member function
> of expression objects. Only the part about a possible bug in
> sympy.simplify() stands.
>
> --
> 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/a79426c5-ff10-454b-b79a-f5381d9fbcc7%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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/CAKgW%3D6Jt_-NNHEfM3BtfjLSk2vZFaSsmyvnaKk9-YnE0W2Koig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Re: Possible bug in simplify() and a question

2018-04-12 Thread divakar
To factor/simplify each term, the best way appears to be to use collect and 
pass the simplification function as an argument. So I can use the following 
syntax:

spy.collect((n-EY).series(N,x0 = spy.oo).removeO(),N, spy.factor)

It would be really nice if sympy can support collect() as a member function 
of expression objects. Only the part about a possible bug in 
sympy.simplify() stands. 

-- 
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/a79426c5-ff10-454b-b79a-f5381d9fbcc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Re: Possible bug in simplify() and a question

2018-04-12 Thread divakar
To factor/simplify, each term the best way appears to be to use collect and 
pass the simplification function as an argument. So I can use the following 
syntax:

spy.collect((n-EY).series(N,x0 = spy.oo).removeO(),N, spy.factor)

Only the part about a possible bug in sympy.simplify() stands.



On Wednesday, April 11, 2018 at 11:28:49 AM UTC-4, div...@umich.edu wrote:
>
> 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  54  32 5  4  3  2
>
>   n  n 17⋅n5⋅n137⋅n n   n  n7⋅n5⋅n
> n   
> ─ -  + ─ -  + ── - ───   -  + ─── -  +  - 
> ──  
> 23040   15364608   51211520192 1920   192   384192
> 80  
> ── + 
> ─── +
>  5   4
> 
> N   N  
>
>
>43   2   32 2   
>   nn11⋅nn  nnnnn   
>  ─── - ── + ─ - ──   - ── + ── - ──   ── - ─   
>  192   3219232 24   812   44⎛1⎞
>  ─ + ── + ── + O⎜──; N → ∞⎟
> 3   2   N   ⎜ 6   ⎟
>N   N⎝N⎠
>
> 
>  
>
>   ⎛  43 ⎛   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   32
> 
>  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/f7f73ea2-1506-41e8-94a1-c05e73d42fa9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.