![]() | 1 | initial version |
The code in the question defines
R
and its polynomial variablesf
, and two symbolic variablesTo instead define f
as a polynomial from the ring R
, use:
sage: R.<x, y> = PolynomialRing(QQ)
sage: f = x + y
Then:
sage: f in R
True
Here is a little more detail.
The instruction
sage: R<x, y> = PolynomialRing(QQ)
is equivalent to
sage: R = PolynomialRing(QQ, ['x', 'y'])
sage: x, y = R.gens()
so it defines R
as a polynomial ring whose polynomial variables display as x
and y
,
and it assigns these polynomial variables to the Python variables x
and y
.
The instruction
sage: f(x, y) = x + y
is equivalent to declaring x
and y
as symbolic variables,
and then declaring f
as a symbolic function of these variables.
To check what happens at each step:
sage: preparse("R.<x, y> = PolynomialRing(QQ)")
sage: R.<x, y> = PolynomialRing(QQ)
sage: f = x + y
sage: f
sage: parent(x)
sage: parent(y)
sage: parent(f)
sage: preparse("f(x, y) = x + y")
sage: f(x, y) = x + y
sage: f
sage: parent(x)
sage: parent(y)
sage: parent(f)