I want to detect polynomials of the form x^n + m
in a python script.
Found this helpful piece of code that works perfectly in sage's jupyter notebook:
x = var('x')
w0 = SR.wild(0)
w1 = SR.wild(1)
(x**2-2).find(x**w0+w1)
However, when I throw this into a .py
file and run it I get the error *** TypeError: unsupported operand parent(s) for ^: 'Symbolic Ring' and 'Symbolic Ring'
Minimal Failing Example:
from sage.all import *
import sage
from sage.calculus.var import var
from sage.symbolic.ring import SymbolicRing
SR = SymbolicRing()
polynomial = SR('x^2-2')
x = var('x')
w0 = SR.wild(0)
w1 = SR.wild(1)
polynomial.find(x**w0+w1)
What am I missing?