Wester's test suite in MuPAD 1.3


Author: Paul Zimmermann
Date  : 09. Sep. 1995
Format: dvi, postscript

Abstract

A few months ago, Michael Wester made a review [Wester94] of the mathematical capabilities of different computer algebra systems, namely Axiom, Derive, Macsyma, Maple, Mathematica and Reduce. This review, which is available by anonymous ftp from math.unm.edu:/pub/cas/Paper.ps consists of 131 tests in different domains of mathematics (arithmetic, algebraic equations, differential equations, integration, operator computation, series expansions, limits).

In this paper we describe the problems that can be solved with MuPAD 1.3, and how to solve them. - Summary

Contents


    Numbers

  1. Compute 50!.
    >> fact(50);
    
         30414093201713378043612608166064768844377641568960512000000000000
    
  2. Compute the prime decomposition of 50!.
    >> ifactor(fact(50));
    
     [1, 2, 47, 3, 22, 5, 12, 7, 8, 11, 4, 13, 3, 17, 2, 19, 2, 23, 2, 29, 1,
    
                        31, 1, 37, 1, 41, 1, 43, 1, 47, 1]
    
    The function ifactor(n) returns a list [ e, p1, a1, ... , pk, ak ], where e is 1 or -1 and n = e * p1^a1 *...* pk^ak.

  3. Compute 1/2 + ... + 1/10.
    >> _plus(1/i$i=2..10);
    
                                     4861/2520
    
    In MuPAD each arithmetic operator has a functional form, here _plus for addition, so for example _plus(a,b) is the same as a+b.

  4. Compute a numerical approximation of e^(Pi*sqrt(163)) to 50 digits.
    >> DIGITS:=50: float(exp(PI*sqrt(163)));
    
              2.6253741264076874399999999999925007259719818568887e17
    
    The floating-point numbers are output in scientific notation. This notation can be used as input too.

  5. Compute a numerical approximation of J2(1+i), where J is the Bessel function of the first kind.
    >> besselJ(2,1.0+I);
    
                         0.4157988694e-1 + 0.2473976415 I
    
    Please note that floating-point numbers are ``contagious'': no float instruction is needed here.

  6. Compute an infinite decimal representation of 1/7.
    >> loadlib("numlib"): export(numlib):
    >> decimal(1/7);
    
                               0, [1, 4, 2, 8, 5, 7]
    
    This result means that the decimal expansion of 1/7 is 0.142857142857142.... Here the instruction loadlib("numlib") loads the package. Then export(numlib) exports the functions of this package, i.e. enables one to call them with a short name (otherwise we should write numlib::decimal).

  7. Compute the first terms of the continued fraction of Pi.
    >> contfrac(PI,5);
    
                                      1               
                            ---------------------- + 3
                                    1                 
                            ------------------ + 7    
                                  1                   
                            ------------- + 15        
                                1                     
                            --------- + 1             
                             1                        
                            --- + 292                 
                            ...                       
    
    The second (optional) argument of contfrac specifies the number of digits to be taken into account before computing the continued fraction.

  8. Simplify sqrt(2*sqrt(3)+4).
    >> radsimp(sqrt(2*sqrt(3)+4));
    
                                      1/2    
                                     3    + 1
    
  9. Simplify sqrt(14+3*sqrt(3+2*sqrt(5-12*sqrt(3-2*sqrt(2))))).
    >> radsimp(sqrt(14 + 3*sqrt(3 + 2*sqrt(5 - 12*sqrt(3 - 2*sqrt(2))))));
    
                                      1/2    
                                     2    + 3
    
  10. Simplify 2*infinity-3.
    >> 2*infinity-3;
    
                                     infinity
    
    The symbol infinity is implemented as a domain in MuPAD. This allows the overloading of the basic arithmetic operations, together with the comparisons. For example we can write in a MuPAD program if a < infinity then ... end_if.

    Statistics

  11. Compute the standard deviation of the sample [1,2,3,4,5].
    >> loadlib("stats"):
    >> stats::stdev([1,2,3,4,5],Sample);
    
                                      1/2  1/2
                                     2    5   
                                     ---------
                                         2    
    
    Here we have shown the other way to call package functions, without exporting them.

    Algebra

  12. Compute the normal form of (x^2-4)/(x^2+4x+4).
    >> normal((x^2 - 4)/(x^2 + 4*x + 4));
    
                                       x - 2
                                       -----
                                       x + 2
    
  13. Simplify (e^x-1)/(e^(x/2)+1).
    >> simplify((exp(x)-1)/(exp(x/2)+1),exp);
    
                                       / x \    
                                   exp | - | - 1
                                       \ 2 /    
    
  14. Expand (x+1)^20, then differentiate and factorize.
    >> Factor(diff(expand((x + 1)^20),x));
    
                                             19
                                   20 (x + 1)  
    
    MuPAD provides two factorization functions: the toplevel function Factor returns an expression, and the library function factor returns a list [ e, p1, a1, ... , pk, ak ] where e is a scalar, the pi are irreducible polynomials and the ai are the corresponding powers. In the above example, factor would return [ 20, x + 1, 19 ].

  15. Factor x^100-1.
    >> Factor(x^100-1);
    
                    /  2     \ /      2    3    4     \ /        2    3    4  
    (x + 1) (x - 1) \ x  + 1 / \ x + x  + x  + x  + 1 / \ - x + x  - x  + x  +
    
        \ /    2    4    6    8      \ /  5    10    15    20     \ /    5    
     1  / \ - x  + x  - x  + x  + 1  / \ x  + x   + x   + x   + 1 / \ - x  + x
    
              10    15    20      \ /    10    20    30    40      \
                 - x   + x   + 1  / \ - x   + x   - x   + x   + 1  /
    
  16. Factor the polynomial x^4-3x^2+1 over the algebraic extension Q(p), where p is a root of the polynomial X^2-X-1.
    >> loadlib("domains");
    >> Qphi:= AlgebraicExtension( Rational, X^2-X-1, phi ):
    >> Qphi::name := "Qphi";
    >> Factor( poly(x^4-3*x+1, Qphi) );
    
             poly(x + phi, [x], Qphi) poly(x + phi - 1, [x], Qphi)
             poly(x + phi + 1, [x], Qphi) poly(x - phi, [x], Qphi)
    
    We have first loaded the domains package, then defined the algebraic extension Qphi of the rationals with the polynomial X^2-X-1, with phi being an alias for the roots of this polynomial. The command Qphi::name:="Qphi" was only used to have a simpler output for the algebraic extension name.

  17. Factor the polynom x^4-3x^2+1 modulo 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]
    
    This result means that x^4 - 3x^2 + 1 factors into (x-2)^2 (x+2)^2 modulo 5. MuPAD provides a special representation poly for polynomials, that enables the user to specify the variables and the coefficient field.

  18. Compute the partial fraction decomposition of (x^2+2x+3)/(x^3+4x^2+5x+2).
    >> partfrac((x^2+2*x+3)/(x^3+4*x^2+5*x+2)); 
    
                              2       3              - 2
                          - ----- + ----- + 2 (x + 1)   
                            x + 1   x + 2               
    

    Inequalities

  19. Solve the inequality |x-1| > 2.
    >> solve( abs(x-1) > 2, x );
    
                 {[-infinity <= x, x < -1], [3 < x, x <= infinity]}
    
  20. Solve the inequality (x-1)(x-2)(x-3)(x-4)(x-5)) < 0.
    >> solve( expand((x-1)*(x-2)*(x-3)*(x-4)*(x-5)) < 0, x );
    
    	    {[2 < x, x < 3], [-infinity <= x, x < 1], [4 < x, x < 5]}
    

    Trigonometry

  21. Rewrite cos(3x) cos(x)in terms of cos(x) and sin(x).
    >> expand(cos(3*x)/cos(x));
    
                                           2    
                                   4 cos(x)  - 3
    
  22. Linearize cos(3x) cos(x).
    >> combine(expand(cos(3*x)/cos(x)),sincos);
    
                                  2 cos(2 x) - 1
    

    Determining Zero Equivalence

  23. Simplify sqrt(997) - (997^3)^(1/6).
    >> sqrt(997)-(997^3)^(1/6);
    
                                         1/6      1/2
                              - 991026973    + 997   
    
    >> simplify(%);
    
                                         0
    
  24. Simplify sqrt(999983) - (999983^3)^(1/6).
    >> sqrt(999983)-(999983^3)^(1/6);
    
                               1/2                     1/6
                         999983    - 999949000866995087   
    
    >> simplify(%);
    
                                         0
    
  25. Recognize that (2^(1/3)+4^(1/3))^3-6*(2^(1/3)+4^(1/3)) - 6 is 0.
    >> simplify(expand((2^(1/3)+4^(1/3))^3-6*(2^(1/3)+4^(1/3))-6));
    
                                         0
    
  26. Simplify log tan(x/2+Pi/4) - sinh^(-1) tan x to 0. In fact, this simplification is not valid in general in the complex plane:
    >> f := ln(tan(x/2+PI/4))-asinh(tan(x)):
    >> float(subs(f,x=-2));
    
                           - 3.046904887 + 3.141592653 I
    
    and whence it is not possible to achieve it in MuPAD.

  27. Show that the function log(tan(x/2+Pi/4))-sinh^(-1)(tan(x)) is 0 in x=0 and that its derivative is 0.
    >> f := ln(tan(1/2*x + PI/4)) - asinh(tan(x)):
    >> eval(subs(f,x=0));
    
                                 0
    
    >> combine(normal(combine(normal(expand(diff(f,x))),sincos)),sincos);
    
                                 0
    
    >> combine(normal(expand(diff(f,x))),sincos);
    
                                     /    1    \1/2    
                            - cos(x) | ------- |    + 1
                                     |       2 |       
                                     \ cos(x)  /       
                            ---------------------------
                                      cos(x)           
    
    As said previously, the function f is not zero everywhere in the complex plane. The above expression tells us that the derivative vanishes when the real part of cos x is positive, i.e. we can conclude that f(x) is really zero when -Pi/2 < Re(x) < Pi/2.

  28. Simplify log( (2 sqrt(r)+1) / sqrt(4r+4 sqrt(r)+1) ).
    >> simplify(ln((2*sqrt(r)+1)/sqrt(4*r+4*sqrt(r)+1)));
    
                                         0
    
  29. Simplify -2 sqrt(r) + (2 sqrt(r)+1) ^ (1/ (2 sqrt(r)+1)) (4r+4 sqrt(r)+1)^(sqrt(r) 1/ (2 sqrt(r)+1)) -1.
    >> e:=(4*r+4*sqrt(r)+1)^(sqrt(r)/(2*sqrt(r)+1))
               *(2*sqrt(r)+1)^(1/(2*sqrt(r)+1))-2*sqrt(r)-1:
    >> assume(r>0):
    >> simplify(e);
    
                                         0
    
    Without the assumption r>0, MuPAD cannot simplify the expression because the transformation (z^a)^b --> x^ab is not true in general for z complex (here we have z=2 sqrt(r)+1, a=2, and b=sqrt(r)/(2 sqrt(r)+1).

    The Complex Domain

  30. Compute the rectangular form a+ib of log(3+4i).
    >> rectform(ln(3+4*I));
    
                                ln(5) + I atan(4/3)
    
    The real and imaginary part are obtained with Re(..) and Im(..) respectively.

  31. Compute the rectangular form of tan(x+iy).
    >> rectform(tan(x+I*y),{x,y});
    
                          sin(2 x)             I sinh(2 y)     
                    -------------------- + --------------------
                    cos(2 x) + cosh(2 y)   cos(2 x) + cosh(2 y)
    
    Here the set {x,y} given as second argument specifies that the variables x and y are real. By default all variables are considered as complex.

  32. Simplify sqrt(x*y*|z|^2) / sqrt(x) / |z|.
    >> sqrt(x*y*abs(z) / (sqrt(x)*abs(z));
    
                        -1/2      1/2
                       x     (x y)
    
  33. Do not simplify sqrt(e^z)-e^(z/2) to 0 without any assumption on the imaginary part of z.
    >> sqrt(exp(z))-exp(z/2);
    
                                    / z \         1/2
                              - exp | - | + exp(z)   
                                    \ 2 /            
    
  34. Simplify sqrt(e^6i) into its correct value -e^3i.
    >> sqrt(exp(6*I));
    
                                     -exp(3 I)
    
  35. Simplify log e^z into z only for -Pi < Im(z) <= Pi.
    >> simplify(ln(exp(z)));
    
                                    ln(exp(z))
                                    
    >> assume(x,Type::RealNum): ln(exp(x));
    
                                         x
    
  36. Compute the correct principal value of log e^10i, namely (10-4Pi)i.
    >> ln(exp(10*I)); 
    
                                 (- 4 I) PI + 10 I
    
    
  37. Simplify (xy)^ (1/n) -x^ (1/n) y^(1/n) with respect to the domain of x, y, n.
    >> e:=(x*y)^(1/n)-x^(1/n)*y^(1/n): simplify(e);
    
                                       1    1  1
                                       -    -  -
                                       n    n  n
                                  (x y)  - x  y 
    
    >> assume(x>0): simplify(e);
    
                                         0
    
    >> unassume(x): assume(y>0): simplify(e);
    
                                         0
    
    Here the command unassume(x) deletes all assumptions about the variable x.

  38. Simplify tan^ (-1) tan(z) into z only for -Pi/2 < z <= Pi/2.
    >> atan(tan(z));
    
                                   atan(tan(z))
    
    >> assume(x>-PI/2): assume(x<=PI/2): atan(tan(x));
    
                                         x
    
  39. Compute the correct value of tan^ (-1) tan(4), namely 4-Pi.
    >> atan(tan(4));
    
                                     - PI + 4
    
  40. Equations

  41. Solve the polynomial equation 3x^3 -18x^2 +33x -19 = 0.
    >> s:=solve( 3*x^3-18*x^2+33*x-19 ):
    >> simplify( rectform(s[i])) $ i=1..3;
    
             1/2    / PI \                     1/2    / PI \      
          2 3    cos| -- |                    3    cos| -- |      
                    \ 18 /           / PI \           \ 18 /      
          ---------------- + 2, - sin| -- | - -------------- + 2, 
                 3                   \ 18 /         3             
          
                          1/2    / PI \    
                         3    cos| -- |    
                / PI \           \ 18 /    
             sin| -- | - -------------- + 2
                \ 18 /         3           
    
  42. Solve the equation x^4+x^3+x^2+x+1=0.
    >> p:=x^4+x^3+x^2+x+1: s:=solve(p,x);
    
    {        /    1/2       \1/2               /    1/2       \1/2       
    {        |   5          |                  |   5          |          
    {  1/2   | - ---- - 5/2 |            1/2   | - ---- - 5/2 |          
    { 5      \    2         /           5      \    2         /          
    { ---- - ------------------- - 1/4, ---- + ------------------- - 1/4,
    {  4              2                  4              2                
    
                /  1/2       \1/2                 /  1/2       \1/2       }
                | 5          |                    | 5          |          }
          1/2   | ---- - 5/2 |              1/2   | ---- - 5/2 |          }
         5      \  2         /             5      \  2         /          }
       - ---- - ----------------- - 1/4, - ---- + ----------------- - 1/4 }
          4             2                   4             2               }
    
  43. Verify a solution of the above equation.
    >> expand(simplify(expand(subs(p,x=s[1]))));
    
                                         0
    
  44. Solve the equation:
    >> solve(exp(2*x)+2*exp(x)+1=z,x);
    
                                      1/2      
      {(- 2 I) PI (0, 1, -1, ...) + ln(z    - 1),
    
                                          1/2      
       (- 2 I) PI (0, 1, -1, ...) + ln(- z    - 1)}
    
  45. Solve the equation (x+1) (sin^2(x)+1)^2*cos^3(3x) = 0.
    >> solve( (x+1)*(sin(x)^2*cos(3*x)^3) = 0, x );
    
    {                                                                              
    { I asinh(1) + 2 PI (0, 1, -1, ...), (- I) asinh(1) + 2 PI (0, 1, -1, ...), -1,
    {                                                                              
    
       PI   PI (0, 1, -1, ...)                                             
       -- + ------------------, PI + (- I) asinh(1) + 2 PI (0, 1, -1, ...),
       6            3                                                      
    
                                              }
       PI + I asinh(1) + 2 PI (0, 1, -1, ...) }
                                              }
    
  46. Solve the equation e^z = 1.
    >> solve( exp(z) = 1, z );
    
                             {(- 2 I) PI (0, 1, -1, ...)}
    
    Here again the variable k1 represents an arbitrary integer.
    
  47. Solve the equation sin(x) = cos(x).
    >> solve( sin(x) = cos(x), x );
    
          { PI                           3 PI                        }
          { -- + 2 PI (0, 1, -1, ...), - ---- + 2 PI (0, 1, -1, ...) }
          { 4                             4                          }
    
  48. Solve the equation tan(x) = 1.
    >> solve( tan(x) = 1, x );
    
                            { PI                      }
                            { -- + PI (0, 1, -1, ...) }
                            { 4                       }
    
  49. Solve the equation sin x = tan x.
    >> solve(sin(x)=tan(x),x);
    
                        {PI (0, 1, -1, ...), 2 PI (0, 1, -1, ...)}
    
  50. Solve the equation sqrt(x^2+1) = x-2.
    >> solve(sqrt(x^2+1)=x-2,x);
    
                                        {}
    
    The function sqrt in MuPAD represents the principal square root, and the possible solution x=3/4 does not correspond to a principal square root.

  51. Solve the equation e^ (2-x^2) = e^(-x).
    >> solve(exp(2-x^2)=exp(-x),x);
    
    {                             1/2                                      1/2       }
    { (8 I PI (0, 1, -1, ...) + 9)             (8 I PI (0, 1, -1, ...) + 9)          }
    { ------------------------------- + 1/2, - ------------------------------- + 1/2 }
    {                2                                        2                      }
    
    >> assume(x,Type::RealNum):
    >> solve(exp(2-x^2)=exp(-x),x);
    
                                      {-1, 2}
    
    The first solution assumes that x represents any complex number, whereas in the second call MuPAD was asked to return only real solutions, which correspond to the index 0 of the general solution.

  52. solve the equation sqrt(log x) = log sqrt(x).
    >> solve(sqrt(ln(x))=ln(sqrt(x)),x);
    
                                    {1, exp(4)}
    
    The above answer is returned without any assumption about x, therefore 1 and e^4 are the only roots in the whole complex plane.

  53. Solve the equation |x-1|=2.
    >> solve( abs(x-1)=2, x );
    
                                 [3, -1]
    
  54. Solve the linear (dependent) system x+y+z=6,2x+y+2z=10,x+3y+z=10.
    >> linsolve({x+y+z=6,2*x+y+2*z=10,x+3*y+z=10},{x,y,z});
    
                               [{y = 2, x = - z + 4 }]
    
  55. Solve the system of nonlinear equations x^2y+3yz-4=0, -3x^2z+2y^2+1=0, 2yz^2-z^2-1=0.
    >> s:=solve({ x^2*y + 3*y*z - 4, -3*x^2*z + 2*y^2 + 1, 2*y*z^2 - z^2 - 1}):
    
       -- --          2       4                    
       |  |        5 z    21 z        5      6     
       |  |  y = - ---- - ----- + 24 z  - 9 z  - 1,
       -- --        2       2                      
    
                                                                               
                            2       2      3       4      5       6       7    
       x = RootOf(19 z + 6 x  - 48 z  + 2 z  + 48 z  + 3 z  - 48 z  + 18 z , x)
                                                                               
    
                                                             -- --
                       2      4       6       7       8       |  |
       , z = RootOf(3 z  + 5 z  + 21 z  - 48 z  + 18 z  + 1)  |  |
                                                             -- --
    
    
    Here the solution is expressed with the help of the RootOf notation. There are 8 solutions, each one corresponding to z being one of the roots of the polynomial 18z^8-48z^7+21z^6+5z^4+3z^2+1, y is a polynomial in z as shown above, and x being one root of a degree two polynomial dependent on z.

    Matrix Algebra

  56. Invert the 2x2 matrix [[a,b],[1,ab]].
    >> loadlib("domains"): export(domains):
    >> loadlib("linalg"): export(linalg):
    >> M := Matrix( ExpressionField(normal) ):
    >> m := M( [[a,b],[1,a*b]] ):
    >> 1/m;
    
                            +-                      -+
                            |    a            1      |
                            |  ------  ,  ---------  |
                            |   2            2       |
                            |  a  - 1     - a  + 1   |
                            |                        |
                            |    1            a      |
                            | -------- , ----------- |
                            |      2            2    |
                            | b - a  b   - b + a  b  |
                            +-                      -+
    
    Here we first load the necessary packages, then we define the domain M of matrices whose coefficients are in the domain ExpressionField(normal), which means the set of all MuPAD expressions after simplification by normal. We could have written as well Matrix( ExpressionField ) if we do not want the expressions to be normalized. Please note that no special command is necessary to invert the matrix: we can use the standard arithmetic operators due to the overloading mechanism of MuPAD.

  57. Compute the determinant of the 4x4 Vandermonde matrix over w,x,y,z.
    >> loadlib("linalg"): export(linalg):
    >> M := SquareMatrix(4):
    >> m := M([[1,1,1,1],[w,x,y,z],[w^2,x^2,y^2,z^2],[w^3,x^3,y^3,z^3]]):    
    >> Factor(det(m));
    
                  (w - x) (w - z) (x - z) (x - y) (w - y) (y - z)
    
  58. Find the eigenvalues of the matrix [[5, -3, -7],[-2, 1, 2],[ 2, -3, -4]].
    >> m := SquareMatrix(3)([[5, -3, -7],[-2,  1,  2],[ 2, -3, -4]]):
    >> eigenValues(m);
    
                                     [1, 3, - 2]
    
    Here we supposed that the linalg package was already loaded (see above example).

    Sums and products

  59. Find a closed-form for the sum over k^3 for k=1..n.
    >> Factor(sum(k^3,k=1..n));
    
                                       2        2
                                  1/4 n  (n + 1) 
    
  60. Find a closed-form for the sum over 1/k^2+1/k^3 for k=1..infinity.
    >> sum(1/k^2+1/k^3,k=1..infinity);
    
                                               2
                                             PI 
                                   zeta(3) + ---
                                              6 
    

    Calculus

  61. Compute the limit of (1+1/n)^n when n goes to infinity, and the limit of (1-cos x)/x^2 when x goes to zero.
    >> limit((1+1/n)^n,n=infinity);
    
                                         E
    
    >> limit((1-cos(x))/x^2,x=0);
    
                                        1/2
    
    It should be noted that the limit functions of MuPAD implements the best known algorithm to this date. It is based on the concept of most-rapidly-varying subexpressions (MRV), and a comparison made by Dominik Gruntz on 19 exp-log expressions Gruntz95 showed that the algorithms implemented in other computer algebra systems (except Maple and MuPAD) fail on many examples, and even return wrong values !

    Indefinite Integrals

  62. Integrate 1/(x^3+2), then differentiate and simplify.
    >> int(1/(x^3+2),x);
    
                 /                              /       3         \ \
             sum \ X2 ln(x + 6 X2), X2 = RootOf \ 108 X3  - 1, X3 / /
    
    >> diff(%,x);
    
                                        1   
                                      ------
                                       3    
                                      x  + 2
    
    The output from int means that an antiderivative of 1/(x^3+2) is the sum of the three functions ai*ln(x+6*ai), where ai is one of the roots of the polynomial 108 X^3-1. The sum expression can be differentiated, and the result is a sum of three rational functions, namely ai/(x+6*ai), which is automatically normalized. More generally, the sum of any rational function over the roots of a polynomial simplifies to an expression involving the polynomial coefficients. The MuPAD syntax for this is sum(f,t=RootOf(..)); for example sum(t^2,t=RootOf(x^3+a*x^2+b*x+c,x)) returns a^2-2*b.

  63. Compute an antiderivative of 1/(a + b cos x) where a < b.
    >> assume(a^2>b^2):
    >> int(1/(a+b*cos(x)),x);
    
              2          2         2    2 1/2                2    2 1/2  
       ln((I a  + (- I) b  + a (- a  + b )    + b cos(x) (- a  + b )    +
    
                          2    2 1/2               2    2 1/2              2     
       (- I) b sin(x) (- a  + b )   )   / b) / (- a  + b )    - ln(((- I) a  +
       
          2         2    2 1/2                2    2 1/2  
       I b  + a (- a  + b )    + b cos(x) (- a  + b )    +
    
                          2    2 1/2               2    2 1/2
       (- I) b sin(x) (- a  + b )   )   / b) / (- a  + b )   
    
  64. Differentiate the above antiderivative and find again 1/(a + b cos x).
    >> normal(expand(combine(normal(diff(%,x)),sincos)));
    
                                        1      
                                   ------------
                                   a + b cos(x)
    
  65. Compute the derivative of |x|.
    >> diff(abs(x),x);
    
                                      sign(x)
    
    The extension of the functionality of MuPAD by such rules is very easy. For example to ``teach'' to MuPAD that the derivative of sin(f) with respect to x is cos(f) f', we simply write:
    >> sin := funcattr(sin,"diff",proc(f,x) begin cos(f)*diff(f,x) end_proc);
    
  66. Compute an antiderivative of |x|.
    >> int(abs(x),x);
    
                                     x abs(x)
                                     --------
                                        2    
    
  67. Compute the derivative of |x| (piecewise defined).
    >> a:=proc(x) begin if x < 0 then -x else x end_if end_proc:
    >> D(a);
    
                                 proc(x)
                                   name a;
                                 begin
                                   if x < 0 then
                                     -1
                                   else
                                     1
                                   end_if
                                 end_proc
    
  68. Compute the antiderivative of |x| (piecewise defined).
    >> a:=proc(x) begin if x < 0 then -x else x end_if end_proc:
    >> int(a);
    
                                 proc(x)
                                   name a;
                                 begin
                                   if x < 0 then
                                     x^2*(-1/2)
                                   else
                                     x^2*1/2
                                   end_if
                                 end_proc
    
    
  69. Compute an antiderivative of x/(sqrt(1+x)+sqrt(1-x)).
    >> int(x/(sqrt(1 + x) + sqrt(1 - x)), x);
    
            / ln(x + 1) \ / x       \       / ln(- x + 1 ) \ /   x        \
        exp | --------- | | - + 1/3 | + exp | ------------ | | - - + 1/3  |
            \     2     / \ 3       /       \      2       / \   3        /
    
    The result can be simplified using the expand command.

  70. Compute an antiderivative of (sqrt(1+x)-sqrt(1-x))/2, which is the same as above.
    >> int((sqrt(1 + x) - sqrt(1 - x))/2, x);
    
            / ln(x + 1) \ / x       \       / ln(- x + 1 ) \ /   x        \
        exp | --------- | | - + 1/3 | + exp | ------------ | | - - + 1/3  |
            \     2     / \ 3       /       \      2       / \   3        /
    
    MuPAD 1.2.1 was already able to solve these two examples, but you had to explicitly load the intlib package and to call intlib::int. Now there is a ``toplevel'' function int for definite and indefinite integration.

    Definite Integrals

  71. Compute the Cauchy principal value of the integral over 1/(x-a) in the range x=a-1..a+1.
    >> int(1/(x-a),x=a-1..a+1), int(1/(x-a),x=a-1..a+1,PrincipalValue);
    
                                   undefined, 0
    
  72. Check that the integral over 1/(x-a)^2) in the range x=a-1..a+1 is divergent.
    >> int(1/(x-a)^2,x=a-1..a+1);
    
                                     infinity
    
  73. Compute the integral over cos(x)/(x^2+a^2) for a > 0 in the range -infinity to infinity.
    >> sign(a):=1:  int( cos(x)/(x^2+a^2), x=-infinity..infinity );
    
                                    PI exp(-a)
                                    ----------
                                        a 
    
  74. Compute the integral over t^ (a-1) / (1+t) for 0 <= Re(a) <= 1 in the range 0 to infinity.
    >> assume(Re(a)>0): assume(Re(a)<1):
    >> int(t^(a-1)/(1+t),t=0..infinity);
    
                                        PI    
                                     ---------
                                     sin(a PI)
    
    
  75. Compute the integral int( x=0..a, int( y=0..b(1-x/a), int( z=0..c(1-x/a-y/b), 1 ).
    >> int(int(int(1,z=0..c*(1-x/a-y/b)),y=0..b*(1-x/a)),x=0..a);
    
                                       a b c
                                       -----
                                         6  
    

    Series

  76. Compute the first terms of the Taylor expansion of 1/sqrt(1-v^2/c^2) at v=0.
    >> series(1/sqrt(1-(v/c)^2),v=0);
    
                         - 2  2      - 4  4               
                        c    v    3 c    v          /  6 \
                        ------- + --------- + 1 + O \ v  /
                           2          8                   
    
  77. Compute the inverse of the square of the above expansion.
    >> 1/%^2;
    
                                - 2  2         /  6 \
                             - c    v  + 1 + O \ v  /
    
    This is possible in MuPAD because of the domain facility, and the fact that standard arithmetic operations can be overloaded for domain elements. This allows to get O(x) as the result of O(x)-O(x), whereas for example Maple gives 0.

  78. Compute the Taylor expansion of tan(x) at x=0 by dividing the expansion of sin(x) by that of cos(x).
    >> series(sin(x),x)/series(cos(x),x)=series(tan(x),x);
    
                     3      5                   3      5           
                    x    2 x      /  6 \       x    2 x      /  6 \
                x + -- + ---- + O \ x  / = x + -- + ---- + O \ x  /
                    3     15                   3     15            
    
    >> bool(%);
    
                                       TRUE
    
    Here again, the results of a series command can be combined with any arithmetic operation.

  79. Compute the expansion of log(sinh(z)) + log(cosh(z+w)) at z=0.
    >> series(ln(sinh(z))+ln(cosh(z+w)),z,3);
    
                                          z sinh(w)     /  2 \
                    ln(z) + ln(cosh(w)) + --------- + O \ z  /
                                           cosh(w)            
    
  80. Subtract from the above expansion that of log( sinh(z) cosh(z+w) ).
    >> %-series(ln(sinh(z)*cosh(z+w)),z,3);  
    
                                       /  2 \
                                     O \ z  /
    
  81. Compute the expansion of log(sin x/x) at x=0.
    >> series(ln(sin(x)/x),x);
    
                                  2    4            
                                 x    x       /  5 \
                               - -- - --- + O \ x  /
                                 6    180           
    
  82. Revert the Taylor expansion of sin(y) + cos(y) at y=0.
    >> s:=series(sin(y)+cos(y),y=0);
    
                            2    3    4    5                
                           y    y    y    y           /  6 \
                       y - -- - -- + -- + --- + 1 + O \ y  /
                           2    6    24   120               
    
    >> t:=revert(s);
    
                 2            3                        5                     
          (y - 1)    2 (y - 1)           4   17 (y - 1)          /        6 \
      y + -------- + ---------- + (y - 1)  + ----------- - 1 + O \ (y - 1)  /
             2           3                       10                          
    
    We can check the result by asking for s @ t that computes the composition of s and t.

    Transforms

  83. Compute the Laplace transform of cos((w-1)t) with repsect to t.
    >> laplace( cos((w-1)*t), t, s );
    
                                         s      
                                   -------------
                                    2          2
                                   s  + (w - 1) 
    
  84. Compute the invers Laplace transform of result above.
    >> ilaplace( %, s, t );
    
                                  cos(t (w - 1))
    

    Differential Equations

  85. Solve the differential equation f''(t)+4f(t)=sin(2t) with the initial conditions f(0)=f'(0)=0.
    >> loadlib("ode"):
    >> ode({diff(f(t),t,t)+4*f(t)=sin(2*t),f(0)=0,D(f)(0)=0},f(t));
    
     ode({D(f)(0) = 0, f(0) = 0, 4 f(t) + diff(f(t), t, t) = sin(2 t)}, f(t))
    
    >> solve(%);
    
                            -- sin(2 t)   t cos(2 t) --
                            |  -------- - ----------  |
                            --    8           4      --
    
    Here we first load the ode package, then we define the equation with the ode command, and simply call solve on this equation.

  86. Solve the above equation using Laplace transforms.
    >> laplace( diff(f(t),t,t)+4*f(t)=sin(2*t), t, s);
    
                                                                             2   
      4 laplace(f(t), t, s) - D(f)(0) + s (s laplace(f(t), t, s) - f(0)) = ------
                                                                            2    
                                                                           s  + 4
    
    >> solve( subs(%,f(0)=0,D(f)(0)=0), laplace(f(t), t, s) );
    
                                  --     2     --
                                  |  ---------  |
                                  |    2     2  |
                                  -- (s  + 4)  --
    
    >> ilaplace( op(%),s,t );
    
                              / sin(2 t)   t cos(2 t) \
                            2 | -------- - ---------- |
                              \    16          8      /
    
  87. Solve the equation x^2 y'(x) + 3 x y(x) = sin x/x.
    >> solve(ode(x^2*diff(y(x),x)+3*x*y(x)=sin(x)/x,y(x)));
    
                            --     - 3    - 3        --
                            |  C3 x    - x    cos(x)  |
                            --                       --
    
  88. Solve the equation y'' + y {y'}^3 = 0 for y(x).
    >> solve(ode(diff(y(x),x,x)+y(x)*diff(y(x),x)^3=0,y(x)));
    
                 --            /                        3    \ --
                 |  C5, RootOf \ 6 x + 6 C6 + 6 C4 y - y , y /  |
                 --                                            --
    
    This result says that the solution is either a constant function y(x)=C5, or an algebraic function satisfying the equation y(x)^3 = 6 C4 y(x)+6x+6 C6 where C4 and C6 are arbitrary constants.

  89. Solve the equation d/dx ( y(x,a) = a*y(x,a) ).
    >> solve(ode(diff(y(x,a),x)=a*y(x,a),y(x,a)));
    
                                   [C1 exp(a x)]
    
    MuPAD recognizes equations with only one differential variable as ordinary differential equations.

  90. Solve the system x'(t)=x(t)-y(t), y'(t)=x(t)+y(t).
    >> sys := {diff(x(t),t)-x(t)+y(t)=0,diff(y(t),t)-x(t)-y(t)=0}:
    >> solve(ode(sys, {x(t),y(t)}));
    
     [x(t) = (I) C5 exp((1 + I) t) + (- I) C6 exp((1 - I) t), y(t) = C5 exp((
    
                          1 + I) t) + C6 exp((1 - I) t)]
    
  91. Verify that the expression above is a solution.
    >> eval(subs([op(sys)],op(%))); 
    
                                  [0 = 0, 0 = 0]
    

    Operators

  92. Define the operator L = (D-1) (D+2) where D is the differentiation operator.
    >> L := (D-id) @ (D+2*id);
    
                              (- id + D )@(2 id + D)
    
    In MuPAD, id stand for the identity, and @ is the composition operator.

  93. Compute L(f) where L is the above defined operator.
    >> L(f);
    
                              - 2 f + D(f) + D(D(f))
    
  94. Compute L(g)(y) where L is the above defined operator.
    >> L(g)(y);
    
                          - 2 g(y) + D(g)(y) + D(D(g))(y)
    
  95. Apply the operator L to the function z --> A*sin(z^2).
    >> h:= func( A*sin(z^2), z ):
    >> L(h)(z);
    
                     2             2             2         2      2
            2 A cos(z ) - 2 A sin(z ) + 2 A cos(z ) - 4 A z  sin(z )
    
  96. Define the operator T such that T(f)(x,a) = f(a) + f'(x) (x-a) + f''(a) (x-a)^2/2.
    >> T:=proc(f) begin
    &>    eval(subsop(hold(func(f,x,a)),
    &>      1=_plus(f(a),_fconcat(D$k)(f)(a)/fact(k)*(x-a)^k$k=1..2)))
    &> end_proc:
    
  97. Evaluate T for an unknown function f.
    >> T(f);
    
          func(f(a) + (-a + x)*D(f)(a) + (-a + x)^2*D(D(f))(a)*1/2, x, a)
    
  98. Evaluate T for an unknown function g and a generic point (y,b).
    >> T(g)(y,b);
    
                                                                 2
                                            D(D(g))(b) (- b + y ) 
                g(b) + D(g)(b) (- b + y ) + ----------------------
                                                      2           
    
  99. Evaluate T for the function sin and a point (z,c).
    >> T(sin)(z,c);
    
                                                                2
                                               sin(c) (- c + z ) 
                  sin(c) + cos(c) (- c + z ) - ------------------
                                                       2         
    

    Programming

  100. Compute the Legendre polynomials directly.
    >> p:= proc(n, x) begin
        if n = 0 then 1
        else normal(1/(2^n*fact(n)) * diff((x^2 - 1)^n, x$n))
        end_if
        end_proc:
    >> p(i,x) $ i=0..4;
    
                       2                   3         2       4      
                    3 x           3 x   5 x      15 x    35 x       
              1, x, ---- - 1/2, - --- + ---- , - ----- + ----- + 3/8
                     2             2     2         4       8        
    
  101. Compute the Legendre polynomials recursively, using their recurrence of order 2.
    >> pp:= proc(n, x) option remember; begin
         if n=0 then 1
         elif n=1 then x
         else normal(((2*n - 1)*x*pp(n - 1, x) - (n - 1)*pp(n - 2, x))/n)
         end_if
         end_proc:
    >> pp(i,x) $ i=0..4;
    
                       2                   3         2       4      
                    3 x           3 x   5 x      15 x    35 x       
              1, x, ---- - 1/2, - --- + ---- , - ----- + ----- + 3/8
                     2             2     2         4       8        
    
  102. Evaluate the fourth Legendre polynomial at 1.
    >> pp(4,1);
    
                                         1
    
    The Legendre polynomials are already defined in the orthpoly package, whence one can write orthpoly::legendre(4,1) too.

    Translation

  103. Define the polynomial p = sum( i=1..5, ai*x^i ).
    >> p:= poly(_plus(a.i * x^i $ i=1..5), [x]);
    
                     /         2       3       4       5         \
                poly \ x a1 + x  a2 + x  a3 + x  a4 + x  a5, [x] /
    
  104. Apply Horner's rule to the above polynomial.
    >> p(x);
    
                     x (a1 + x (a2 + x (a3 + x (a4 + x a5))))
    
  105. Convert the above result to Fortran syntax.
    >> generate::fortran(hold(p)=%);
          p = x*(a(1)+x*(a(2)+x*(a(3)+x*(a(4)+x*a(5)))))
    

    Boolean Logic

  106. Evaluate TRUE and FALSE.
    >> TRUE and FALSE;
    
                                       FALSE
    
  107. Simplify x or (not x).
    >> x or (not x);
    
                                       TRUE
    
  108. Simplify the boolean expression x or y or (x and y)
    >> simplify( x or y or (x and y), logic );
    
                                       x or y
    

Summary

Number of solved problems: 107 over 131 (37 new problems with respect to MuPAD 1.2.2). As a comparison, Reduce can solve 49 problems, Axiom 57 problems, Derive 67 problems, Mathematica 80 problems, Maple 89 problems and Macsyma 102 problems, but none of these systems is public domain ! You can get MuPAD by anonymous ftp from ftp.uni-paderborn.de:/pub/MuPAD and also from many other sites. Please refer to out WWW documentation http://math-www.uni-paderborn.de/MuPAD/.

Acknowledgement: Many thanks to Michael Wester for his very detailed comments on a first version of this paper.

References

Mupad93
Fuchssteiner, B., and al. MuPAD Benutzerhandbuch. Birkhäuser, Basel, 1993.

Mupad94
Fuchssteiner, B., and al. MuPAD Tutorial. Birkhäuser, Basel, 1994.

Gruntz95
Gruntz, D. On Computing Limits in a Symbolic Manipulation System. PhD thesis, Swiss Federal Institute of Technology Zürich, 1995.

Wester94
Wester, M. A review of cas mathematical capabilities. Computer Algebra Nederland Nieuwsbrief 13 (Dec. 1994), 41--48.

Converted and installed by: MuPAD-Webmaster
Last updated: 10. Jan. 1996