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

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

Open
hargup opened this Issue Jul 9, 2014 · 9 comments

Comments

Projects
None yet
5 participants
@hargup
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}

@hargup hargup added the Solvers label Jul 9, 2014

@skirpichev

This comment has been minimized.

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
@hargup

This comment has been minimized.

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 <class 'sympy.core.mul.Mul'> 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.

@asmeurer

This comment has been minimized.

Member

asmeurer commented Jul 12, 2014

I think you'll need domain=EX

@skirpichev

This comment has been minimized.

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.

@hargup

This comment has been minimized.

Member

hargup commented Jul 12, 2014

@asmeurer what does EX stands for?

@pelegm

This comment has been minimized.

Contributor

pelegm commented Jan 7, 2015

I think it stands for arbitrary EXpressions.

@asmeurer

This comment has been minimized.

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.

@smichr

This comment has been minimized.

Member

smichr commented Mar 27, 2017

See also #12345 and #12421

@smichr

This comment has been minimized.

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment