Ask Your Question

Revision history [back]

It seems you want to create a function to create polynomials of degree two, in two variables $x$, $y$, of the form $a x^2 + b y - 1$.

The function would take $a$ and $b$ as arguments and return the polynomial above.

You could define the polynomial ring in $x$ and $y$ over $\mathbb{Q}$ as

R = PolynomialRing(QQ, ['x', 'y'])
x, y = R.gens()

and then define a function that takes $a$ and $b$ and outputs $a x^2 + b y - 1$:

def degree_two_polynomial(a, b):
    return a*x^2 + b*y - 1

which you could use as follows:

sage: degree_two_polynomial(2, 3)
2*x^2 + 3*y - 1
sage: degree_two_polynomial(5, 1)
5*x^2 + y - 1