Revision history [back]

The problem is that the x in polynomial is not the x = var('x'):

>>> x is polynomial.variables()[0]
False


It is better to be explicit:

>>> x = SR.var('x')
>>> polynomial = x**2 - 2
>>> polynomial.find(x**w0+w1)
[x^2 - 2]
>>> polynomial.match(x**w0+w1)
{$1: -2,$0: 2}


The problem is that the x in polynomial is not the x = var('x'):

>>> x is polynomial.variables()[0]
False


It is better to be explicit:

>>> x = SR.var('x')
>>> polynomial = x**2 - 2
>>> polynomial.find(x**w0+w1)
[x^2 - 2]
>>> polynomial.match(x**w0+w1)
{$1: -2,$0: 2}


Or, if you would like to use the preparser:

>>> x = SR.var('x')
>>> polynomial = sage_eval('x^2 - 2', locals={'x' : x})