2.4 Polynomials

Operator: degree poly var

Returns the degree of polynomial or equation poly in variable var.

Operator: degree poly

Returns the total-degree, the degree of its highest degree monomial, of polynomial or equation poly.

(%0028) degree(a*x*x + b*y*x + c*y*y + d*x + e*y + f, y);
%0028: 2
(%0029) degree(a*x*x + b*y*x + c*y*y + d*x + e*y + f);
%0029: 3

Note that all roots and radicals count as degree 1.

Operator: coeff poly var
Operator: coeff poly var deg
Operator: coeffs poly var

The command coeff is used to determine the coefficient of a certain power of a variable in a given polynomial. Here poly is a polynomial and var is a variable. If the optional third argument is omitted, then Jacal returns the coefficient of the variable var in poly. Otherwise it returns the coefficient of var^deg in poly. The function coeffs returns a list of all of the coefficients. For example,

(%0009) coeff((x + 2)^4, x, 3);
%0009: 8
(%0010) (x + 2)^4;
                       2      3    4
%0010: 16 + 32 x + 24 x  + 8 x  + x
(%0011) coeff((x + 2)^4, x);
%0011: 32
(%0012) coeffs((x + 2)^4, x);
%0012: [16, 32, 24, 8, 1]
Operator: poly var vect
Operator: poly var coeff1 …

The function poly provides an inverse to the function coeffs, allowing one to recover a polynomial from its vector or list of coefficients.

(%0013) poly(y, [16, 32, 24, 8, 1]);
                       2      3    4
%0013: 16 + 32 y + 24 y  + 8 y  + y
(%0014) poly(y, 16, 32, 24, 8, 1);
                       2      3    4
%0014: 16 + 32 y + 24 y  + 8 y  + y
Operator: poly eqn

The function poly returns the expression equal to 0 in equation eqn. Be aware that the sign and scaling of the returned polynomial will not necessarily match those in the equation creating eqn.

(%0015) 2*a = 4*c;
%0015: 0 = - a + 2 c
(%0016) poly(%0015);
%0016: - a + 2 c
Operator: content poly var

Returns a list of content and primitive part of a polynomial with respect to the variable. The content is the GCD of the coefficients of the polynomial in the variable. The primitive part is poly divided by the content.

content(2*x*y+4*x^2*y^2,y);
                      2
%0017: [2 x, y + 2 x y ]
Operator: divide dividend divisor var
Operator: divide dividend divisor

The command divide treats divident and divisor as polynomials in the variable var and returns a pair ‘[quotient, remainder]’ such that dividend = divisor * quotient + remainder. If the third argument var is omitted Jacal will choose a variable on its own with respect to which it will do the division. In particular, of dividend and divisor are both numerical, one can safely omit the third argument.

(%0018) divide(x^2+y^2,x-7*y^2,x);
               2   2       4
%0018: [x + 7 y , y  + 49 y ]
(%0019) divide(-7,3);
%0019: [-2, -1]
(%0020) divide(x^2+y^2+z^2,x+y+z);
                        2              2
%0020: [- x - y + z, 2 x  + 2 x y + 2 y ]
(%0021) divide(x^2+y^2+z^2,x+y+z,y);
                        2              2
%0021: [- x + y - z, 2 x  + 2 x z + 2 z ]
(%0022) divide(x^2+y^2+z^2,x+y+z,z);
                        2              2
%0022: [- x - y + z, 2 x  + 2 x y + 2 y ]
Command: mod poly1 eqn var
Command: mod poly1 poly2 var
Command: mod poly1 poly2

Returns poly1 reduced with respect to poly2 (or eqn) and var. If poly2 is univariate, the third argument is not needed.

Command: mod poly1 n

Returns poly1 with all the coefficients taken modulo n.

Command: mod poly1

Returns poly1 with all the coefficients taken modulo the current modulus.

If the modulus (n or the current modulus) is negative, then the results use symmetric representation.

(%0023) x^4+4 mod 3;
            4
%0023: 1 + x
(%0024) x^4+4 mod x^2=2;
%0024: 8
(%0025) mod(x^3*a*7+x*8+34, -3);
                  3
%0025: 1 - x + a x
(%0026) mod(5,2);
%0026: 1
(%0027) mod(x^4+4,x^2=2,x);
%0027: 8
Command: gcd poly_1 poly_2

The Jacal function gcd takes as arguments two polynomials with integer coefficients and returns a greatest common divisor of the two polynomials. This includes the case where the polynomials are integers.

(%0028) gcd(x^4-y^4,x^6+y^6);
        2    2
%0028: x  + y
(%0029) gcd(4,10);
%0029: 2
Command: discriminant poly var

Here poly is a polynomial and var is a variable. This function returns the square of the product of the differences of the roots of the polynomial poly with respect to the variable var.

(%0030) discriminant(x^3 - 1, x);
%0030: -27
Command: resultant poly_1 poly_2 var

The function resultant returns the resultant of the polynomials poly_1 and poly_2 with respect to the variable var.

(%0031) resultant(x^2 + a, x^3 + a, x);
        2    3
%0031: a  + a
Command: equatecoeffs z1 z2 var

Returns the list of equations formed by equating each coefficient of variable var^n in z1 to the corresponding coefficient of var^n in z2. z1 and z2 can be polynomials or ratios of polynomials.

Command: decompose poly_1 var

Returns the polynomial decomposition of poly_1 with respect to var. Note that decompose is not currently working.