Comment #27 on issue 51 by mattpap: RootOf for polynomial equations
http://code.google.com/p/sympy/issues/detail?id=51

Regarding #25, I slightly improved RooOf's API, so now we have:

1. Just a single root:

In [1]: RootOf(x**3 + x + 1, 0)
Out[1]:
      ⎛ 3           ⎞
RootOf⎝x  + x + 1, 0⎠

2. Collection of roots:

In [2]: RootOf(x**3 + x + 1, (0,1,2))
Out[2]:
⎡      ⎛ 3           ⎞        ⎛ 3           ⎞        ⎛ 3           ⎞⎤
⎣RootOf⎝x  + x + 1, 0⎠, RootOf⎝x  + x + 1, 1⎠, RootOf⎝x  + x + 1, 2⎠⎦

3. Only real roots:

In [3]: RootOf(x**3 + x + 1)
Out[3]:
⎡      ⎛ 3           ⎞⎤
⎣RootOf⎝x  + x + 1, 0⎠⎦

4. All roots:

In [4]: RootOf(x**3 + x + 1, True)
Out[4]:
⎡      ⎛ 3           ⎞        ⎛ 3           ⎞        ⎛ 3           ⎞⎤
⎣RootOf⎝x  + x + 1, 0⎠, RootOf⎝x  + x + 1, 1⎠, RootOf⎝x  + x + 1, 2⎠⎦

5. A generator can be specified as the second argument to RootOf. If specified, then indices are moved to the third argument and work exactly the same as above:

In [5]: RootOf(y*x**3 + y*x + y, x, 0)
Out[5]:
      ⎛ 3           ⎞
RootOf⎝x  + x + 1, 0⎠

Note that a polynomial must be univariate a prior:

In [6]: RootOf(y*x**3 + y*x + y, 0)
---------------------------------------------------------------------------
PolynomialError                           Traceback (most recent call last)

/home/matt/repo/git/sympy/<ipython console> in <module>()

/home/matt/repo/git/sympy/sympy/polys/rootoftools.pyc in __new__(cls, f, x, indices, radicals, expand)
    390
    391         if not poly.is_univariate:
--> 392 raise PolynomialError("only univariate polynomials are supported")
    393
    394         degree = poly.degree()

PolynomialError: only univariate polynomials are supported

(this limitation will be removed in future).

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to