cyjax.polynomial.univariate_coefficients#
- cyjax.polynomial.univariate_coefficients(poly, var)#
Polynomials for coefficients in each order for a single variable.
Given a multivariate polynomial
poly
, we single one variable (var
) out and treat the others as constants. The coefficients of the single variate polynomial invar
are then given by polynomials in the remaining “constant” variables. This function extracts the coefficients of the univariate polynomial invar
in terms of polynomials in the remaining constant variables.Example
>>> poly = 'z1**2 * z2 * x**2 + 3 * shift * (1 + x**2)' >>> variables = ['x', 'z', 'shift'] >>> poly = Poly.from_sympy(poly, variables) >>> coeff_polies = univariate_coefficients(poly, 'x') >>> len(coeff_polies) # degree in x is 2 so we get 3 coefficients 3 >>> print(coeff_polies[0]) # At degree x^2 Poly([z_1, z_2], shift) = 3*shift + z1**2*z2 >>> print(coeff_polies[1]) # At degree x^1 0.0 >>> print(coeff_polies[2]) # At degree x^0 Poly([z_1, z_2], shift) = 3*shift