Contents Changes to MuPAD 1.2.2 Advanced Calculus Polynomials Linear Algebra Graphics Gröbner Bases Further Nice Examples
assume
asymp
combine
contfrac
diff
expand
Factor
limit
linsolve
normal
ode
poly
rectform
RootOf
series
setuserinfo
simplify
solve
sum
The function simplify
enables the user to simplify arbitrary algebraic expressions,
for example to determine zero equivalence:
>> simplify( sqrt(127) - ((127)^6)^(1/12) );
0or to simplify expressions like:
>> simplify( sqrt( 14+3*sqrt(3+2*sqrt(5-12*sqrt(3-2*sqrt(2)))) ) , sqrt );
1/2 2 + 3
This function provides also special simplifications on expressions with respect to the exponential function, for example:
>> simplify( (exp(x)+1)/(exp(2*x)-1), exp );
1 ---------- exp(x) - 1
To expand algebraic expressions, use the function
expand
:
>> expand( cos(5*x)/(sin(2*x)*cos(x)^2) );
2 3 cos(x) 5 sin(x) - 5 sin(x) + -------- + --------- 2 sin(x) 2 2 cos(x)Here the functions sin(n x) and cos(m x) (m, n integers) were expanded into sums.
To determine a normal form of rational expressions the function
normal
may be used:
>> normal( (sin(x)^2-exp(x)^2)/(sin(x)^2 + 2*sin(x)*exp(x) + exp(x)^2) );
sin(x) - exp(x) --------------- sin(x) + exp(x)
Use the function combine
to write the expression in terms of sin and cos:
>> e:= (sin(2*x) - 5*sin(x)*cos(x))/(sin(x)*(1+tan(x)^2));
- 5 cos(x) sin(x) + sin(2 x) ---------------------------- 2 sin(x) (tan(x) + 1)
>> combine( normal(expand(e)), sincos );
9 cos(x) 3 cos(3 x) - -------- - ---------- 4 4
>> 2*infinity + PI;
infinity
>> bool( 2 > -infinity );
TRUEand
>> infinity / infinity;
undefined
>> infinity - infinity;
undefined
But some kind of simplifications are not automatically performed, for example:
>> (-1)^(1/3);
1/3 (-1)
In this case the function rectform
may be used to get the principal value
of the (complex) solutions:
>> rectform( % );
/ 1/2 \ | 3 | 1/2 + | ---- | I \ 2 /
Simplifications which in general are not valid over the field of complex numbers are avoided in MuPAD 1.2.9. Examples are given by:
>> sqrt( x^2 );
2 1/2 (x )
>> ln( exp(x) );
ln(exp(x))For simplifications involving unknowns which may have certain properties (real valued, positive, ...) the function
assume
in use together with simplify
could be helpful.
For the last example we yield the simplification to x
if we assume
that x
represents a real valued quantifier:
>> assume( x,Type::RealNum ): simplify( ln( exp(x) ) );
x
The following statement factorizes a multivariate polynomial over the rationals:
>> factor( 7*x^3 + 7*x^2*y + 3*x*y + 3*y^2 );
2 [1, x + y, 1, 3 y + 7 x , 1]The result means that the polynomial factors in 1 * (x+y)^1 * (3y+7x^2)^1.
The function Factor
returns the factorization of a polynomial in a more natural form:
>> Factor( x^100-1 );
2 2 3 4 2 3 (x - 1) (x + 1) (x + 1) (x + x + x + x + 1) (- x + x - x + 4 2 4 6 8 5 10 15 20 x + 1) (- x + x - x + x + 1) (x + x + x + x + 1) 5 10 15 20 10 20 30 40 (- x + x - x + x + 1) (- x + x - x + x + 1)
The following statement will factorize a polynomial over the finite field Z mod 5:
>> factor( poly( x^4 - 3*x^2 + 1, [x], IntMod(5) ) );
[1, poly(x - 2, [x], IntMod(5)), 2, poly(x + 2, [x], IntMod(5)), 2]We see that factors in over 5.
poly
enables
the user to specify indeterminates and a coefficient domain
of a polynomial. It creates an own data type for polynomial,
which guarantees an efficient arithmetic on polynomials.
Please have a look in chapter poly for further explanations and demonstrations of polynomials and their factorization.
An important use of computer algebra systems is based on their facility to differentiate and integrate functions symbolically.
The integrator of MuPAD has received further improvements since MuPAD 1.2.2:
>> int(exp(x^2/2),x);
1/2 1/2 (- 1/2 I) (2 PI) erf(1/2 I x 2 )
>> simplify( diff( %,x ) );
/ 2 \ | x | exp| -- | \ 2 /
The following is computed by the Trager-Rothstein algorithm which expresses the antiderivative as a sum of logarithms taken over the root of a polynomial:
>> int( 1/(x^5-x-1), x );
/ / 2 3 4 | | 309 X15 21716 X15 45904 X15 183616 X15 sum| X15 ln| x - ------- - ---------- - ---------- - ----------- \ \ 625 625 625 625 \ | 2 3 - 256/625 |, X15 = RootOf(15 X16 - 80 X16 + 160 X16 + 2869 / \ 5 | X16 - 1) | /The index
X15
of the summation runs over the roots,
of which only one is real.diff
is able to handle
summation:
>> diff( %, x );
1 ------------ 5 - x + x - 1
The definite integrator was also improved, which may be demonstrated by the following examples:
>> int( sin(p*x/l)^2, x=l/2..l );
l l sin(p) l sin(2 p) - + -------- - ---------- 4 4 p 4 p
>> int( sin(x)/x, x=0..infinity );
PI -- 2
As we already could see by examples of the last section, MuPAD is able to compute the sum of special classes of functions.
Here is an example for the function
sum
:
>> sum( 1/k^2 + 1/k^3, k=1..infinity );
2 PI zeta(3) + --- 6
For the following example, Gosper's algorithm will be used to compute the sum of a hypergeometric function, as we will see:
>> setuserinfo( Sum,2 ): sum( binomial(n+k,k), k ); setuserinfo( Sum ):
entering indefinite summation enter Gosper f(k)/f(k-1) = 1/k*(k + n) input is hypergeometric case 2a of Gosper's algorithm d=, 0 number of equations is, 1 solution is, {F[0] = 1/(n + 1)} k binomial(k + n, k) -------------------- n + 1What also can be seen by this example is that now,
setuserinfo
also handles a domain
as its first argument. In that case the call of setuserinfo
only concerns all the methods defined for this domain.
Another example of the function sum
may be given by
>> sum( 1/(n^2+21*n),n=1..infinity );
18858053/108636528where Abramov's algorithm was used to determine the result.
With MuPAD it is also possible to compute numerically sums like
>> float(sum(ln(n)/n^(1.5-14.1*I),n=1..infinity))
- 0.3541793679 + 0.01416426969 I
Important parts of higher analysis consist of series expansions and limit computations. In MuPAD you can do Taylor, Laurent, Puiseux or more general series expansion.
However, a special feature of MuPAD is the possibility to manipulate such series with standard arithmetic operations:
>> s:= series( sin(x),x=0 );
3 5 x x 6 x - -- + --- + O(x ) 6 120
>> t:= series( cos(x),x=0 );
2 4 x x 6 1 - -- + -- + O(x ) 2 24
>> s^2 + t^2;
6 1 + O(x )
>> s/t = series( tan(x),x=0 );
3 5 3 5 x 2 x 6 x 2 x 6 x + -- + ---- + O(x ) = x + -- + ---- + O(x ) 3 15 3 15
An expression for which a Puiseux series does not exist is given by
>> series( sin(1/x+exp(-x))-sin(1/x), x=infinity);
/ exp(-x) \ exp(-x) exp(-x) | ------- | exp(-x) - ------- + ------- + O| 6 | 2 4 \ x / 2 x 24 xIn such a case,
series
tries to compute a
generalize series expansion. Such an expression is of type
gseries
:
>> domtype( % );
gseries
A generalized expansion for an expression can be
directly computed by the use of the function
asympt
:
>> asympt( exp(sin(1/x+exp(-exp(x))))-exp(sin(1/x)),x,2);
/ exp(-exp(x)) \ exp(-exp(x)) | ------------ | exp(-exp(x)) + ------------ + O| 2 | x \ x /
This function is based on an algorithm developed by D. Gruntz in 1995
and which is implemented in the
limit
function of MuPAD:
>> limit( sin(x)/x, x=0 );
1
It is known to be the best algorithm up to date to compute limits
symbolically, and it is based on the concept of most-rapidly-varying
subexpressions.
A nice example for that is given by
>> limit( x*ln(x)*(ln(x*exp(x)-x^2))^2/ln(ln(x^2+2*exp(exp(3*x^3*ln(x))))), x=infinity );
1/3
The functions solve
or
linsolve
may be used to solve
systems of linear equations:
>> linsolve( { x+y+z = 2, 2*x-y = 3-z, x+z = -y+2}, {x,y,z} );
{ { z 2 z } } { { y = - - + 1/3, x = - --- + 5/3 } } { { 3 3 } }
As a difference to MuPAD 1.2.2,
the function solve
returns a set of
solutions instead of a list:
>> solve( {x^2+y^2=1, a*x+b*y=0}, {x,y} );
{ -- 4 2 2 1/2 -- { | b y (a + a b ) | { | x = - ---, y = --------------- |, { | a 2 2 | { -- a + b -- -- 4 2 2 1/2 -- } | b y (a + a b ) | } | x = - ---, y = - --------------- | } | a 2 2 | } -- a + b -- }You can give the highest degree to which the roots will be expressed explicitely:
>> solve( {x^2+y^2=1, a*x+b*y=0}, {x,y}, MaxDegree=1 );
{ -- b y 2 2 2 2 2 -- } { | x = - ---, y = RootOf(- a + a y + b y , y) | } { -- a -- }Then, the solution is expressed with the help of the
RootOf
notation. There are two solutions, each one corresponding to
being one of the roots of the polynomial .
The RootOf
will also be used to represent solutions
of an irreducible polynomial of degree , as the
next example shows:
>> solve( x^6 - 3*x^2 + 5*x, x );
5 {0, RootOf(- 3 x + x + 5)}
Many improvements were done for the function solve
.
Now, for example, equations that consists of logarithmic,
trigonometric or special functions can be treated:
>> solve( sqrt(ln(x)) = ln(sqrt(x)), x );
{1, exp(4)}
>> s:= solve( cos(x)/sin(x)=0,x );
{ / PI 3 PI PI \ } { | --, ----, - --, ... | { { \ 2 2 2 / }
The result is a set that consists in that case of a discrete set of solutions:
>> domtype( op(s,1) );
Dom::DiscreteSet
It may also be possible to solve inequations, as in the following example shown:
>> solve( abs(x-1) < 2,x );
{[-1 < x, x < 3]}
ode
to declare an equation to be an ordinary differential equation.
At first, before solving it, we have to define an ordinary
differential equation by the use of this function.
Let us consider the following equation:
>> eq1:= ode( y'(x) + y(x) = sin(x), y(x) );
ode(y(x) + diff(y(x), x) = sin(x), y(x))After this, we can solve the equation by the use of the already known function
solve
:
>> solve(%);
{ cos(x) sin(x) } { - ------ + ------ + C1 exp(-x) } { 2 2 }MuPAD recognized an inhomogenous linear differential equation of first order. The solution of the corresponding homogenous system is expressed using a new identifier for a complex constant.
The differential equation of order 4 has the general solution:
>> solve( ode( y''''(x) - 5*y''(x) + 4*y(x) = 2*cos(x), y(x) ) );
{ cos(x) } { ------ + C2 exp(x) + C3 exp(-x) + C4 exp(2 x) + C5 exp(- 2 x) } { 5 }
It is also possible to solve systems of differential equations:
>> solve( ode( {f'(x) - f(x) + g'(x) + 2*g(x) = 1+exp(x), g'(x) + 2*g(x) + h'(x) + h(x) = 2+exp(x), f'(x) - f(x) + h'(x) + h(x) = 3+exp(x)}, {f(x), h(x), g(x)}) );
{ { exp(x) x exp(x) { { g(x) = ------ + C8 exp(- 2 x), f(x) = -------- + C6 exp(x) { { 6 2 exp(x) } } - 1, h(x) = ------ + C7 exp(-x) + 2 } } 4 } }
There are several functions for computing with complex functions, for example to compute the real and imaginary part of an expression:
>> Re( sin(2+3*I)+exp(2-I) + (2+3*I)^(1/3) );
1/6 / atan(3/2) \ cos(1) exp(2) + sin(2) cosh(3) + 13 cos| --------- | \ 3 /
The function rectform
could be used to
compute for an expression the form where
unknowns of are considered as complex:
>> Im( rectform( cos(z) + I*sin(z) ) );
sin(Re(z)) cosh(Im(z)) - sin(Re(z)) sinh(Im(z))
Furthermore, rectform
enables also to specify
real unknowns:
>> Re( rectform( cos(z)+I*sin(z), {z} ) );
cos(z)
The function contfrac
computes continued fractions:
>> cPI:= contfrac( PI,5 );
1 ------------------------ + 3 1 -------------------- + 7 1 --------------- + 15 1 ----------- + 1 1 ----- + 292 "..."or the first terms of the continued fraction of sqrt(2):
>> cSqrt2:= contfrac( sqrt(2),2 );
1 ----------------- + 1 1 ------------- + 2 1 --------- + 2 1 ----- + 2 "..."Moreover it is nice to see that you can calculate with continued fractions in the usual way. That means, to compute the continued fraction of Pi/Sqrt(2), just divide their already computed fractions:
>> cPI / cSqrt2;
1 --------- + 2 1 ----- + 4 "..."