Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

polynomial evaluation

asked 12 years ago

db gravatar image

If I have a polynomial p in variables x0,...,xn, how do I specialize the algebra appropriately to substitute values for xi's? For example, how do I compute p(1,1,...,1)? Or replace xi by qi (q a parameter) so to compute p(1,q,...,qn)? In Mathematica, if the variables were x[[i]], one could do "./x[[i]] -> q^i //Simplify" and it is the equivalent of this replace and simplify that I am looking for.

This is coming from symmetric polynomials/functions theory and I know some of the specializations are built in, but at the end of the day I want to try small examples with different specializations than what is already built in.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 12 years ago

Francis Clarke gravatar image

For polynomial substitution there are several possibilities:

sage: R.<x,y,z> = QQ[]
sage: f = x^2*y + y^2*z + z^2*x
sage: f(1, 2, 3)
23
sage: f(x=1, y=2, z=3)
23
sage: f.subs(x=1, y=2, z=3)
23
sage: f(x=1)
y^2*z + z^2 + y

To handle symmetric polynomials it may be best to work in a polynomial ring. For example:

sage: E = SymmetricFunctionAlgebra(QQ, basis='elementary')
sage: g = E([2,1])
sage: h = g.expand(3); h
x0^2*x1 + x0*x1^2 + x0^2*x2 + 3*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2
sage: R = h.parent()
sage: x0, x1, x2 = R.gens()

We can then check symmetry

sage: h == h(x0=x1, x1=x0) and h == h(x0=x1, x1=x2, x2=x0)
True

and do other sorts of substitution

sage: S.<q> = R[]
sage: h(1, q, q^2)
q^5 + 2*q^4 + 3*q^3 + 2*q^2 + q
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 8,781 times

Last updated: Feb 06 '13