Ask Your Question

Revision history [back]

Hello,

Here is a possibility

sage: R.<a,b> = PolynomialRing(QQ,['a','b'])
sage: R
Multivariate Polynomial Ring in a, b over Rational Field
sage: P = a^3*b^5+3*a^2+2*b^4
sage: P
sage: P(5,6)   # standard way
974667
sage: P(a=5,b=6)  # another one
974667
sage: v = (5,6)
sage: P(*v)   # the * operator unfold a tuple as 5,6
974667
sage: d = {'a': 5, 'b': 6}
sage: P(**v)  # the ** operator unfold a dictionary as a=5,b=6
974667

But if v is a vector and not a tuple the trick won't work.

Hello,

Here is a possibility

sage: R.<a,b> = PolynomialRing(QQ,['a','b'])
sage: R
Multivariate Polynomial Ring in a, b over Rational Field
sage: P = a^3*b^5+3*a^2+2*b^4
sage: P
sage: P(5,6)   # standard way
974667
sage: P(a=5,b=6)  # another one
974667
sage: v = (5,6)
sage: P(*v)   # the * operator unfold a tuple as 5,6
974667
sage: d = {'a': 5, 'b': 6}
sage: P(**v)  # the ** operator unfold a dictionary as a=5,b=6
974667

But if v is a vector and not a tuple the trick won't work.

Hoping this would be useful, Vincent