Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Use expression.find with SR.wild in python scripts

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)

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)

What am I missing?