# Series expansion of the square root gives wrong result #11407

Open
opened this Issue Jul 18, 2016 · 0 comments

Projects
None yet
1 participant

### astholkohtz commented Jul 18, 2016

 Whenever the constant term on the square root is a sum of 2 or more symbols, the series() function gets the expansion wrong ``````In [1]: from sympy import * In [2]: a,b,c,x = symbols('a b c x') In [3]: sqrt(a+b + c*x).series(x,0,1) Out[3]: 5*sqrt(a + b)/16 + 15*b/(16*sqrt(a + b)) - 5*b**2*sqrt(a + b)/(16*(a**2 + 2*a*b + b**2)) + b**3*sqrt(a + b)/(16*(a**3 + 3*a**2*b + 3*a*b**2 + b**3)) + 15*a/(16*sqrt(a + b)) - 5*a*b*sqrt(a + b)/(8*(a**2 + 2*a*b + b**2)) + 3*a*b**2*sqrt(a + b)/(16*(a**3 + 3*a**2*b + 3*a*b**2 + b**3)) - 5*a**2*sqrt(a + b)/(16*(a**2 + 2*a*b + b**2)) + 3*a**2*b*sqrt(a + b)/(16*(a**3 + 3*a**2*b + 3*a*b**2 + b**3)) + a**3*sqrt(a + b)/(16*(a**3 + 3*a**2*b + 3*a*b**2 + b**3)) + O(x) In [4]: sqrt(a+b+c + c*x).series(x,0,1) Out[4]: 5*sqrt(a + b + c)/16 + 15*c/(16*sqrt(a + b + c)) - 5*c**2*sqrt(a + b + c)/(16*(a**2 + 2*a*b + 2*a*c + b**2 + 2*b*c + c**2)) + c**3*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) + 15*b/(16*sqrt(a + b + c)) - 5*b*c*sqrt(a + b + c)/(8*(a**2 + 2*a*b + 2*a*c + b**2 + 2*b*c + c**2)) + 3*b*c**2*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) - 5*b**2*sqrt(a + b + c)/(16*(a**2 + 2*a*b + 2*a*c + b**2 + 2*b*c + c**2)) + 3*b**2*c*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) + b**3*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) + 15*a/(16*sqrt(a + b + c)) - 5*a*c*sqrt(a + b + c)/(8*(a**2 + 2*a*b + 2*a*c + b**2 + 2*b*c + c**2)) + 3*a*c**2*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) - 5*a*b*sqrt(a + b + c)/(8*(a**2 + 2*a*b + 2*a*c + b**2 + 2*b*c + c**2)) + 3*a*b*c*sqrt(a + b + c)/(8*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) + 3*a*b**2*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) - 5*a**2*sqrt(a + b + c)/(16*(a**2 + 2*a*b + 2*a*c + b**2 + 2*b*c + c**2)) + 3*a**2*c*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) + 3*a**2*b*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) + a**3*sqrt(a + b + c)/(16*(a**3 + 3*a**2*b + 3*a**2*c + 3*a*b**2 + 6*a*b*c + 3*a*c**2 + b**3 + 3*b**2*c + 3*b*c**2 + c**3)) + O(x) `````` As long as the constant term is only one, series() gives the correct result ``````In [5]: sqrt(a + c*x).series(x,0,1) Out[5]: sqrt(a) + O(x) In [6]: sqrt(a + (a+b)*x).series(x,0,1) Out[6]: sqrt(a) + O(x) In [7]: sqrt(a + (a+b+c)*x).series(x,0,1) Out[7]: sqrt(a) + O(x) In [8]: sqrt(a + (a+b+c)*x).series(x,0,2) Out[8]: x*(sqrt(a)/2 + b/(2*sqrt(a)) + c/(2*sqrt(a))) + sqrt(a) + O(x**2) ``````

### skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 19, 2016

``` Add regression test ```
`Closes sympy/sympy#11407`
``` cc1388a ```

### skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 22, 2016

``` Add regression test ```
`Closes sympy/sympy#11407`
``` dd63088 ```