Next: , Previous: , Up: Algebra   [Contents][Index]


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.

e26 : degree(a*x*x + b*y*x + c*y*y + d*x + e*y + f, y);

e26: 2

e27 : degree(a*x*x + b*y*x + c*y*y + d*x + e*y + f);

e27: 3
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,

e14 : coeff((x + 2)^4, x, 3);

e14: 8

e15 : (x + 2)^4;

                     2      3    4
e15: 16 + 32 x + 24 x  + 8 x  + x

e16 : coeff((x + 2)^4, x);

e16: 32

e18 : coeffs((x + 2)^4, x);

e18: [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.

e15 : poly(y, [16, 32, 24, 8, 1]);

                     2      3    4
e15: 16 + 32 y + 24 y  + 8 y  + y

e16 : poly(y, 16, 32, 24, 8, 1);

                     2      3    4
e16: 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.

e17 : 2*a = 4*c;

e17: 0 = - a + 2 c

e18 : poly(e17);

e18: - 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.

e24 : content(2*x*y+4*x^2*y^2,y);

                     2
e24: [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.

e5 : divide(x^2+y^2,x-7*y^2,x);

            2    2       4
e5: [x + 7 y , y  + 49 y ]

e6 : divide(-7,3);

e6: [-2, -1]

e11 : divide(x^2+y^2+z^2,x+y+z);

                       2              2
e11: [- x - y + z, 2 x  + 2 x y + 2 y ]

e14 : divide(x^2+y^2+z^2,x+y+z,y);

                       2              2
e14: [- x + y - z, 2 x  + 2 x z + 2 z ]

e15 : divide(x^2+y^2+z^2,x+y+z,z);

                       2              2
e15: [- 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.

e19 : x^4+4 mod 3;

          4
e19: 1 + x

e20 : x^4+4 mod x^2=2;

e20: 8

e22 : mod(x^3*a*7+x*8+34, -3);

                3
e22: 1 - x + a x

e23 : mod(5,2);

e23: 1

e24 : mod(x^4+4,x^2=2,x);

e24: 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.

e1 : gcd(x^4-y^4,x^6+y^6);

     2    2
e1: x  + y

e2 : gcd(4,10);

e2: 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.

e7 : discriminant(x^3 - 1, x);

e7: -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.

e2 : resultant(x^2 + a, x^3 + a, x);

     2    3
e2: 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.

e7 : decompose(((x+1)^6),x);

                2           2    3
e7: [1 + 2 x + x , 3 x + 3 x  + x ]

Next: , Previous: , Up: Algebra   [Contents][Index]