Hi Christophe,
On Fri, Jun 26, 2009 at 11:23:41AM +0200, Christophe wrote:
>
> Hello,
> the following code only gives [1] but I would also have the
> multilplicity of the root 1 (which is 3) :
> ===============
> x = sympy.Symbol('x')
> f = '(x-1)**3'
> sympy.solve(f, x)
> ===============
>
> Is there a way to know that ?
>
> Christophe.
>
there is a dedicated tool for obtaining polynomial roots, e.g.:
n [1]: var('x')
Out[1]: x
In [2]: f = (x - 1)**3
In [3]: roots(f, x)
Out[3]: {1: 3}
The result is a dictionary { root: multiplicity }. To get similar
behaviour to solve(), set the 'multiple' flag:
In [4]: roots(f, x, multiple=True)
Out[4]: [1, 1, 1]
Note however that solve() and roots() have different semantics. See
docstrings for details.
> f = '(x-1)**3'
btw. You don't have to enter expressions as strings.
--
Mateusz
signature.asc
Description: This is a digitally signed message part
