Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

defining multivariate polynomial ring in script

I'm trying to setup a multivariate polynomial ring within a generic python script so I can access the coefficients of an ellipse easily. One wrinkle in the problem is that I'm declaring variables that have an arbitrary display value. For instance,

theta1, theta2 = var('v1073, v1074')
f = 10.6*theta1**2 + 4.63*theta1*theta2 + 5.332*theta2**2 + 4.56*theta1 + 3.25456*theta2 - 43.54352

The reason I'm declaring a different value between the variable and the display value is because I'm using this same equation in a loop where I update the variable values to represent a current pair. This equation is being used to generate elliptical variable constraints in an optimization.

To the heart of the question. I can get the proper output for the coefficients if I declare a PolynomialRing lexographically. But this format is not compatible with a python script. How do you define the same PolynomialRing in another way? For example:

A.<theta1, theta2> = QQ[]; A
Multivariate Polynomial Ring in theta1, theta2 over Rational Field
f.coefficients()
[10.6, 4.63, 5.332, 4.56, 3.25456, -43.54352]

but

A = QQ['theta1', 'theta2']; A
Multivariate Polynomial Ring in theta1, theta2 over Rational Field
f.coefficients()
[[5.332*v1074^2 + 3.25456*v1074 - 43.54352, 0],
[4.63*v1074 + 4.56, 1],
[10.6, 2]]

I've tried a few other methods, but it doesn't seem to work. Even though when I look at the definition of A, I get the same answer as to what it represents. How can I define the ring, such that I get the correct answer?