Contents Changes to MuPAD 1.2.2 Advanced Calculus Polynomials Linear Algebra Graphics Gröbner Bases Further Nice Examples
decompose
factor
gcd
IntMod
lcm
Poly
poly
Functions working with polynomial expressions internally use this
data type. Polynomials of this type are created by using the function
poly
:
>> poly( x^2 + 2*x + 1 );
2 poly(2 x + x + 1, [x])This is a univariate polynomial with indeterminate and integer coefficients.
Multivariate polynomials and polynomials over other rings are constructed similarly. A polynomial in x and y:
>> poly( x^2*y^2 + x*y + 1 );
2 2 poly(x y + x y + 1, [x, y])
The expression defining the polynomial is automatically expanded:
>> poly( x * (2*x + y + 2)^2 + 2 );
2 3 2 2 poly(4 x + 4 x y + 8 x + 4 x + x y + 4 x y + 2, [x, y])
The indeterminates may be given explicitly, changing their default order:
>> poly( x^2*y^2 + x*y + 1, [y,x] );
2 2 poly(x y + x y + 1, [y, x])
A polynomial in and with coefficients from the residue class Z mod 7:
>> poly( x^2*y^2 + 6*x*y - 2*x - 5, IntMod(7) );
2 2 poly(- 2 x - x y + x y + 2, [x, y], IntMod(7))User-defined domains may also be used as coefficient rings.
The arithmetical operators +
, -
,
*
and ^
are defined for polynomials as usual:
>> a:= poly(2*x^2 - 4*x*y - 2*x + 4*y, [x,y], IntMod(17)); b:= poly(x^2*y - 2*x*y^2, [x,y], IntMod(17));
2 poly(- 2 x + 4 y - 4 x y + 2 x , [x, y], IntMod(17)) 2 2 poly(- 2 x y + x y, [x, y], IntMod(17))
>> a + b; a * b; a^3;
2 2 2 poly(- 2 x + 4 y - 4 x y + 2 x - 2 x y + x y, [x, y], IntMod(17)) 3 3 4 2 2 2 3 3 2 poly(- 8 x y - 2 x y + 2 x y + 8 x y + 8 x y - 8 x y , [x, y], IntMod(17)) 3 4 3 5 6 2 2 poly(- 8 x + 7 x - 4 y - 7 x + 8 x + 6 x y - 3 x y - 3 3 4 5 2 2 2 3 5 x y - 8 x y + 8 x y + 3 x y - x y + 5 x y 3 2 3 3 4 2 + x y + 4 x y - 6 x y , [x, y], IntMod(17))
The greatest common divisor of two polynomial expressions over Z mod 17:
>> gcd( a,b );
poly(x - 2 y, [x, y], IntMod(17))
The least common multiple of two polynomials:
>> lcm( a,b );
2 2 3 2 2 poly(4 x y - 2 x y + 2 x y - 4 x y , [x, y], IntMod(17))
The user can also obtain a recursive representation of polynomials.
Domains of polynomials created by
Poly
are used as coefficient domains:
>> a:= poly( 5*x^2*y^2 + 2*y + 3, [x], Poly([y]) );
2 2 poly(2 y + 5 x y + 3, [x], Poly([y], Expr))
The coefficients are polynomials in y:
>> coeff( a );
2 poly(5 y , [y]), poly(2 y + 3, [y])
At last we show an example for decomposing a polynomial. That is for a given polynomial p a sequence of polynomial q1, q2, ..., qn, such that p(x) = q1( q2( ...(qn(x))...)):
>> decompose( x^6+6*x^4+x^3+9*x^2+3*x-5 );
2 3 x + x - 5, 3 x + x
>> decompose( poly(x^4-3*x^3-x+5,[x],IntMod(5)) );
2 2 poly(- x + x , [x], IntMod(5)), poly(x + x , [x], IntMod(5))
>> factor( 6*x^2 + 18*x - 24 );
[6, x + 4, 1, x - 1, 1]
>> factor( 4*x^3 + 4*x^2*y + 3*x*y + 3*y^2 );
2 [1, x + y, 1, 3 y + 4 x , 1]
Factorization over the integers:
>> factor( x^3+1 );
2 [1, x + 1, 1, - x + x + 1, 1]
>> P:= x^8 + 8*x^7 + 28*x^6 + 56*x^5 + 70*x^4 + 56*x^3 + 28*x^2 + 8*x^2 +8*x +1;
2 3 4 5 6 7 8 8 x + 36 x + 56 x + 70 x + 56 x + 28 x + 8 x + x + 1
>> factor( P );
2 3 4 5 6 7 [1, 8 x + 36 x + 56 x + 70 x + 56 x + 28 x + 8 x 8 + x + 1, 1]Hence the polynomial p is irreducible over the rationals.