# roots should find the roots of x**4*I + x**2 + I #7724

Open
opened this Issue Jul 9, 2014 · 9 comments

Projects
None yet
5 participants
Member

### hargup commented Jul 9, 2014

 ``````In [34]: roots(x**4*I + x**2 + I, x) Out[34]: {} `````` surprisingly if we replace `I` with variable coefficients we get an answer. ``````In [35]: roots(x**4*a + x**2 + b, x) Out[35]: {sqrt(2)*sqrt(-sqrt(-4*a*b + 1)/a - 1/a)/2: 1, sqrt(2)*sqrt(sqrt(-4*a*b + 1)/a - 1/a)/2: 1, -sqrt(2)*sqrt(sqrt(-4*a*b + 1)/a - 1/a)/2: 1, -sqrt(2)*sqrt(-sqrt(-4*a*b + 1)/a - 1/a)/2: 1} ``````

Contributor

### skirpichev commented Jul 9, 2014

 This works: ``````In [3]: Poly(I*x**4 - x**2 + I, x, domain='ZZ[I]') Out[3]: Poly(I*x**4 - x**2 + I, x, domain='ZZ[I]') In [4]: len(roots(_,x)) Out[4]: 4 ``````
Member

### hargup commented Jul 12, 2014

 I suppose `ZZ` is for the integer domain, because this fails: ``````In [43]: roots(x**2 + I*sqrt(2), x, domain='ZZ[I]') --------------------------------------------------------------------------- . . # Removed the call stack to make the comment short . CoercionFailed: can't convert sqrt(2)*I of type to ZZ[I] `````` `RR` fails complaining `sqrt(2)*I` isn't a Real number ``````In [44]: roots(x**2 + I*sqrt(2), x, domain='RR') --------------------------------------------------------------------------- . . . CoercionFailed: expected real number, got sqrt(2)*I `````` `RR[I]` fails with error "expecting a valid domain specification" ``````In [45]: roots(x**2 + I*sqrt(2), x, domain='RR[I]') --------------------------------------------------------------------------- . . . OptionError: expected a valid domain specification, got RR[I] `````` And `CC` returns the answer in float. ``````In [46]: roots(x**2 + I*sqrt(2), x, domain='CC') Out[46]: {-1.18920711500272*sqrt(-I): 1, 1.18920711500272*sqrt(-I): 1} `````` The docstring for the `roots` function doesn't contain any example for domains and filters. Maybe @mattpap can help.
Member

### asmeurer commented Jul 12, 2014

 I think you'll need domain=EX
Contributor

### skirpichev commented Jul 12, 2014

 I suppose ZZ is for the integer domain Yes. The docstring for the roots function doesn't contain any example The docstring is clear enough for me. The domain option is a filter to get roots from the specific domain. In the example above I have used domain option for the Poly constructor.
Member

### hargup commented Jul 12, 2014

 @asmeurer what does `EX` stands for?
Contributor

### pelegm commented Jan 7, 2015

 I think it stands for arbitrary EXpressions.
Member

### asmeurer commented Jan 7, 2015

 The domain parameter only specifies the domain of the coefficients of the polynomial, not the roots. Roots of a polynomial in the domain ZZ might be non-integers.

Closed

Member

Member

### smichr commented Mar 27, 2017

 example for domains and filters The filters use the assumption system to filter the results, basically `return [i for i in full_solution if i.is_foo]`. So this is limited by the assumption system's ability to deduce these properties. For complicated expressions it might have problems and get a None.

### skirpichev added a commit to skirpichev/diofant that referenced this issue Jan 9, 2018

``` Support extension option for some methods ```
```Probably in future this could be reverted by making
extension=True - default for construct_domain(),
see e.g. diofant#478.

Related issues:
* sympy/sympy#5428
* sympy/sympy#7724
* sympy/sympy#12345```
``` b6a556d ```

### skirpichev added a commit to skirpichev/diofant that referenced this issue Mar 9, 2018

``` Add regression test ```
`Closes sympy/sympy#7724`
``` cc2676c ```