Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The subs method for polynomi

The subs method for polynomipolynomials is not an analog of SR.subs !

sage: a=SR.var("a")
sage: R1.<x>=SR[]
sage: R2.<y,z>=SR[]
sage: x.subs?

prints

Docstring:     
   Identical to "self(*x)".

   See the docstring for "__call__()".

   EXAMPLES:

      sage: R.<x> = QQ[]
      sage: f = x^3 + x - 3
      sage: f.subs(x=5)
      127
      sage: f.subs(5)
      127
      sage: f.subs({x:2})
      7
      sage: f.subs({})
      x^3 + x - 3
      sage: f.subs({'x':2})
      Traceback (most recent call last):

etc... Compare with :

sage: y.subs?
Signature:      y.subs(fixed=None, **kw)
Docstring:     
   Fix some given variables in a given multivariate polynomial and
   return the changed multivariate polynomials. The polynomial itself
   is not affected. The variable, value pairs for fixing are to be
   provided as a dictionary of the form "{variable: value}".

   This is a special case of evaluating the polynomial with some of
   the variables constants and the others the original variables.

   INPUT:

   * "fixed" - (optional) dictionary of inputs

   * "**kw" - named parameters

   OUTPUT: new "MPolynomial"

   EXAMPLES:

      sage: R.<x,y> = QQbar[]                                                     # optional - sage.rings.number_field
      sage: f = x^2 + y + x^2*y^2 + 5                                             # optional - sage.rings.number_field
      sage: f((5, y))                                                             # optional - sage.rings.number_field
      25*y^2 + y + 30
      sage: f.subs({x: 5})                                                        # optional - sage.rings.number_field
      25*y^2 + y + 30

As far as I understand it, (a*x).subs(a=1) should have raised an error.

Consider yelping on sage-support...

HTH,