A. Solutions to Exercises

Exercise 2.1: The help page ?diff tells you how to compute higher order derivatives:

» diff(sin(x~2), x, x, x, x, x)

32 x 5 cos (x2 ) - 120 x cos (x2 ) + 160 x 3 sin (x2 )

You can also use the longer command diff (diff ( ... , x) , x).

Exercise 2.2: The exact representations are: » sqrt(27) - 2*sqrt(3) , cos(PI/8)

v'3 y'v'2 + 2 , 2

The numerical approximations are:

» DIGITS := 5: » float(sqrt(27) - 2*sqrt(3», float(cos(PI/8» 1.7321, 0.92388

They are correct to within 5 digits.

Exercise 2.3:

» expand«x~2 + y)~5)

5 x 8 y + 5 x 2 y4 + 10 X4 y3 + 10 x 6 y2 + x 10 + y5

Exercise 2.4:

» normal«x~2 - 1)/(x + 1» x-I 336 A. Solutions to Exercises

Exercise 2.5: You can plot the function f(x) = 1/ sin (x) on the interval [1 , 10] without any problems since the (equidistant) graphical sample points in this interval contain no singularities: » plotfunc2d(1/sin(x), x = 1 .. 10)

y

10 X -1

-2 I /

However, on the interval [0,10]' you run into problems. The boundaries be• long to the sample points. An error occurs when the system tries to evaluate 1/ sin(O) = 1/0 at the left boundary.

Exercise 2.6: MuPAD immediately returns the claimed limits: » limit(sin(x)/x, x = 0), limit«l - cos(x»/x, x = 0), limit(ln(x), x = 0, Right) 1,0, -00 » limit(xAsin(x), x = 0), limit«l + l/x)Ax, x = infinity), limit(ln(x)/exp(x), x = infinity) 1, e, 0 » limit(xAln(x), x = 0, Right), limit«l + PI/X)AX, x = infinity), limit(2/(1 + exp(-l/x», x = 0, Left)

00, e1r , 0

The result undefined denotes a non-existing limit: » limit(exp(cot(x», x = 0) undefined A. Solutions to Exercises 337

Exercise 2.7: You obtain the first result in the desired form by factoring:

» sum(k A 2 + k + 1 , k = 1 .. n): % = factor(%)

3 -+n5 n 2 +-=n (1)- ·n· (3n+n 2) +5 3 3 3 » sum«2*k - 3)/«k + l)*(k + 2)*(k + 3)), k = O.. infinity) -1 4 » sum(k/(k - 1)-2/(k + 1)-2, k = 2 .. infinity) 5 16

Exercise 2.8:

» A := matrix([[l, 2, 3], [4, 5, 6], [7, 8, 0]]) : » B := matrix([[l, 1, OJ, [0, 0, 1], [0, 1, 0]]) : » 2*(A + B), A*B

6 6 ( ; 10 14)' (~ 1~ ~) 14 18 0 7 7 8 » (A - B)-(-1) I ~3 T) (-1 1 -2 '2 '2 7'

Exercise 2.9: a) The function numlib: :mersenne returns a list of values for p yielding the 40 currently known Mersenne primes that have been found on supercomputers. The actual computation for 1 < p ::::: 1000 can be easily performed in MuPAD: » select([$ 1 .. 1000], isprime): » select(%, p -> (isprime(2-p - 1)))

After some time you obtain the desired list of values of p:

[2,3,5,7,13,17,19,31,61,89,107,127,521,607] 338 A. Solutions to Exercises

The corresponding Mersenne primes are:

» map(%, p -> (2~p-l» [3, 7, 31, 127, 8191, 131071, 524287, 2147483647,

2305843009213693951, 618970019642690137449562111,

162259276829213363391578010288127, ... ] b) Depending on your computer's speed, you can test only the first 11 or 12 Fermat numbers in a reasonable amount of time. Note that the 12-th Fermat number already has 1234 decimal digits.

» Fermat := n -> (2~(2~n) + 1): isprime(Fermat(10» FALSE

The only known Fermat primes are the first five Fermat numbers (including Fermat (0»). Indeed, if MuPAD tests the first 12 Fermat numbers, then after some time it returns the following five values:

» select([Fermat(i) $ i = O.. 11], isprime) [3,5,17,257,65537]

Exercise 4.1: The first operand of a power is the base, the second is the exponent. The first and second operand of an equation is the left and the right hand side, respectively. The operands of a function call are its arguments:

» op(a~b, 1), op(a~b, 2) a, b » op(a = b, 1), op(a = b, 2) a, b » op(f(a, b), 1), op(f(a, b), 2) a, b A. Solutions to Exercises 339

Exercise 4.2: The list with the two equations is op(set, 1). Its second operand is the equation y = ... , whose second operand is the right hand side:

» set := solve({x+sin(3)*y = exp(a) , y-sin(3)*y = exp(-a)}, {x,y})

= sin (3) e-a - ea sin (3) ea = _ e-a ] } { [ + x sin (3) - 1 ' Y sin (3) - 1 » y := op(set, [1, 2, 2])

sin (3) - 1

Use assign(op(set» to perform assignments of both unknowns x and y simultaneously.

Exercise 4.3: If at least one number in a numerical expression is a floating• point number, then the result is a floating-point number: » 1/3 + 1/3 + 1/3, 1.0/3 + 1/3 + 1/3 1, 1.0

Exercise 4.4: You obtain the desired floating-point numbers immediately by applying float: » float(PIA(PIAPI», float(exp(PI*sqrt(163)/3»

1.340164183· 10 18 , 640320.0

Note that only the first 10 digits of these values are reliable since this is the default precision. Indeed, for larger values of DIGITS, you find: » DIGITS := 100: » float(PIA(PIAPI», float(exp(PI*sqrt(163)/3» 1340164183006357435.297449129640131415099374974573499\ 237787927516586034092619094068148269472611301142

640320.0000000006048637350490160394717418188185394757\ 714857603665918194652218258286942536340815822646

We compute 235 decimal digits of PI to obtain the correct 234-th digit after the decimal point. After setting DIGITS: =235, the result is the last shown digit of float (PI). A more elegant way is to multiply by 10234 . Then the 340 A. Solutions to Exercises desired digit is the first digit before the decimal point, and we obtain it by truncating the digits after the decimal point:

» DIGITS := 235: trunc(10~234*PI) - 10*trunc(10~233*PI) 6

Exercise 4.5: a) Internally, MuPAD computes exactly with some additional digits not shown in the output.

» DIGITS := 10: x := 10~50/3.0; floor(x) 3.333333333 . 1049 33333333333333333332837742572648668761603891527680 b) After increasing DIGITS, MuPAD displays the additional digits. However, not all of them are correct:

» DIGITS := 40: x 3.33333333333333333328377425726486687616.1049

Restart the computation with the increased value of DIGITS to obtain the desired precision:

» DIGITS := 40: x := 10~50/3.0 3.333333333333333333333333333333333333333.1049

Exercise 4.6: The names caution! -!, x-y, and Jack&Jill are invalid since they contain the special characters !, -, and &, respectively. Since an identifier's name must not start with a number, 2x is not valid either. The names diff and exp are valid names of identifiers. However, you cannot assign values to them since they are protected names of MuPAD functions.

Exercise 4.7: We use the sequence operator $ (Section 4.5) to generate the set of equations and the set of unknowns. Then a call to solve returns a set of simpler equations: A. Solutions to Exercises 341

» equations := {(x.i + x.(i+1) = 1) $ i = 1 .. 19, x20 = PI}: » unknowns := {x.i $ i = 1 .. 20}: » solutions := solve (equations , unknowns) {[xl = 1 - PI, xl0 = PI, xll = 1 - PI, x12 = PI, x13 1 - PI, x14 PI, x15 = 1 - PI, x16 = PI,

x17 1 - PI, x18 = PI, x19 = 1 - PI, x2 = PI,

x20 = PI, x3 = 1 - PI, x4 = PI, x5 = 1 - PI,

x6 = PI, x7 = 1 - PI, x8 = PI, x9 = 1 - PI]} We use the function assign to assign the computed values to the identifiers: » assign(op(solutions, 1»: xl, x2, x3, x4, x5, x6 1 - IT, IT, 1 -IT, IT, 1- IT, IT

Exercise 4.8: MuPAD stores the expression a~b - sin(a/b) in the form a~b+ (-1) *sin(a*b~(-l». Its expression tree is:

a b

Exercise 4.9: We observe that: » op(2/3); op(x/3) 2,3 1 x, "3 342 A. Solutions to Exercises

The reason is that 2/3 is of domain type DOM_RAT, whose operands are the numerator and the denominator. The domain type of the symbolic expression x/3 is DOM_EXPR and its internal representation is x * (1/3). The situation is similar for 1 + 2 * I and x + 2 * I: » op(l + 2*I); op(x + 2*I) 1, 2

x, 2i

The first object is of domain type DOM_COMPLEX. Its operands are the real and the imaginary part. The operands of the symbolic expression x + 2 * I are the first and the second term of the sum.

Exercise 4.10: The expression tree of condition= (not a) and (b or c) is: and

c

Thus op(condition, 1) =not a and op(condition, 2) =b or c. We obtain the atoms a, b, c as follows: » op(condition, [1, 1]), op(condition, [2, 1]), op(condition, [2, 2]) a, b, c

Exercise 4.11: You can use both the assignment function _assign presented in Section 4.3 and the assignment operator: =. » _assign(x.i, i) $ i = 1 .. 100: » (x.i := i) $ i = 1 .. 100:

You can also pass a set of assignment equations to the assign function:

» assign({x.i = i $ i = 1 .. 100}):

Exercise 4.12: Since a sequence is a valid argument of the sequence operator, you may achieve the desired result as follows: A. Solutions to Exercises 343

» (x.i $ i) $ i = 1 .. 10 xl, x2, x2, x3, x3, x3, x4, x4, x4, x4, ...

Exercise 4.13: We use the addition function _plus and generate its argu• ment sequence via $:

» _plus«(i+j)~(-l) $ j 1 .. i) $ i=1 .. 10) 1464232069 232792560

Exercise 4.14: » Ll := [a, b, c, dJ: L2 := [1, 2, 3, 4J: » Ll.L2, zip(Ll, L2, _mult) [a, b, c, d, 1, 2, 3, 4J, [a, 2 b, 3 c, 4 d]

Exercise 4.15: The function _mult multiplies its arguments:

»map([l, x, 2J, _mult, multiplier) [multiplier, x multiplier, 2 multiplierJ

We use map to apply the function sublist ->map(sublist, _mult, 2) to the sublists in a nested list: » L := [[1, x, 2J, [PIJ, [2/3, lJJ: mapel, map, _mult, 2)

[[2,2 x, 4], [27r], [~, 2]]

Exercise 4.16: For: » X := [xl, x2, x3J: Y := [yl, y2, y3J: the products are given immediately by

» _plus(op(zip(X, Y, _mult))) xl y I + x2 y2 + x3 y3

The following function f multiplies each element of the list Y by its input parameter x and returns the resulting list:

» f := x -> (map(Y, _mult, x)): 344 A. Solutions to Exercises

The next command replaces each element of X by the list returned by f:

» map (X, f) [[xl y1,x1y2, xl y3j , [x2y1,x2y2,x2y3j, [x3y1,x3y2,x3y3jj

Exercise 4.17: For each m, we use the sequence generator $ to create a list of all integers to be checked. Then we extract all primes from the list via select (., isprime). The number of primes is just naps of the resulting list. We compute this value for all m between 0 and 41:

» nops(select([(n-2 + n + m) $ n = 1 .. 100), isprime») $ m = 0 .. 41 1, 32, 0, 14, 0, 29, 0, 31, 0, 13, 0, 48, 0, 18, 0,

11, 0, 59, 0, 25, 0, 14, 0, 28, 0, 28, 0, 16, 0,

34, 0, 35, 0, 11, 0, 24, 0, 36, 0, 17, 0, 86

There is a simple explanation for the zero values for even m > O. Since n 2 + n = n (n + 1) is always even, n 2 + n + m is an even integer greater than 2 and hence not a prime.

Exercise 4.18: We store the children in a list C and remove the one that was counted out at the end of each round. We represent the positions 1,2, ... , n of n children by a list with the corresponding integers. Let out E {I, ... , n} be the position of the last child that was counted out. After deleting the out-th element, the next round begins at position out in the shortened list. At the end of the round, after m words, the child at position out + m- 1 in the current list is counted out. Since we are counting cyclically, we take this value modulo the number of remaining children. Note, however, that a mod b produces numbers in the range 0,1, ... , b - 1 rather than 1, ... , b. This is overcome by using «a - 1) mod b) + 1 instead of a mod b:

»m := 8: n := 12: C := [$ 1 .. n): out := 1: » out := «out + m - 2) mod nops(C) + 1: » crout] 8 » delete crout) : » out := «out + m - 2) mod nops(C)) + 1: » crout] 4 etc. It is useful to implement the complete counting by a loop (Chapter 16): A. Solutions to Exercises 345

»m := 8: n := 12: C := [$ 1 .. n]: out := 1: » repeat out := «out + m - 2) mod nops(C» + 1: print(C[out]); delete crout]; until nops(C} = 0 end_repeat: 8

4

1

11

9

5

Exercise 4.19: The following two conversions list I---t set I---t list in general change the order of the list elements:

» set := {op(list)}: list:= [op(set)]:

Exercise 4.20:

» A := {a, b, c}: B := {b, c, d}: C := {b, c, e}: » A union Bunion C, A intersect B intersect C, A minus (B union C) {a,b,c,d,e}, {b,c}, {a}

Exercise 4.21: You obtain the union via _union:

» M := {{2, 3}, {3, 4}, {3, 7}, {5, 3}, {1, 2, 3, 4}}: » _union(op(M» {1,2,3,4,5,7} and the intersection via intersect: » _intersect(op(M» {3} 346 A. Solutions to Exercises

Exercise 4.22: The function combinat: : subsets (M, k) returns a list of all subsets with k elements of a set M: »M := {i $ i = 5 .. 20}: » subsets := combinat: :subsets(M, 3):

The number of such subsets is: » nops(subsets) 560

The function combinat:: subsets: : count returns the number of subsets without (expansively) generating them first:

» combinat::subsets::count(M, 3) 560

Exercise 4.23: » telephoneDirectory := table(Ford = 1815, Reagan = 4711, Bush = 1234, Clinton = 5678): An indexed call returns Ford's number: » telephoneDirectory[Ford] 1815

You can use select to extract all table entries containing the number 5678: » select(telephoneDirectory, has, 5678)

[Clinton = 5678

Exercise 4.24: The command [op (Table)] returns a list of all assignment equations. The call map(', op, i) (i = 1,2) extracts the left and the right hand sides, respectively, of the equations:

» T := table(a = 1, b = 2, 1 - sin(x) = "derivative of x + cos(x)" ): » indices := map([op(T)], op, 1) [a,b, 1- sin (x)] » values := map([op(T)], op, 2) [1,2, "derivative of x + cos(x)'] A. Solutions to Exercises 347

Exercise 4.25: The following timings (in milliseconds) show that generating a table is more time consuming: » n := 100000: » time«T := table( (i=i) $ i=l .. n))), time«L := [i $ i=l .. n])) 3750, 820

However, working with tables is notably faster. The following assignments create an additional table entry and extend the list by one element, respect• ively:

» time«T[n + 1] := New)), time«L := L. [New])) 10, 140

Exercise 4.26: We use the sequence generator $ to create a nested list and pass it to array:

» n := 20: array(1. .n, 1. .n, [[l/(i + j - 1) $ j 1. .n] $ i 1. .n]):

Exercise 4.27: » TRUE and (FALSE or not (FALSE or not FALSE)) FALSE

Exercise 4.28: We use the function zip to generate a list of comparisons. We pass the system function _less as third argument, which generates in• equalities of the form a < b. Then we extract the sequence of inequalities via op and pass it to _and:

» Ll := [10*i~2 - i~3 $ i = 1 .. 10]: » L2 := [i~3 + 13*i $ i = 1 .. 10]: » _and(op(zip(Ll, L2, _less))) 9 < 14 and 32 < 34 and 63 < 66 and 96 < 116 and

125 < 190 and 144 < 294 and 147 < 434 and

128 < 616 and 81 < 846 and 0 < 1130

Finally, evaluating this expression with bool answers the question: 348 A. Solutions to Exercises

» boolC%) TRUE

Exercise 4.29: The function sort does not sort the identifiers alphabetically by their names but according to an internal order (Section 4.6). Thus, we convert them to strings via expr2text before sorting: » map (anames (All) , expr2text) ["Ax", "Axiom", "AxiomConstructor", "C_", "Cat",

"Category", ... , "zeta", "zip"]

Exercise 4.30: We compute the reflection of the palindrome » text := "Never odd or even": by passing the reflected sequence of individual characters to the function _concat, which converts it to a string again: » n := length(text): _concat(text[n - i + 1] $ i 1 .. n) 'neve ro ddo reveN'

This can also be achieved with the call revert (text) .

Exercise 4.31:

» f := x -> (x~2): g := x -> (sqrt(x): » (f~fGg)(2), (f~~100)(x) 4, X1267650600228229401496703205376

Exercise 4.32: The following function does the job:

» f := L -> [L[nops(L) + 1 - i] $ i 1 .. nops(L)] L -> [L[(nops(L) + 1) - i] $ i = 1 .. nops(L)]

» f([a, b, c]) [e, b, a)

However, the simplest solution is to use f :=revert. A. Solutions to Exercises 349

Exercise 4.33: You can use the function last (Chapter 12) to generate the Chebyshev polynomials as expressions:

» TO := 1: T1 := x: » T2 := 2*x*% - %2; T3:= 2*x*% - %2; T4:= 2*x*% - %2 2x2 -1

2x(2x2-1)-x

1 - 2 x2 - 2 x (x - 2 x (2 x2 - 1))

A much more elegant way is to translate the recursive definition into a MuPAD function that works recursively:

» T := (k, x) -> (if k < 2 then xAk else 2*x*T(k - 1, x) - T(k - 2, x) end_if) :

Then we obtain: » T(i, 1/3) $ i = 2 .. 5 -7 -23 17 241 9' --:n-' 81' 243 » T(i, 0.33) $ i = 2 .. 5 -0.7822, -0.846252, 0.22367368, 0.9938766288 »T(i, x) $ i 2 .. 5 2 2 2 x - 1, 2 x (2 x - 1) - x,

2 2 1 - 2 x - 2 x (x - 2 x (2 x - 1)), x -

2 2 2 x (2 x - 1) - 2 x (2 x (x - 2 x (2 x - 1)) +

2 2 x - 1)

You can obtain expanded representations of the polynomials by inserting a call to expand (Section 9.1) in the function definition. The Chebyshev polynomials are already implemented in orthpoly, the library for ortho• gonal polynomials. The i-th Chebyshev polynomial is returned by the call orthpoly: :chebyshev1(i, x). 350 A. Solutions to Exercises

Exercise 4.34: In principle, you can compute the derivatives of fin MuPAD and substitute x = O. But it is simpler to approximate the function by a Taylor series whose leading terms describe the behavior in the neighborhood of x = 0: » taylor(tan(sin(x)) - sin(tan(x)), x = 0, 8)

x7 29 x9 1913 XlI 95 x I3 I5 30 + 756 + 75600 + 7392 + 0 (X )

Thus, f(x) = x 7 /30· (1 + 0(x2 )), and hence f has a root of order 7 at x = o.

Exercise 4.35: The reason for the difference between the results » taylor(diff(l/(l - x), x), x); diff(taylor(l/(l - x), x), x)

1 + 2 x + 3 x 2 + 4 x 3 + 5 x4 + 6 x 5 + 0 (x6 )

1 + 2 x + 3 x 2 + 4 x 3 + 5 X4 + 0 (x5 )

is the truncation determined by the environment variable ORDER with the default value 6. Both taylor calls compute the corresponding series up to 0(x6 ):

» taylor(l/(l - x), x)

1 + x + x 2 + x 3 + X4 + x 5 + 0 (x6 )

The order term O(x-5) appears when the term O(x-6) is differentiated: » diff (%, x) 1 + 2 x + 3 x 2 + 4 x3 + 5 X4 + 0 (x5)

Exercise 4.36: An asymptotic expansion yields:

» f := sqrt(x + 1) - sqrt(x - 1): » g := series(f, x = infinity)

-+--+1 1 7 +0 ( -- 1 ) Fx SqX5 12S~ ~

Thus + ... ) , A. Solutions to Exercises 351 and hence f(x) ~ 1/ Vx for all real x» 1. The next better approximation is f (x) ~ ~ ( 1 + 8 ~2 ).

Exercise 4.37: The command ?revert requests the corresponding help page.

» f := taylor(sin(x + xft 3), x); g := revert(%)

5x3 59x5 7 X + 6 - 120 + 0 (x )

5 x 3 103 x 5 0 ( 7) x- 6 +--:w-+ x

To check this result, we consider the composition of f and g, whose series expansion is that of the identity function x f---t x:

Exercise 4.38: We perform the computation over the standard coefficient ring (Section 4.15.1), which comprises both rational numbers and floating• point numbers:

» n := 16: » H := matrix(n, n, (i, j) -> «i + j -1)~(-1))): » e := matrix(n, 1, 1): b ;= H*e:

We first compute the solution of the system of equations H x = b with exact arithmetic over the rational numbers. Then we convert all entries of Hand b to floating-point numbers and solve the system numerically (and in the instable and slow way, using an explicit inverse instead of calling numeric: :matlinsolve):

» exact = H~(-1)*b, numerical = float(H)~(-1)*float(b)

1 0.999999993 1 1.000000164

exact = , numerical = 1 -11.875 1 4.036132812 1 0.3975830078 352 A. Solutions to Exercises

The errors in the numerical solution originate from rounding errors. To demonstrate this, we repeat the numerical computation with higher preci• sion:

» DIGITS := 20: » numerical = float(H)~(-l)*float(b) 1.0000000505004147319 0.99999992752642441474

numerical = 0.99999889731407165527 1.0000003278255462646 0.9999999580904841423

Exercise 4.39: We look for values where the determinant of the matrix vanishes:

» matrix([[1, a, b], [1, 1, C ], [1, 1, 1]]): » factor(linalg::det(%» (c-1)·(a-1)

The matrix is invertible unless a = 1 or c = 1.

Exercise 4.40: We first store the matrix data in arrays. These arrays are used later to generate matrices over different coefficient rings:

» a := array(1 .. 3, 1 .. 3, [[ 1, 3, 0], [-1, 2, 7], [ 0, 8, 1]]): » b := array(1 .. 3, 1 .. 2, [[7, -1], [2, 3], [0, 1]]):

To simplify the following function calls we export the library Dom:

» export(Dom):

Now we define the constructor MQ for matrices over the rational numbers and convert the arrays to corresponding matrices:

» MQ := Matrix(Rational): A := MQ(a): B := MQ(b):

The method "transpose" of the constructor computes the transpose of a matrix B via MQ: : transpose (B): A. Solutions to Exercises 353

» (2*A + B*MQ::transpose(B))A(-1)

188534 15087 -153)7540 ( 11 -31 893 3770 3016 15080 -47 201 -731 3770 3016 15080

Computing over the residue class ring modulo 7 we find: » Mmod7 := MatrixClntegerMod(7)): » A := Mmod7(a): B := Mmod7(b): » C := (2*A + B*Mmod7: :transpose(B)): CA(-1)

3 mod 7 0 mod 7 1 mod 7 ) ( 1 mod 7 3 mod 7 2 mod 7 4 mod 7 2 mod 7 2 mod 7

We check this by multiplying the inverse by the original matrix, which yields the identity matrix over the coefficient ring:

1 mod 7 0 mod 7 Omod7 ) ( Omod7 Imod7 Omod7 omod 7 Omod 7 Imod7

Exercise 4.41: We compute over the coefficient ring of rational numbers: »MQ := Dom::Matrix(Dom: :Rational):

We consider 3 x 3 matrices. To define the matrix, we pass a function to the constructor that maps the indices to the corresponding matrix entries:

» A := MQ(3, 3, (i, j) -> Cif i=j then 0 else 1 end_if)) (:~D The determinant of A is » linalg::det(A) 2 The eigenvalues are the roots of the characteristic polynomial: 354 A. Solutions to Exercises

»p := linalg::charpoly(A, x)

x 3 - 3x - 2 » solve(p, x) {-1,2}

Alternatively, the linalg package provides a function for computing eigen• values: » linalg::eigenvalues(A) {-1,2}

Let I d denote the 3 x 3 identity matrix. The eigenspace for the eigenvalue A E { -1, 2} is the solution space of the system of linear equations (A - A' I d) x = O. The solution vectors span the nullspace (the "kernel") of the matrix A - A' I d. The function linalg: : nullspace computes a basis for the kernel of a matrix:

» Id := MQ::identity(3): » lambda := -1: linalg: :nullspace(A - lambda*Id)

There are two linearly independent basis vectors. Hence the eigenspace for the eigenvalue A = -1 is two-dimensional. The other eigenvalue is simple:

» lambda := 2: linalg: :nullspace(A - lambda*Id) [(:) 1

Alternatively, linalg:: eigenvectors computes all eigenspaces simultan• eously:

» linalg::eigenvectors(A) [[-1,2, [( ~1 ) ,( ~1 )11 ' [2,1, [( : )111 A. Solutions to Exercises 355

The return value is a nested list. For each eigenvalue A, it contains a list of the form [ A, multiplicity of A, eigenspace basis ].

Exercise 4.42:

» p := poly(xA7 - xA4 + xA3 - 1): q := poly(xA3 - 1): » p _ qA2

poly (x7 - x6 - x4 + 3x3 - 2, [xl)

The polynomial p is a multiple of q: » p/q poly (x4 + 1, [xl)

This is confirmed by a factorization: » factor(p) poly (x - 1, [xl) . poly (x2 + x + 1, [xl) . poly (X4 + 1, [xl) » factor(q) poly (x - 1, [xl) . poly (x2 + x + 1, [xl)

Exercise 4.43: We use the identifier R to abbreviate the lengthy type name Dom: : IntegerMod(3). With alias, MuPAD also uses R as an alias in the output of the following polynomials.

»p := 3: alias(R = Dom::lntegerMod(p)):

We only need to try the possible remainders 0,1, 2 modulo 3 for the coeffi• cients a, b, c in a x 2 +b x+c. We generate a list of all 18 quadratic polynomials with a i= 0 as follows:

» [«poly(a*xA2 + b*x + c, [x], R) $ a = 1 .. p-l) $ b = O.. p-l) $ c = O.. p-l] : The command select (., irreducible) extracts the 6 irreducible polyno• mials: 356 A. Solutions to Exercises

» select(%, irreducible) 2 2 [poly(x + 1, [x], R), poly(2 x + x + 1, [x], R),

2 poly(2 x + 2 x + 1, [x], R),

2 2 poly(2 x + 2, [x], R), poly(x + x + 2, [x], R),

2 poly(x + 2 x + 2, [x], R)]

Exercise 5.1: The value of x is the identifier a1. The evaluation of x yields the identifier c1. The value of y is the identifier b2. The evaluation of y yields the identifier c2. The value of z is the identifier a3. The evaluation of z yields 10.

The evaluation of ulleads to an infinite recursion, which MuPAD aborts with an error message. The evaluation of u2 yields the expression v2~2 - 1.

Exercise 6.1: The result of subsop(b+a, l=c) is b+c and not c+a, as you might have expected. The reason is that subsop evaluates its arguments. The system reorders the sum internally when evaluating it, and thus subsop processes a + b instead of b + a. Upon return, the result c + b is reordered again.

Exercise 6.2: The highest derivative occurring in g is the 6-th derivative diff (f (x) , x $ 6). We pass the sequence of replacement equations:

diff(f(x), x $ 6) = f6, diff(f(x) , x $ 5) = f5, ... , diff(f(x) , x) = fl, f(x) = fO to MuPAD's substitution function. Note that, in accordance with the usual mathematical notation, diff returns the function itself as the O-th derivative: diff (f(x) , x $ 0) = diff(f(x» = f(x). A. Solutions to Exercises 357

» delete f: g := diff(f(x)/diff(f(x) , x), x $ 5): » subs(g, (diff(f(x) , x $ 6 - i) = f.(6-i» $ i = O.. 6) 4 2 60 f2 4 f5 20 f3 fO f6 25 f2 f4 ------+ ------+ ------4 fl 2 2 2 fl fl fl fl

5 2 120 fO f2 100 f2 f3 10 fO f2 f5 ------+ ------+ 6 3 3 fl f1 f1

2 3 20 fO f3 f4 90 fO f2 f3 240 fO f2 f3 ------+ 3 4 5 fl fl fl

2 60 fO f2 f4

4 fl

Exercise 7.1: The following commands yield the desired evaluation of the function:

» f := sin(x)/x: x := 1.23: f 0.7662510585

However, x now has a value. The following call diff (f, x) would intern• ally lead to the command diff (0.7662510584, 1. 23), since diff evaluates its arguments. You can circumvent this problem by preventing a complete evaluation of the arguments via level or hold (Section 5.2):

» g := diff(level(f, 1), hold(x»; g cos (x) sin (x) -----

-0.3512303507

Here the evaluation of hold (x) is the identifier x and not its value. Writing hold(f) instead of level(f, 1) would yield the wrong result diff (hold(f) , hold(x»=0 since hold(f) does not contain hold(x). Using level(f, 1) 358 A. Solutions to Exercises replaces f by its value sin(x)/x (Section 5.2). The next call of g returns the evaluation of g, namely the value of the derivative at x = 1.23. Alternatively you can delete the value of x:

» delete x: diff(f, x): subs(%, x = 1.23); eval(%) 0.8130081301 cos (1.23) - 0.6609822196 sin (1.23)

-0.3512303507

Exercise 7.2: The first three derivatives of the numerator and the denom• inator vanish at the point x = 0:

» Z := x -> (x-3*sin(x»: N := x -> «1 - cos(x»-2): » Z(O), N(O), Z'(O), N'(O), Z"(O), N"(O), Z"'(O), N"'(O) 0, 0, 0, 0, 0, 0, 0, 0

For the fourth derivatives, we have:

»Z""(O), N""(O) 24,6

Thus the limit is Z""(O)jN""(O) = 4, according to de I'Hospital's rule. The function limit computes the same result: » limit(Z(x)/N(x), x = 0) 4

Exercise 7.3: The first order partial derivatives of II are:

» fl := sin(xl*x2): diff(fl, xl), diff(fl, x2) x2 cos (xl x2) , xl cos (xl x2)

The second order derivatives are: » diff(fl, xl, xl), diff(fl, xl, x2), diff(fl, x2, xl), diff(fl, x2, x2) 2 - x2 sin(xl x2), cos (xl x2) - xl x2 sin(xl x2),

2 cos (xl x2) - xl x2 sin(xl x2), - xl sin(xl x2) A. Solutions to Exercises 359

The total derivative of 12 with respect to tis: » f2 := x-2*y-2: x := sin(t): y := cos(t): diff(f2, t) 2 cos {t)3 sin (t) - 2 cos (t) sin (t)3

Exercise 7.4: » int(sin(x)*cos(x), x = O.. PI/2), int(1/(sqrt(1 - x-2», x = 0 .. 1), int(x*arctan(x), x = o.. 1), int(l/x, x = -2 .. -1) 1 7r 7r 1 2' 2' 4 - 2' -In(2)

Exercise 7.5:

x a.J2ax - x2 » int(sqrt(x-2 - a-2), x) xvx2 -a2 a2 ln(x+.Jx2-a2) 2 2 » int(1/(x*sqrt(1 + x-2», x)

- arctanh (~) x 2 + 1

Exercise 7.6: The function intlib: : changevar only performs a change of variables without invoking the integration:

» intlib: :changevar(hold(int) (sin(x)*sqrt(1 + sin(x», x = -PI/2 .. PI/2), t = sin(x»

1 tv't+1 dt / -1 v'f=t2 A further evaluation activates the integration routine: » eval(%): % = float(%)

2.j23 -_ 09428090416 . 360 A. Solutions to Exercises

Numerical quadrature returns the same result:

» numerie::int(sin(x)*sqrt(l + sin(x», x = -PI/2 .. PI/2) 0.9428090416

Exercise 8.1: The equation solver returns the general solution:

» equations := {a + b + e + d + e =: 1, a + 2*b + 3*e + 4*d + 5*e = 2, a - 2*b - 3*e - 4*d - 5*e = 2, a - b - e - d - e =: 3}: » solve (equations, {a, b, e, d, e}) {[a = 2, b = d + 2 e - 3, c = 2 - 3 e - 2 d]}

The free parameters are on the right hand sides of the solved equations. You can determine them in MuPAD by extracting the right hand sides and using indets to find the identifiers contained therein: » map(%, map, op, 2); indets(%) {[2,d+ 2e - 3,2 - 3e - 2d]}

{d,e}

Exercise 8.2: The symbolic solution is:

» solution := solve(ode( {y'(x) = y(x) + 2*z(x) , z'(x) = y(x)}, {y(x), z(x)}»

{[z(x)= C2tx -C1e-X ,y(x)=C1e-X +C2e2X]} with free constants C1, C2. We remove the outer curly braces via op:

» solution := op(solution) C2e2x ] [ z(x) = -2- -C1e-X ,y(x) = C1e-x +C2e2x

Now, we set x = 0 and substitute yCO) and zCO), respectively, for the initial conditions. Then, we solve the resulting linear system of equations for C1 and C2: A. Solutions to Exercises 361

» solve (subs (solution, x = 0, yeO) = 1, z(O) = 1), {Cl, C2}) {[C1= ~1,C2=~]}

Again, we remove the outer curly braces via op and assign the solution values to Cl and C2 by means of assign:

» assign(op(%)):

Thus, the value at x = 1 of the symbolic solution for the above initial condi• tions is:

» x := 1: solution

e-l 2e2 4e2 e-1 ] [ z(l) = 3 + 3,y(1) = 3 - 3

Finally, we apply float: » float(%) [z (1) = 5.04866388, y (1) = 9.729448318]

Exercise 8.3: 1) »solve(ode(y'(x)/y(x)-2 = l/x, y(x)))

{C2 _lin (x) } 2a) » solve(ode({y'(x) - sin(x)*y(x) = 0, D(y)(l)=l}, y(x)))

ecos(l) } { sin (1) eCos(x) 2b) » solve (ode ({2*y' (x) + y(x)/x = 0, D(y)(l) = PI}, y(x))) {- ~} 362 A. Solutions to Exercises

3) » solve(ode({diff(x(t),t) = -3*y(t)*z(t), diff(y(t),t) = 3*x(t)*z(t), diff(z(t),t) = -x(t)*y(t)}, {x(t),y(t),z(t)}» 2 1/2 {[x(t) (3 z(t) - CS)

2 1/2 yet) = - (- C7 - 3 z(t» ] ,

2 1/2 [x(t) = - (3 z(t) - CS)

2 1/2 yet) = (- C7 - 3 z(t» ],

2 1/2 [x(t) = - (3 z(t) - CS)

2 1/2 yet) = - (- C7 - 3 z(t» ],

2 1/2 [x(t) (3 z(t) - CS)

2 1/2 yet) = (- C7 - 3 z(t» ]}

Exercise 8.4: The function solve directly yields the solution of the recur• rence: » solve(rec(F(n) = F(n-1) + F(n-2), F(n), {F(O) = 0, F(1) = 1}» { V5 (~+ !)" _V5 (!: 4)"}

Exercise 9.1: You obtain the answer immediately from:

» simplify(cos(x)-2 + sin(x)*cos(x» cos (2x) sin (2x) 1 2 + 2 +"2

You get the same result by applying combine to rewrite products of trigono• metric functions as sums: A. Solutions to Exercises 363

» combine(cos(x)~2 + sin(x)*cos(x) , sincos) cos (2x) sin (2x) 1 2 + 2 + 2

Exercise 9.2:

1> expand(cos(5*x)/(sin(2*x)*cos(x)~2)) cos (X)2 5' () 5 sin (x)3 . ()- smx+ 2 2 sm x 2 cos (x)

2> f := (sin(x)~2 - exp(2*x)) / (sin(x)~2 + 2*sin(x)*exp(x) + exp(2*x)): » normal(expand(f)) eX - sin (x) eX + sin (x)

3> f := (sin(2*x) - 5*sin(x)*cos(x)) / (sin(x)*(l + tan(x)~2)): » combine(normal(expand(f)), sincos) 3 cos (x) tan (X)2 + 1

4> f := sqrt(14 + 3*sqrt(3 + 2*sqrt(5 - 12*sqrt(3 - 2*sqrt(2))))): » simplify(f, sqrt) V2+3

Exercise 9.3: As a first step, we perform a normalization:

» int(sqrt(sin(x) + 1), x): normal(diff(%, x)) 3 cos (x)2 sin (x) - 2 sin (x) + cos (x)2 + 2 sin (x)3 COS(X)2 vsin(x) + 1

Then we eliminate the cosine terms: » rewrite(%, sin)

2 sin (x) + 3 sin (x) (sin (X)2 - 1) + sin (X)2 - 2 sin (x)3 - 1

(sin(x)2-1) vsin(x) +1 364 A. Solutions to J::;xercises

The final normalization step achieves the desired simplification:

» normal(%)

Jsin (x) + 1

On the other hand, calling Simplify is much easier:

» int(sqrt(sin(x) + 1), x): Simplify(diff(%, x» Jsin(x) + 1

Exercise 9.5: The function assume (Section 9.3) assigns properties to iden- tifiers. These are taken into account by limit:

» assume(a > 0) : limit(x~a, x = infinity) 00 » assume(a = 0) : limit(x~a, x = infinity) 1 » assume(a < 0): limit(x~a, x = infinity) 0

Exercise 10.1: In analogy to the previous gcd example, we obtain the following experiment:

» die := random(1 .. 6): » experiment := [[die(), die(), die()] $ i = 1 .. 216]: » diceScores := map(experiment, x -> (x[1] + x[2] + x[3]»: » frequencies := Dom::Multiset(op(diceScores»: » sortingOrder := (x, y) -> (x[1] < y[1]): » sort([op(frequencies)], sortingOrder) [[4, 4], [5, 9], [6, 8], [7, 9], [8, 16], [9, 20],

[10, 27], [11, 31], [12, 32], [13, 20], (14, 13],

[15, 12], [16, 6], [17, 7], [18, 2]]

In this experiment, the score 3 did not occur.

Exercise 10.2: a) The command

» r := float~random(0 .. 10~10)/10~10: A. Solutions to Exercises 365 creates a generator for random floating-point numbers in the interval [0,1]. Alternatively, one may also use the (faster) generator frandom. The call

» n := 1000: absValues := [sqrt(r()~2+r()~2) $ i = 1 .. n]: returns a list with the absolute values of n random vectors in the rectangle Q = [0,1] x [0,1]. The number of values ~ 1 is the number of random points in the right upper quadrant of the unit circle:

» m := nops(select(absValues, z -> (z <= 1») 787

Since min approximates the area 1f / 4 of the right upper quadrant of the unit circle, we obtain the following approximation to 1f:

» float(4*m/n) 3.148 b) First we determine the maximum of f. The following function plot shows that f is monotonically increasing on the interval [0, 1]:

» f := x -> x*sin(x) + cos(x)*exp(x): plotfunc2d(f(x) , x = O.. 1):

y

2.2

2.0

1.8

1.6

1.4

1.2

1.0 ~-+--+---<-+--+---<-+--+---+--+---+-~-- 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 x

Thus f(x) assumes its maximal value at the right end of the interval. There• fore, M = f(1) is an upper bound for the function:

» M := f(1.0) 2.310164925

We use the random number generator defined above to generate random points in the rectangle [0, 1] x [0 , M] :

» n := 1000: pointlist := [Ere), M*r()] $ i 1. .n] : 366 A. Solutions to Exercises

We select those points p = [x, y] for which 0 ::; y ::; f(x) holds: » select(pointlist, p -> (p[2] <= f(p[l]»): » m := nops(%) 740 Thus the following is an approximation of the integral:

1. 709522044 The exact value is: » float(int(f(x) , x = 0 .. 1» 1.679193292

Exercise 14.1: With the following definition of the postOutput method of Pref, the system prints an additional status line: » Pref::postOutput( proc() begin "bytes: " expr2text(op(bytes(), 1» " (logical) / " expr2text(op(bytes(), 2» " (physical)" end_proc): » DIGITS := 10: float(sum(l/i!, i o . .100» 2.718281828 bytes: 836918 (logical) / 1005938 (physical)

Exercise 15.1: We first generate the set S:

» f := i -> ( (i A (5/2)+i A 2-i A (1/2)-1) / (i A (S/2)+i A 2+2*i A (3/2)+2*i+i A (1/2)+1) ) : » S := {f(i) $ i=-1000 .. -2} union {f(i) $ i=0 .. 1000}: Then we apply domtype to all elements of the set to determine their domain types: » mapeS, domtype) {DOM_EXPR, DOM_INT, DOM_RAT} A. Solutions to Exercises 367

You see the explanation for this result by looking at some elements: » f(-2), f(O), f(l), f(2), f(3), f(4) 3iv'2+3 -1 ° 3v'2+3 8V3+8 ~ i v'2 + l' "9 v'2 + 9' 16 V3 + 16' 5

The function normal simplifies the expressions containing square roots: » map(%, normal) 113 3, -1, 0, 3' 2' 5

Now we apply normal to all elements of the set before querying their data type:

» map(S, domtype~normal) {DOM_INT, DOM_RAT}

Thus, all numbers in S are indeed rational (in particular there are two integer values f (0) = -1 and f (1) = 0). The reason is that f (i) can be simplified to (i-i)/(i+i):

» normal(f(i) - (i - l)/(i + 1)) o

Exercise 15.2: We apply testtype(·, "sin") to each element of the list:

» list := [sin(i*PI/200) $ i = O.. 100]: to find out whether it is returned in the form sin (.). The following split command (Section 4.7) decomposes the list accordingly:

» decomposition := split(list, testtype, "sin"): 368 A. Solutions to Exercises

MuPAD simplified 9 of the 101 calls: » map(decomposition, nops); decomposition[2] [92, 9, 0]

1/2 1/2 1/2 1/2 1/2 1/2 5 (2 - 2 ) 2 (5 - 5 ) 0, - 1/4, ------4 2 4

1/2 1/2 1/2 1/2 2 5 (2 + 2) + 1/4, ------2 4 2

1/2 1/2 1/2 2 (5 + 5) ------1 4

Exercise 15.3: You can use select (Section 4.7) to extract those elements that testtype identifies as positive integers. For example:

» set := {-5, 2.3, 2, x, 1/3, 4}: » select(set, testtype, Type::Poslnt) {2,4}

Note that this selects only those objects that are positive integers, but not those that might represent positive integers, such as the identifier x in the above example. This is not possible with testtype. Instead, you can use assume to set this property and query it via is: » assume(x, Type::Poslnt): » select(set, is, Type::Poslnt) {2,4,x} A. Solutions to Exercises 369

Exercise 15.4: We construct the desired type specifier and employ it as follows:

» T := Type: :ListOf(Type::ListOf( Type: : AnyType , 3, 3), 2, 2) Type::ListOf (Type::ListOf (Type::AnyType, 3, 3) ,2,2) »testtype([[a, b, c], [1,2,3]], T), testtype([[a, b, c], [1, 2]], T) TRUE, FALSE

Exercise 17.1: Consider the conditions x <> 1 and A and x = 1 or A, re• spectively. After entering:

» x := 1: it is not possible to evaluate them due to the singularity in x/(x - 1):

» x <> 1 and A Error: Division by zero [_power]

» x = 1 or A Error: Division by zero [_power]

However, this is not a problem within an if statement since the Boolean evaluation of x <> 1 and x = 1 already tells us that x <> 1 and A evaluates to FALSE and x = 1 or A to TRUE , respectively: » (if x <> 1 and A then right else wrong end_if), (if x = 1 or A then right else wrong end_if) wrong, right

On the other hand, evaluation of the following if statement still produces an error, since it is necessary to evaluate A in order to determine the truth value of x = 1 and A: » if x = 1 and A then right else wrong end_if Error: Division by zero [_power] 370 A. Solutions to Exercises

Exercise 18.1: With the formulas given, implementation of the "float" slots is straightforward:

» ellipticE: : float := z -> float(PI/2) * hypergeom::float([-1/2, 1/2], [1], z): ellipticK::float := z -> float(PI/2) * hypergeom: :float([1/2, 1/2], [1], z):

This is almost sufficient: » ellipticE(1/3)

» float(%) 1.430315257

However, one thing is missing: We would like to have calls with floating point arguments evaluated immediately: » ellipticE(O.l) E (0.1)

To this end, we must extend the definitions of ellipticE and ellipticK:

» ellipticE : = proc(x) begin if domtype(x) = DOM_FLOAT or domtype(x) = DOM_COMPLEX and (domtype(Re(x)) = DOM_FLOAT or domtype(Im(x)) = DOM_FLOAT) then return(ellipticE::float(x)); end_if; if x = 0 then PI/2 elif x = 1 then 1 else procname(x) end_if end_proc:

Extend ellipticK analogously, then make these new functions into function environments (the above definition replaced the old one completely) and add the function slots we used for the original definitions and the new float slots, and you get: » ellipticE(O.l) 1.530757637 A. Solutions to Exercises 371

Exercise 18.2: The following procedure evaluates the Abs function: » Abs := proc(x) begin if domtype(x) = DOM_INT or domtype(x) = DOM_RAT or domtype(x) = DOM_FLOAT then if x >= 0 then x else -x end_if; else procname(x); end_if end_proc:

We convert Abs to a function environment and supply a function producing the desired the screen output:

» Abs := funcenv(Abs, proc(f) begin "I" . expr2text(op(f)) . "I" end_proc, NIL):

Then we set the function attribute for differentiation:

» Abs::diff := proc(f,x) begin f/op(f)*diff(op(f), x) end_proc:

Now we have the following behavior:

» Abs(-23.4), Abs(x) , Abs(x-2 + y - z) 23.4, lxi, Iy - z + x-21 The diff attribute of the system function abs yields a slightly different but equivalent result: » diff(Abs(x-3), x), diff(abs(x-3), x) 3 Ix-31 2 ------, 3 Ixl sign(x) x

Exercise 18.3: We use expr2text (Section 4.11) to convert the integers passed as arguments to strings. Then we combine them, together with some slashes, via the concatenation operator ".": » date := proc(month, day, year) begin print (Unquoted, expr2text(month) . "/" expr2text(day) . "/" . expr2text(year)) 372 A. Solutions to Exercises

Exercise 18.4: We present a solution using a while loop. The condition x mod 2 = 0 checks whether x is even:

» f := proe(x) loeal i: begin i := 0: userinfo(2, "term" . expr2text(i) It. tI expr2text(x»; while x <> 1 do if x mod 2 = 0 then x := x/2 else x := 3*x+1 end_if; i := i + 1: userinfo(2, "term " . expr2text(i) II. II expr2text(x» end_while; i end_proe: » f(4), f(1234), f(56789) , f(123456789) 2, 132, 60, 177

If we set setuserinfo(f, 2) (Section 14.2), then the userinfo command outputs all terms of the sequence until the procedure terminates: » setuserinfo(f, 2): f(4) Info: term 0: 4 Info: term 1: 2 Info: term 2: 1

2 If you do not believe in the 3 x + 1 conjecture, you should insert a stopping condition for the index i to ensure termination.

Exercise 18.5: A recursive implementation based on the relation gcd(a, b) = gcd(a mod b, b) leads to an infinite recursion: we have a mod b E {O, 1, ... , b- 1 }, and hence (a mod b) mod b = a mod b in the next step. Thus the function gcd would always call itself recurs• ively with the same arguments. However, a recursive call of the form gcd(a, b) = gcd(b, a mod b) make sense. Since a mod b < b, the function calls itself recursively for decreasing values of the second argument, which finally becomes zero: A. Solutions to Exercises 373

» Gcd := procCa, b) begin /* recursive variant */ if b = 0 then a else Gcd(b, a mod b) end_if end_proc:

For large values of a and b, you may need to increase the value of the en• vironment variable MAXDEPTH if Gcd exhausts the valid recursion depth. The following iterative variant avoids this problem:

» GCD := procCa, b) local c; /* iterative variant */ begin while b <> 0 do c := a; a := b; b := c mod b end_while; a end_proc:

These implementations yields the same results as the functions igcd and gcd provided by the system:

» a := 123456: b := 102880: » Gcd(a, b), GCD(a, b), igcd(a, b), gcd(a, b) 20576, 20576, 20576, 20576

Exercise 18.6: In the following implementation, we generate a shortened copy Y = [Xl) ... ) xn] of X = [xo ) ... ) Xn] and compute the list of differences [Xl - Xo ,···, Xn - xn- d via zip and _subtract Csubtract (y ,x) = y - x). Then we multiply each element of this list with the corresponding numeri• cal value in the list [J (xo), f (Xl), . .. ]. Finally, the function _pI us adds all elements of the resulting list:

» Quadrature := proc(f, X) local Y, distances, numericalValues, products; begin Y := X; delete Y[l] ; distances := zip(Y, X, _subtract); numericalValues := map(X, float~f); products := zip(distances, numericalValues, _mult); _plus(op(products)) end_proc: 374 A. Solutions to Exercises

In the following example, we use n = 1000 equidistant sample points in the interval [0,1]:

» f := x -> (x*exp(x)): n := 1000: » Quadrature(f, [i/n $ i = O.. n]) 0.9986412288

This is a (crude) numerical approximation of fa1 x eX dx (= 1).

Exercise 18.7: The specification of Newton requires that the first argu• ment f be an expression and not a MuPAD function. Thus, to compute the derivative, we first use indets to determine the unknown in f. We substi• tute a numerical value for the unknown to evaluate the iteration function F(x) = x - f(x)/ f'(x) at a point: » Newton := proc(f, xO, n) local vars, x, F, sequence, i; begin vars := indets(float(f»: if nops(vars) <> 1 then error( "the function must contain exactly one unknown" ) else x := op(vars) end_if; F := x - f/diff(f,x); sequence := xO; for i from 1 to n do xO := float(subs(F, x = xO»; sequence := sequence, xO end_for; return (sequence) end_proc:

In the following example, Newton computes the first terms of a sequence rapidly converging to the solution )2:

» Newton(x A 2 - 2, 1, 6) 1, 1.5, 1.416666667, 1.414215686, 1.414213562,

1.414213562, 1.414213562 A. Solutions to Exercises 375

Exercise 18.8: The call numlib: : g_adic( .. ,2) yields the binary expansion of an integer as a list of bits: » numlib: :g_adic(7, 2), numlib: :g_adic(16, 2) [1,1,1], [0,0,0,0,1]

Instead of calling numlib: : g_adic directly, our solution uses a subprocedure binary furnished with the option remember. This accelerates the computa• tion notably since numlib: : g_adic is called frequently with the same argu• ments. The call isSPoint ( [x, y]) returns TRUE when the point specified by the list [x, y] is a Sierpinski point. To check this, the function multiplies the lists with the bits of the two coordinates. At those positions where both x and y have a 1 bit, multiplication yields a 1. In all other cases, 0·0, 1· 0, 0·1, produce the result O. If the list of products contains at least one 1, the point is a Sierpinski point. We use select (Section 4.6) to extract the Sierpinski points from all points considered. Finally, we create a plot: : PointList2d with these points and call plot (Section 11):

» Sierpinski := proc(xmax, ymax) local binary, isSPoint, allPoints, i, j, SPoints; begin binary := proc(x) option remember; begin numlib: :g_adic(x, 2) end_proc; isSPoint := proc(Point) local x, y; begin x := binary(Point[1]); y := binary(Point[2]); has(zip(x, y, _mult), 1) end_proc; allPoints := [([i, j] $ i = 1 .. xmax) $ j = 1 .. ymax]; SPoints := select (allPoints , isSPoint); plot(plot: :PointList2d(SPoints, Color = RGB::Black»; end_proc: 376 A. Solutions to Exercises

For xmax = ymax = 100, say, you obtain a quite appealing picture:

» Sierpinski(100, 100)

y 100

90 eo 10 eo

50

<0

30 20

10 20 3() <0 50 eo 10 80 90 100•

Exercise 18.9: We present a recursive solution. Given an expression formula(xl, x2, ... ) with the identifiers xl, x2, ... , we collect the iden• tifiers in the set x = {xl, x2, ... } by means of indets. Then we sub• stitute TRUE and FALSE, respectively, for xl (= op(x,l)), and call the procedure recursively with the arguments formula (TRUE , x2, x3, ... ) and formula (F ALSE, x2, x3, ... ), respectively. In this way, we test all possible combinations of TRUE and FALSE for the identifiers until the expression can finally be simplified to TRUE or FALSE at the bottom of the recursion. This value is returned to the calling procedure. If at least one of the TRUE/FALSE combinations yields TRUE, then the procedure returns TRUE, indicating that the formula is satisfiable, and otherwise it returns FALSE.

» satisfiable := proc(formula) local x; begin x := indets(formula); if x = {} then return(formula) end_if; return (satisfiable (subs (formula, op(x, 1) TRUE) ) or satisfiable (subs (formula, op(x, 1) FALSE))) end_proc:

If the number of identifiers in the input formula is n, then the recursion depth is at most n and the total number of recursive calls of the procedure is at most 2n. We apply this procedure in two examples:

» Fl := «x and y) or (y or z)) and (not x) and y and z: » F2 := «x and y) or (y or z)) and (not y) and (not z): » satisfiable(Fl), satisfiable(not Fl), satisfiable(F2), satisfiable(not F2) TRUE, TRUE, FALSE, TRUE A. Solutions to Exercises 377

The call simplify (. ,logic) (Section 9.2) simplifies logical formulae. For• mula F2 can be simplified to false, no matter what the values of x, y, and z are:

» simplify(Fl, logic), simplify(F2, logic) -,x 1\ y 1\ z, FALSE B. Documentation and References

The central MuPAD web sites, where you find documentation, news, material and background information, are

http://www . mupad. de and http://www.mupad.com.

On a Windows platform, you find a list of all documents that are available in your installation by choosing "Browse Help" from the "Help" menu of the MuPAD window and then clicking on "Contents". Among them are the following documents:

[Oev03] W. OEVEL. MuPAD 3.0 Quick Reference. 2003.

[Dre 02] K. DRESCHER. Axioms, Categories and Domains. Automath Tech• nical Report No.1, 2002.

The MuPAD Quick Reference [Oev03] lists all data types, functions, and libraries of MuPAD version 3.0, and provides a survey of its functionality.

YQU also find links to various libraries such as, for example, Dom (the lib• rary for preinstalled data types). The corresponding documentation [Dre 95] contains a concise description of all domains provided by Dom. In a MuPAD session, the command ?Dom directly opens this document. Moreover, you can access the description of individual data structures from this document, such as Dom: : Matrix, directly through the call ?Dom: : Matrix. Another example is the documentation [Pos 98] for the linalg package (linear algebra). An updated version can be requested directly via ?linalg:

[Dre 95] K. DRESCHER. Domain-Constructors. Automath Technical Report No.2, 1995.

[Pos98] F. POSTEL. The Linear Algebra Package "linalg". Automath Tech• nical Report No.9, 1998. 380 B. Documentation and References

It is not possible to print these documents and help pages from within the help system. However, you can download pdf versions from the above MuPAD web sites. As an introduction to MuPAD Pro, targeted especially at Windows users, we recommend the following book:

[Maj 04] M. MAJEWSKI MuPAD Pro Computing Essentials, Second Edition. Springer Heidelberg, 2004. ISBN 3-540-21943-9

In addition to the MuPAD documentation, we recommend the following books about computer algebra in general and the underlying algorithms:

[Wes99] M. WESTER (ED.), Computer Algebra Systems. A Practical Guide. Wiley, 1999.

[GG99] J . VON ZUR GATHEN AND J. GERHARD, Modern Computer Al• gebra. Cambridge University Press, 1999.

[Hec 93] A. HECK, Introduction to . Springer, 1993.

[DTS93] J.H. DAVENPORT, E. TOURNIER AND Y. SIRET, Computer Al• gebra: Systems and Algorithms for Algebraic Computation. Aca• demic Press, 1993.

[GCL92] K.O. GEDDES , S.R. CZAPOR AND G. LABAHN, Algorithms for Computer Algebra. Kluwer, 1992. c. Graphics Gallery

x

_ l/x'sin(x) _ X'cos(x) _ tan(x)

Fig. 1: Functions

y 0.3

0.2

0.1

0

-0.1

-02

-0.3

Fig. 2: Spline Interpolation 382 C. Graphics Gallery

Trigonometric Functions

The Sine Function I r-- The osine Function y y

0.5 0.5

0 0

X X -0.5 -0.5

-1 II -1 Th e Tangent Fun ction

y 10 Y

5

0

-5

-10 I ill(x)*coS(X) r sin(x) + O. *cos(5*x) - ~ y 1.5 0.4

0.2

0 0.5

- 0.2 o +-----+-----+-~--*--- 2 - 0.4 JU Fig. 3: A Canvas with several Scenes C. Graphics Gallery 383

2 3 4 5 6 7 8 9 10 11 12 13

2

2 7 8 9 10 11 12 13 , L2: ~ r

2

10 11 12 13 I l ~ I l

2

6 7 12 13

2

6 7

Fig. 4: Construction of Cycloids 384 C. Graphics Gallery

Fig. 5: Hatch between Functions

x

Fig. 6: Hatch inside Curves c. Graphics Gallery 385

y 1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2 0 . 1 ~~~::::::~~ 0.5 1.5 2 2 .5 3 3.5 4 X Fig. 7: Statistical Distributions

C.F. Gauss

- 4 -3 -2 -1 o 2 3 4 5 6 7 X Fig. 8: Bitmap Import 386 C. Graphics Gallery

rame 72 rame 23 J

rame 371 F"mo 475 j

Frame 510

Fig. 9: Three Body Problem C. Graphics Gallery 387 y

0.8

0.6

0.4

0.2

0

-0.2

- 0.4

- 0.6

-0.8

Fig. 10: Visualization of a Vector Field y 2.4

2.2

2

1.8

1.6

1.4 1.2

0.8

0.6

0.4 02

O ~~~~~~~~~-+~~~~~~~~--~--~~~.. o 2 3 4 5 6 X Fig. 11: Solutions of a 388 C. Graphics Gallery

Fig. 12: Rotation of a Function

y

0.5

o

- 0.5

- 1

- 2 -1 .5 -1 -0.5 o 0.5 1.5 x

Fig. 13: Mande1brodt Set c. Graphics Gallery 389

y

o 2 3 4 5 6 7 8 9 10 11 12 13 14 X Fig. 14: Visualization of Statistical Data

-1 -0.8 -0.6 - 0.4 - 0.2 o 0.2 0.4 0.6 0.8 X Fig. 15: Conformal Mapping 390 C. Graphics Gallery

y 4

3

2

o

-1

- 4 - 3 - 2 -1 0 2 3 X Fig. 16: Ellipt ic ur e

y

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0 2.8 2.9 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 X

Fig. 17: Feigenbaum Diagram C. Graphics Gallery 391

0.4 0.2 z 20 -0.2 o

20 0

0.2 Z 0 -0.2

20

o 0

Fig. 18: Bessel Functions Gallery C. Graphics 392

-1 2

Grid With Coordinate Fig. 19: Functions C. Graphics Gallery 393

Fig. 20: Klein's Bottle 394 C. Graphics Gallery

Nalalina Turritella

Lyria

Phalllasia

Fig. 21: Snails (Maike Kramer-Jka) c. Graphics Gallery 395

0.6

0.4

0.2

Z 0

0.6

Fig. 22: Surface of Revolution

Fig. 23: Implicit Surface 396 C. Graphics Gallery

z

Fig. 24: Lorenz Attractor D. Comments on the Graphics Gallery

On the color pages of this book you find a gallery of pictures demonstrating the power of the MuPAD graphics. These pictures are discussed at various loc• ations in this book and the online plot documentation, respectively. There, further details including the MuPAD commands for reproducing the pictures can be found.

Figure 1 shows a plot of several functions. Singularities are highlighted by "vertical asymptotes." See page 187 in Section 11.2.1. Figure 2 shows a function plot together with a spline interpolation through a set of sample points. See page 208 in Section 11.3.2. Figure 3 demonstrates some layout possibilities. See the examples on the help page of the graphical attribute Layout in the online plot documentati• on. Figure 4 demonstrates the construction of cycloids via points fixed to a rolling wheel. See page 209 in Section 11.3.2. Figure 5 and Figure 6 demonstrate hatched areas between functions and within closed curves, respectively. See the examples on the help page of plot: : Hatch. Figure 7 shows various statistical distribution functions. Figure 8 shows an imported bitmap inside function plots. See page 260 in Section 11.15. Figure 9 shows some frames of an animation of the perturbed orbit of a small planet kicked out of a solar system by a giant planet after a near• collision. The animation is generated in Section "Animations" / "Examples" of the online plot documentation.

Figure 10 visualizes the vector field v(x,y) = (sin(37ry),sin(37rx)). 398 D. Comments on the Graphics Gallery

Figure 11 shows three solution curves of an ODE inside the directional vector field associated with the ODE. See the examples on the help page of plot: : VectorField2d. Figure 12 shows several rotated copies of a function graph. See the examples on the help page of plot: : Rotate2d. Figure 13 shows the Mandelbrot set together with two blow ups of regions of special interest. See the examples on the help page of plot: :Density. Figure 14 shows a bar plot of statistical data. See the examples on the help page of plot: : Bars2d. Figure 15 shows the image of a rectangle in the complex plane under the map z -- sin(z2). See the examples on the help page of plot: : Conformal. Figure 16 shows some elliptic curves generated as a contour plot. See the examples on the help page of plot: : Implici t2d. Figure 17 shows the Feigenbaum diagram of the logistic map. See the examples on the help page of plot: : PointList2d.

Figure 18 shows Bessel functions Jv ( Jx 2 + y2) with v = 0,4,8. See the examples on the help page of plot: : Function3d. Figure 19 shows 3D function plots with coordinate grid lines. See the exam• ples on the help page of the graphical attribute GridVisible. Figure 20 shows "Klein's bottle" (a famous topological object). This surface does not have an orientation; there is no "inside" and no "outside" of this object. See the examples on the help page of plot: : Surface. Figure 21 models various snails using plot: : Surface (by Maike Kramer• Jka). Figure 22 demonstrates the re-construction of an object with rotational symmetry from measurements of its radius at various points. See page 211 in Section 11.3.2.

Figure 23 shows the solution set of the equation Z2 = sin(z - x2 . y2) in 3D. See the examples on the help page of plot: : Implici t3d. Figure 24 shows the "Lorenz attractor." See page 264 in Section 11.16. Index

# ...... see _power _and ...... see and ...... see fact _assign ...... 41, 342 " ...... see strings _concat ...... 53, 54, 66, 81, 348 , ...... 18, 27, 142 _concat ...... 48 , ...... 46 _di vide ...... 50, 53, 54 * ...... see _mult _equal ...... 54, 286, 288 •...... 7 _exprseq ...... 54, 58 + ...... see _plus _f concat ...... see ~ - ...... see _negate and _subtract _fnest ...... see ~~ -> . 21, 27, 29- 33, 52, 83, 95, 131, 136, _fnest ...... 54 142, 155, 182, 297, 30l, 304, 320, _for ...... 294 323, 337, 338, 343, 349, 351, 365, _if ...... 297 366, 374 _intersect ...... see intersect ...... see _concat and concatenation _leequal ...... 51 ...... see expressions, range ( .. ) _less ...... 51 , 54, 286, 347 ...... see hull _mult ... 50, 54, 58, 68, 139, 286, 343 / ...... see _divide _negate ...... 50 /* ... */ ...... see comments _plus . 50, 53, 54, 58, 59, 68, 69, 138, / / ...... see comments 286, 309, 343 : ...... 8 _power .. 50, 54, 55, 58, 68, 168, 286 : = ...... see assignment _seqgen ...... 53 , 54, 61 ; ...... 8 _subtract ...... 50, 54, 373 < ...... see _less _unequal ...... 51 <= ...... see _leequal _union ...... 53, 54 <> ...... see _unequal = ...... see _equal > ...... see _less A >= ...... see _leequal » ...... 7 abbreviation ...... see assignment ? ...... see help abs ...... 16,45, 174, 177,371 addition theorems ...... 20, 162 ~ ... 32, 52, 83, 88 , 142, 351 , 364, 367, 373 algebraic structures ...... 89--93 alias ...... 355 ~~ ...... 52, 83, 88 $ .... 29-31, 33, 51, 53, 56, 61, 64, 75, anames ...... 48, 82, 348 139, 141, 179-181,288,316,337, and ...... 54, 55, 347 338, 340, 342-344, 346-349, 355, and 52, 60, 19, 296, 333, 342, 376, 377 357, 364- 367 animations .... 188, 197, 206, 231-250 %. 8, 19, 24, 25, 53, 130, 148, 152, 160, - examples ...... 247-250 167, 171, 269, 337, 338, 348, 349, - frame by frame ~ ...... 242- 246 351, 356, 358-361, 363, 364, 366 - join ~ ...... 250 - number of frames ...... 236-237 400 Index

- playing rv ...... 235 cameras in 3D ...... 261-267 - simple rv •••.••...... 231-235 - animated ...... 265 - start ...... 189 canvas ...... 212 - synchronization of rv •..... 239-242 case ...... 298 - time range of rv ...... 236-237 case distinction ...... see piecewise annulus ...... 248 ceil ...... 45 approximate solution . . . .. see float characteristic polynomial arccos ...... 19 (linalg: : charpoly) .. 105, 353 arccosh ...... 19 Chebyshev polynomials ..... 85, 349 arcsin ...... 19 X2 -test (stats: : csGOFT) ...... 183 arcsinh ...... 19 coeff ...... 87, 114 arctan ...... 19 coin tosses ...... 179 arctanh ...... 19 collect ...... 160 args ...... 305, 315, 316 colon ...... 8 array ...... 76, 78, 95, 347 colors ...... 228-231 arrays ...... 76-79 - finding rv by name ...... 229 - 0-th operand ...... 78 - HSV rv ••....•...... 230-231 - deleting elements ...... 77 - opacity ...... 229 - dimension...... 78 - RGB rv •••••••••.•.... 228-230 - generation of rv ••••••••••••. 76 - RGBa rv ....•.•.••••••••• 229 - matrix multiplication ...... 308 column vectors ...... 24, 96 arrow operator (-» ...... 83 combinat (library for combinatorics) assign ... 48, 148, 339, 341, 342, 361 ...... 72,73 assignment ...... 17, 46 - rv: : subsets ...... 72 - delete ...... 47 combinat: : subsets ...... 346 - indexed ...... 65 combinatorics (combinat) ...... 73 - simultaneous rv • ...... 48, 64, 339 combine...... 160, 168, 363 - to sublist ...... 65 comments ...... 302 assume .. 144, 172, 172, 173, 175-178, comparisons ...... 51 364 composition operator ...... see ~ assumptions about identifiers ..... composition operator (~) ...... 88 ...... see assume and is computation assumptions about identifiers (assume - exact ... see symbolic computations and is) ...... 173 - hybrid ...... 2 asymptotic expansion (series) .... 88 - numerical ...... atoms ...... 43, 57 ...... see numerical computations attributes ... see graphics, attributes - symbolic see symbolic computations Axiom ...... 3 computer algebra ...... 1 - systems ...... 3 concatenation (. and _ concat) B - of lists ...... 66 backtick ...... 46 - of matrices ...... 100 batch mode ...... 259-260 - of names ...... 48 bool ...... 79, 348 - of strings ...... 81 Boolean expressions ...... 79-81 conjugate ...... 16, 100 - evaluation (bool) ...... 79 contains...... 66, 72, 75 branching (if and case) . . . . . 295-300 context ...... 321 - return value ...... 297, 299 cycloid ...... 209 c D C/C++ additions to MuPAD ...... 4 D ...... 54,117, 142 C_ ...... 151 data type ...... 4 Index 401 debugger ...... 4 - DoM_CoMPLEX ...... 44 decompose...... see operands - DoM_EXPR ...... 50 degree ...... 113 - DoM]LOAT ...... 44 delayed evaluation (hold) ...... 181 - DoM]UNC_ENV ...... 323 delete . 14, 15, 82, 88, 47, 48, 58, 68, - DoM_IDENT ...... 46 65, 66, 74, 77, 79, 84, 125- 180, - DoM_INT ...... 44 139, In, 174, 270, 276, 294, 308, - DoM_INTERVAL ...... 52 819, 821, 822, 844, 357, 858, 873 - DoM_NULL ...... 123 DELiA ...... 8 - DoM_PoLY ...... 110 denom ...... 45 - DOM_PRoC ...... 302 denominator (denom) ...... 45 - DoM_RA T ...... 44 dense matrices ...... 94 - DoM_SET ...... 70 derivative ...... see differentiation - DOM_STRING ...... 81 Derive ...... 8 - DoM_ TABLE ...... 73 determinant (linalg: :det) .. 24, 104 - DoM_VAR ...... 306 diagonal matrices ...... 97 - piecewise ...... 153 die ...... 179 - rectform ...... 167 diff ... 8, 17, 19, 62, 86, 89, 100, 110, - Series:: Puiseux ...... 86 117, 189, 141, 165, 171, 269, - solvelib: :BasicSet ...... 151 275-277, 281, 286, 828, 326, 827, - Type ...... 176, 288, 314 829, 881, 850, 857, 871 domain type ...... 41 differential equations (ode) ...... 154 - defining your own cv •••••••••• 42 - initial and boundary conditions . 155 - determining the cv •••• see domtype - numerical solutions ... 155, 210, 266 domtype. 42, 44- 46, 79, 86, 91, 98, 123, differential operator (, and D) ..... 131, 132, 151-154, 167, 281, 285, ...... 18, 117, 142 288, 298, 299, 302, 305, 309, 323, differentiation (diff) ...... 141- 148 366, 367, 371 - higher derivatives ...... 141 - partial derivatives ...... 141 - sample procedure ...... 829- 381 E DIGITS .. 3, 14, 15, 46, 122, 283, 818, E ...... 13, 15 889, 340, 352 e ...... see E discont ...... 27 eigenvalues discontinuities (discont) ...... 27 - numerical ...... distribution function ...... 182 · ...... see numeric: : eigenvalues div ...... 45, 51 - symbolic see linalg: : eigenvalues divide ...... 114 eigenvectors Dodecahedron ...... 217 - numerical ...... domain · ... .. see numeric: : eigenvectors - Dom: : DenseMatrix ...... 94 - symbolic ...... - Dom: : ExpressionField ...... 92 · ...... see linalg: : eigenvectors - Dom: : Float ...... 90 elliptic integrals ...... 824-828 - Dom: : FloatIV ...... 121 ...... 7 - Dom:: ImageSet ...... 152 environment variables ...... 14 - Dom: : Integer...... 90 - DIGITS ...... 14 - Dom: : IntegerMod ...... 90, 355 - HISTORY ...... 270 - Dom: : Interval ...... 154 - LEVEL ...... 129 - Dom:: Matrix ...... 94 - MAXDEPTH ...... 303 - Dom: : Multiset ...... 181, 364 - MAXLEVEL ...... 129 - Dom: : Rational ...... 90 - ORDER ...... 86 - Dom: :Real ...... 90 - PRETTYPRINT ...... 275 - Dom: : SquareMatrix ...... 94, 98 - reinitialization (reset 0) .. 14, 283 - DoM_ARRAY ...... 76 - TEXTWIDTH ...... 275 - DOM_BOoL ...... 79 402 Index equations ...... 51 Expr ...... 113 - assigning solutions (assign) . .. 148 expr ...... 86, 100, 113, 167 - differential rv (ode) ...... 154 expr2text 82, 274, 281, 291 , 295, 348, - general rv • •••••• •• ...... • • 152 371 integer solutions ...... 151 expressions ...... 50-60 - linear rv .....•.•• • ...... 148 - O-th operand ...... 58 - numerical solutions ...... 151 - atoms ...... 57 -- numeric: :realroots ...... 151 - Boolean rv .. • .••• ••• .... 79-81 -- numeric: :fsolve ...... 151 -- evaluation (bool) ...... 79 -- numeric: : solve ...... 151 - comparisons ...... 51 -- search range ...... 153 - equations ...... 51 - parametric rv ...... ••••••. 153 - expression trees ...... 56-58 - polynomial rv ...... 147 - factorial (f act) ...... 50 - rational solutions ...... 151 - generation via operators . . . . 50-56 - real solutions ...... 150 - indeterminates (indets) ...... 111 - recurrence rv (rec) ...... 157 - inequalities ...... 51 - solving (solve) ...... 147-157 - manipulation ...... 159-178 - survey of all solvers (?solvers) .. - operands (op) ...... 58-60 ...... 147, 151 - quotient modulo (div) ...... 51 error function (erf) ...... 143 - range ( .. ) ...... 52 escape ...... 304, 313 - remainder modulo (mod) ...... 51 Euclidean Algorithm ...... 332 -- redefinition ...... 51 eval ...... 130, 136, 154, 270 - sequence generator ($) ...... 61 evalp ...... 116 - simplification ...... evaluation ...... 125- 132 . see also combine, normal, radsimp, - complete rv •• • •••• . .• . • 127- 132 simplify, and Simplify, 168-172 - delayed rv (hOld) ...... 131 - transformation . . . see also collect, - enforcing rv (eval) ...... 130, 136 combine, factor, normal, partfrac,

- rv tree ...... 127 rectform, rewrite, 160-167 - incomplete ...... 130 - invoke ...... 7 - level (LEVEL) ...... 129 F - maximal depth (MAXLEVEL) .. .. 129 fact ...... 24, 45 , 51 , 54 - of arrays ...... 130 factor 21 , 45 , 117, 133, 162, 163, 352 - of matrices ...... 131 factorial ...... see fact - of polynomials ...... 131 FAIL ...... 99, 124, 134 - of tables ...... 131 FALSE ...... 79 - up to a particular level (level) . 128 Fermat numbers...... 33, 338 - within procedures ...... 131 Fibonacci numbers ...... evaluator ...... 4 ...... 37, 157, 316- 318, 362 exact calculations ...... 10 field extension examples (Dom: : AlgebraicExtension) . 92 - transfer rv to notebook ...... 10 fields ...... 89-93 exp ...... 13, 100, 108 files expand .. 20 , 100, 109, 133, 149, 162, - reading rv (read) ...... 276 349 - reading data (import: :readdata) exponential function (exp) ...... 13 ...... 278 - for matrices ...... 100, 105, 108 - writing rv (write) ...... 276 exponentiation (~) ...... see _power float ... 1, 13, 15, 19, 45 , 53 , 75, 78, export ...... 37, 95 , 229 100, 144, 148, 151 , 153, 180, 280, exporting graphics ...... 258- 260 319, 323, 326, 339, 351, 359, 361 , - batch mode ...... 259- 260 364-366 - interactive ...... 258- 259 floating point ...... expose ...... 37, 39, 324 . ... see numerical computations Index 403 floating-point intervals ...... 119- 123 -- AxesTitleFont ...... 257 floor ...... 45, 340 -- AxesTitles ...... 191, 199 fonts ...... 257- 258 -- AxesVisible ...... 191, 199 for ...... 291 -- BorderWidth ...... 212 formula manipulation ...... 2 -- CameraDirection ...... 262 Fourier expansion...... 170 -- change'" in existing objects .. 205 fp ...... 84 -- Color ...... 204, 228 fp: :unapp1y ...... 84 -- Colors ...... 188, 191, 196, 199 frac ...... 45 -- CoordinateType ...... 191 frandom ...... 180 -- default values ...... 220-221 frequencies (Dom: : Multiset). 181, 364 -- FillColor ...... 228 funcenv ...... 325, 371 -- FillColorFunction ...... 238 function environments ...... 322-329 -- FillColorType ...... 199 - function attributes ...... 326 -- Filled ...... 223 - generation ...... see funcenv -- Footer...... 190, 198, 238, 258 - operands ...... 324 -- FooterFont ...... 257, 258 - source code (expose) ...... 39 -- Frames .... 190, 191, 198, 199, 236 functions ...... 52, 83- 85 -- "fully qualified" ...... 223 - as procedures ...... 301- 333 -- GridVisible .. 190, 19:3, 198, 201 - composition ...... see ~ -- Header ...... - constant ~ ...... 84 . . . . . 190, 192, 198, 201, 238, 258 - converting expressions to ~ -- HeaderFont ...... 257, 258 (fp: :unapply) ...... 84 -- Height ...... 190, 198, 212 - extrema ...... 27 -- help pages for '" ...... 226-228 - functional expressions ...... 84 -- hints ...... 224-226 - generation (-» ...... 83 -- inheritance of '" ...... 221-224 - identity function (id) ...... 92 -- Layout ...... 261 - iterated composition ...... see ~~ -- Legend...... 255, 256 - iterated composition (@@) ..... 83 -- LegendAlignment ...... 256 - kernel ~ ...... 4 -- LegendEntry ...... 255, 256 - library for functional programming -- LegendFont ...... 256, 257 (fp) ...... 84 -- LegendPlacement ...... 256 - numbers as ~ ...... 84 -- LegendText ...... 255, 256 - roots ...... 27 -- LegendVisible. 191 , 199, 255, 256 -- LineColor ...... 228 -- LineColorFunction ...... 238 G -- LineColorType ...... 191 GAP ...... 3 -- LinesVisible ...... 220, 223 gcd ...... 111, 373 -- Mesh ...... 191, 192, 199 general plot principles ...... 203- 207 -- Name ...... 256 general purpose systems ...... 3 -- PointColor ...... 228 generate ...... 281 -- Scaling ...... 191, 199, 261 -- spelling ...... 233 genident ...... 49, 322 geometric series ...... 86 -- SubgridVisible ...... getprop...... 114, 177, 178 ...... 190, 193, 198, 201 global variables ...... 306 -- Submesh ...... 199, 200 -- TextFont ...... 257 Goldbach conjecture ...... 30 -- TicksLabelFont ...... 257 graphical trees ...... 212-214 -- TicksNumber ...... 191, 199 graphics ...... 185- 268 - animations ...... see animations -- TimeBegin ...... 236, 239 - attributes ...... 219- 228 -- TimeEnd ...... 236 , 239 -- Adapti veMesh .. . .. 191, 192, 199 -- TimeRange ...... 236, 239 -- Axes ...... 191, 199, 224 -- Title ...... 190, 198, 238 -- TitleFont ...... 257 404 Index

-- TitlePosition ...... , 190, 198 -- drivers ...... 268 -- type specific '" ...... 223 - Plato's polyhedra ...... 217 -- ViewingBoxYRange ..... 191, 194 - playing animations ...... 235 -- ViewingBoxZRange . . . .. 199, 202 - plotfunc2d ...... 186-194 -- VisibleAfter ...... 242 - plotfunc3d ...... 195-202 -- VisibleAfterEnd ...... 240 - primitives ... 217-219, see also plot -- VisibleBefore ...... 242 (graphics library) -- VisibleBeforeBegin ...... 240 - property inspector ...... 214-216 -- VisibleFromTo ...... 242 - RGB colors ...... 228-230 -- Width ...... 190, 198, 212 - saving and exporting ...... 258-260 -- XTicksBetween ...... 192 -- batch mode ...... 259-260 -- XTicksDistance ...... 192 -- interactive ...... 258-259 -- YRange ...... 191 - Sierpinski triangle ...... 332, 375 -- YTicksBetween ...... 193 - size of image...... see graphics, -- YTicksDistance ...... 192 attributes, Height and Width -- ZRange ...... 199 - title (per object) ...... - batch mode ...... 259- 260 .... see graphics, attributes, Title - cameras in 3D ...... 261- 267 - title position...... see graphics, -- animated ...... 265 attributes, Ti tlePosi tion - canvas ...... 212 - transformation ...... 252-253 - caption ...... - transformations ...... 219 · .. see graphics, attributes, Footer graphs of functions (plotfunc2d, - colors...... see colors plotfunc3d) ...... 186 - evaluation mesh . . . .. see graphics, greatest common divisor ...... attributes, Mesh und Submesh ...... see gcd and igcd - evaluation mesh, adaptive ...... Grabner bases ...... see library · ...... see graphics, attributes, groups of primitives ...... 250-251 AdaptiveMesh - fonts ...... 257- 258 - footer ...... H · .. see graphics, attributes, Footer has ...... 67, 171, 330 - general plot principles ..... 203- 207 help ...... 9- 10, 379 - graphical trees ...... 212- 214 help ...... 9,35 -- implicit'" ...... 214 Hexahedron ...... 217 - graphs of functions (plotfunc2d, Hilbert matrix (linalg: :hilbert) . plotfunc3d) ...... 22, 186 ...... 79, 79, 101, 122 gaps in definition ...... 188, 196 - inverse'" (linalg: : invhilbert) . piecewise defined functions ...... 123 ...... 188, 196 hint .... see graphics, attributes, hints singularities ...... 193, 201 HISTORY ...... 270 - grid lines . . see graphics, attributes, history (% and last) ...... 269-271 GridVisible and SubgridVisible - evaluation of last ...... 270 - groups of primitives .. 219, 250-251 hold .... 131, 132, 136, 144, 151, 153, - header ...... 171, 277, 305, 320, 321, 330, 357 · .. see graphics, attributes, Header de I'Hospital ...... 142 - HSV colors ...... 230-231 hull ...... 52, 120, 121 - image size . see graphics, attributes, hypertext ...... 10 Height and Width - importing pictures ...... 260-261 - legends ...... 254- 256 I - light sources ...... 219 - logarithmic plots ...... 191 I ...... 16 - object browser ...... 214- 216 Icosahedron ...... 217 - OpenGL ...... 185 id ...... 92 Index 405 identifiers ...... 17, 46-49 - generate intervals ( ... , hull) ... - assignment ...... 46-48 ...... 52, 120 - assumptions .... see assume and is intlib: : changevar ...... 145, 359 - assumptions (assume and is) . 113 IntMod ...... 112 - concatenation ...... 48 irreducible ...... 119, 356 - deleting the value ...... 47 is ...... 152,113,174,175,177 - dynamical generation ...... 48 isprime ... 12, 29-31, 45, 80, 295-297, - evaluation ...... 125 337, 344 - generation via strings ...... 49 iszero ...... 92, 98, 100 - list (anames) ...... 48 iteration operator ...... see @@ - values ...... 125 iteration operator (@@) ••••••• 83, 88 - with arbitrary characters ...... 46 ithprime ...... 29, 273, 274 - write protection -- removing rv (unprotect) ...... 48 -- setting rv (protect) ...... 48 J if .... 80, 83, 124, 131, 293, 295, 297, JavaView ...... 259 300, 302, 303, 305, 309, 314-317, 324, 325, 330, 349, 369, 371, 373, 374, 376 K ifactor...... 12, 29, 32, 45 igcd ...... 181, 332, 373 kernel ...... 4 19noreSpecialCases ...... 23 - extending the rv • • • • • • • • • • • • . • 4 1m ...... 16, 45 kernel function ...... 4 imaginary part ...... see 1m imaginary unit ...... 16 import: : readbitmap ...... 260 L import: : readdata ...... 218, 284 Landau symbol (0) ...... 86, 350 importing pictures ...... 260-261 last ...... see % in ...... 123, 152 last indeterminates ...... see identifiers - evaluation of rv •••...... •••• 270 indeterminates (indets) ...... 111 last ...... 19, 130, 269, 349 indets ...... 111, 150, 360, 374 Laurent series ...... 88 inequalities ...... 51 legends ...... 254-256 - solving rv •...... •.•••• 154 length ...... 82, 348 infinity. 13, 27, 28, 88, 132, 134, 350 LEVEL ...... 129 - rounded rv (RD_INF, RD_NINF) .. 120 level ...... 128, 322, 357 info .... 9, 35, 90, 102, 103, 229, 287 library...... 35-39 input and output ...... 273-278 - exporting a rv (export) ...... 37 int . 8, 18, 19, 52, 53, 59, 84, 100, 117, - for color names (RGB) ...... 229 143, 144, 171, 269, 270, 280, 304, - for combinatorics (combinat) . 12, 73 322, 359, 363, 364, 366 - for data structures (Dom) ...... 89 integration...... see int - for external formats (generate) . 281 - change of variable ...... - for functional programming (fp) .84 ...... see intlib: : changevar - for Grabner bases (groebner) . 118 - numerical rv •••••••••••••••• - for input (import) ...... 278 ...... see numerical integration - for linear algebra (linalg) .... 103 intermediate result ...... 8 - for (numlib) .. 33, 35 interpolation ...... 208 - for numerical algorithms intersect ...... 54, 345 (numeric) ...... 31, 103 intersect ...... 11, 73, 121 - for orthogonal polynomials ...... 119-123 (orthpoly) ...... 349 - union, intersect ...... 121 - for statistics (stats) ...... 180 - convert to intervals (interval) . 121 - for strings (stringlib) ...... 82 - fa<;ade domain (Dom: : FloatlV) 121 406 Index

- for type specifiers (Type) ...... Mathematica ...... 3 ...... 287, 314, 369 mathematical objects ...... 1 - information on a rv (? and inf 0) . 35 MathView ...... 3 - standard rv ...... •.•...... 39 matrices ...... 93-110 limit ... 13, 21, 27, 28, 124, 277, 364 - characteristic polynomial - one-sided ...... 27 (linalg: :charpoly) ..... 105,353 limit computation (limit) ...... 21 - computing with rv...... 99-101 linalg (library for linear algebra) - default coefficient ring - rv:: charpoly ...... 105, 353 (Dom: :ExpressionField) ...... 98 - rv: :det ...... 24, 104, 352 - dense rv . . • . . . . • . . • . • ...... 94 - rv:: eigenvalues ... 105, 106, 353 - determinant (linalg: :det) .24, 104 - rv:: eigenvectors ...... 354 - diagonal rv • • . . • . • . • . • ...... 97 - rv:: invhilbert ...... 123 - eigenvalues - rv:: isPosDef ...... 176 -- numerical ...... linear algebra (linalg) ...... 103 · ..... see numeric: : eigenvalues linefeed ...... 7 -- symbolic ...... lists ...... 64-70 · ...... see linalg: : eigenvalues - applying a function (map) ...... 67 - eigenvectors - combining rv (zip) ...... 68 numerical ...... - empty list ...... 64 · .... see numeric: : eigenvectors - selecting according to properties symbolic ...... (select) ...... 67 · ..... see linalg: : eigenvectors - splitting according to properties - exponential function (exp). 100, 108 (split) ...... 68 - exponential function In ...... 13 (numeric: : expMatrix) ...... 105 local ...... 306 - functional calculus local variables (local) ...... 306-309 (numeric: : fMatrix) ...... 105 - formal parameters...... 320 - Hilbert matrix (linalg: :hilbert) - uninitialized rv ...... 307 ...... 79, 101, 122 log ...... 122 - identity rv ...... 97 logarithm (In, log) ...... 13, 122 - indexed access ...... 96 logical formula ...... 333 - initialization...... 94-98 loops ...... 291-294 - inverse ...... 24, 99 - aborting rv (break) ...... 293 - inverse Hilbert matrix - for ...... 291 (linalg: :invhilbert) ...... 123 - repeat ...... 292 - library for linear algebra (linalg) - return value ...... 294 ...... 103 - skipping commands (next) .... 293 - library for numerical algorithms - while ...... 293 (numeric) ...... 103 Lorenz attractor ...... 264 - methods ...... 101-103 -- survey of rv ...... 102 - ring of square rv ...... 98 M - sparse rv .....•...... 94, 106-107 Macintosh ...... 7 - submatrices ...... 96 ...... 3 - Toeplitz rv • . • ...... • . • . . . . 107 manipulating expressions .... 159-178 matrix . 24, 94, 98, 106, 107, 176, 351, map. .. 25, 55, 67, 69, 72, 75, 78, 100, 352 108, 109, 130, 148, 149, 152, 153, max ...... 63, 304, 315 330, 338, 343, 346, 348, 360, 364, MaxDegree ...... 149 366, 367, 373 MAXDEPTH ...... 303, 373 mapcoeffs ...... 116 ...... 3 Maple ...... 3 MAXLEVEL ...... 129 maps...... see functions mean value (stats: :mean) ...... 180 memory management ...... 4 Index 407

Mersenne primes ...... 33, 337 - fractional part ...... see frac min ...... 63 - greatest common divisor . . ' see igcd minus ...... 71 - i-th prime (i thprime) ...... 29 mod . . 45, 51, 56, 90 , 91, 112, 332, 344, - imaginary part ...... see 1m 372, 373 - integers .. . . . see domains, DOM_INT - redefine'" ...... 51 - integral part ...... see trunc modp ...... 51 - i-th prime ...... see i thprime mods ...... 51 - modular exponentiation modular exponentiation (powermod) (powermod) ...... 91 ...... 91 - next prime ...... see nextprime module ...... 4 - numerator ...... see numer Moebius strip ...... 249 - odd integers (Type: : Odd) .. . .. 288 Monte-Carlo simulation ...... 184 - operands ...... 44 multcoeffs ...... 116 - output format of floating-point multiset ...... 181 numbers (Pref: : floatFormat) . 280 MuPAD components ...... 5 - primality test ...... see isprime - prime factorization .... see ifactor - quotient modulo (di v) ...... 45 N - random", . see random and frandom Newton iteration ...... 332, 374 - rational", ... see domains, DaM_RAT - numeric: :fsolve ...... 37 - real and imaginary part ...... nextprime ...... 29- 31 · ...... see rectform NIL . .... 124, 279 , 281, 297, 303, 371 - real part ...... see Re nops . . 29- 33, 42, 58, 59, 71, 344- 346, - remainder modulo ...... see mod 365, 366, 374 - rounding ...... norm ...... 100 · .... see ceil, floor, round, trunc normal . 20, 25 , 93 , 98, 163, 168, 281, - sign ...... see sign 363, 364, 367 - simplification of radicals (radsimp) normal distribution · ...... 21, 169 (stats: : normalCDF) ...... 183 - square root...... see sqrt not .. 30, 31 , 52, 60, 79, 296, 333, 342, - type specifier ...... 288 376,377 numer ...... 45 notebook ...... 3, 274 numerator (numer) ...... 45 nterms ...... 118 numeric (numerics library) nthcoeff ...... 118 - "': :det ...... 105 nthterm ...... 118 - "': : eigenvalues . 38, 105, 187, 196 null objects ...... 123- 124 - "':: eigenvectors ...... 105 null 0 ...... 62, 123 - "': : expMatrix ...... 105 number theory (numlib) ...... 33, 35 - "': : fMatrix ...... 105 numbers ...... 44- 46 - "': :fsolve ...... 37, 151 - absolute value ...... see abs - "': :int ...... 131 , 144,360 - basic arithmetic ...... 45 - "': : inverse ...... 105 - complex", ...... - "' : : odesol ve ...... 155 . 16, see also domains, DaM_COMPLEX - "': : quadrature ...... 38 - complex conjugation. see conjugate - "':: realroots ...... 38, 151, 153 - computing with", ...... 10-12 - "':: singularvalues ...... 105 - decimal expansion - "': : singularvectors ...... 105 (numlib: : decimal) ...... 36 - "': :solve ...... 151 - denominator...... see denom numerical computations ...... - domain types ...... 44 ...... 1, 13, 14, 37, 103 - even integers (Type: : Even) ... . 288 - precision ...... see DIGITS - factorial ...... see fact numerical integration . . . 38, 144, 360 - floating point approximation . .. . numerical integration (numeric: : int ...... see float and numeric: : quadrature) 332 408 Index numlib (library for number theory) Plato's polyhedra ...... 217 - rv:: decimal ...... 36 plot (graphics library) - ",::fibonacci ...... 318 - "':: AmbientLight ...... 219 - "': : primedi visors ...... 33 - "':: Arc2d ...... 217 - "':: proveprime ...... 29 - "':: Arrow2d ...... 217 - "':: Arrow3d ...... 217 - "':: Bars2d ...... 218 o - "':: Bars3d ...... 218 0. : ...... 86, 350 - "': :Box ...... 217 object browser ...... 214- 216 - "':: Boxplot ...... 218 Octahedron ...... 217 - "':: Camera ...... 219, 263 ode ...... 154, 360 - "':: Canvas...... 212, 219 - "':: Circle2d ...... 217 op . 42, 43 , 44, 58-60, 63 , 65, 71 , 75 , 78, 87, 113, 114, 116, 123, 136- 139, - "':: Circle3d ...... 217 148, 149, 152, 181, 182, 309, 326, - "':: ClippingBox ...... 219 330, 338, 339, 341-343, 345- 348, - rv: : Cone ...... 217 361, 364, 371, 373, 374, 376 - "': : Conformal ...... 218 OpenGL ...... 185, 268 - "':: CoordinateSystem2d. . 213, 219 - drivers ...... 268 - "' : : CoordinateSystem3d . . 213, 219 operands ...... 42-44, 135 - "':: Curve2d ...... 218 - O-th operand ...... 58, 138 - rv: : Curve 3d ...... 218 - accessing'" ...... see op - "':: Cylinder ...... 217 - number of '" ...... see nops - "':: Cylindrical ...... 218 - of series expansions ...... 87 - "': :Density ...... 218 operators ...... 50-56 - "' : : DistantLight ...... 219 - priorities ...... 56 - "':: Dodecahedron ...... 217 option escape ...... 304, 313 - "': : Ellipse2d ...... 217 option remember ...... 14, 316- 320 - "' : : Ellipsoid ...... 217 or ...... 52, 79, 296, 333, 342, 376 - "':: Function2d ...... 218 ORDER ...... 86 - "': : Function3d ...... 218 orthpoly: : chebyshev1 ...... 349 - "' : :getDefault ...... 220 OS command (system) ...... 284 - "':: Group2d ...... 219 output - "': : Group3d ...... 219 - manipulation (Pref: : output) .. 281 - "' : : Hatch ...... 218 - of floating-point numbers - "':: Hexahedron ...... 217 (Pref: : floatFormat) ...... 280 - "':: Histogram2d ...... 218 - order of terms ...... 17 - "': :HOrbital ...... 218 - suppressing '" ...... 8 - "':: Icosahedron ...... 217 output and input ...... 273- 278 - "': : Implicit2d ...... 218 - pretty print ...... 275 - "': : Implici t3d ...... 218 overload ...... 4 - "': : Inequality ...... 218 - "':: Iteration ...... 218 - rv : : Line2d ...... 217 p - "'::Line3d ...... 217 - rv: :Lsys ...... 218 PARI ...... 3 - "':: Matrixplot ...... 218 parser ...... 4 - "':: Octahedron ...... 217 partfrac ...... 20, 164 - "':: Ode2d ...... 218 partial fraction decomposition - "':: Ode 3d ...... 218, 265 (partfrac) ...... 164 - "':: Parallelogram2d ...... 217 Pascal ...... 3 - "':: Parallelogram3d ...... 217 PI ...... 15 - "':: Piechart2d ...... 218 7r • •.••• •• ••• • .•• •• ...•. ••. 15 - "':: Piechart3d ...... 218, 224 piecewise ...... 23, 153, 188, 196 - "': :Point2d ...... 217 Index 409

- ~::Point3d ...... 217 - definition (poly) ...... 110-113 - ~:: PointLight ...... 219 - degree (degree) ...... 113 - ~: :PointList2d ...... 217 - division with remainder (divide) . - ~:: PointList3d ...... 217 ...... 114 - ~: : Polar ...... 218 - evaluation (evalp) ...... 116 - ~:: Polygon2d ...... 217 - factorization (factor) .... 117, 163 - ~: :Polygon3d ...... 217 - Grabner bases (groebner) ..... 118 - ~: :Raster ...... 218,260 - greatest common divisor (gcd) .. 117 - ~:: Rectangle ...... 217 - irreducibility test (irreducible) - ~: :Rotate2d ...... 219, 252 119 - ~:: Rotate3d ...... 219, 252 - library for orthogonal ~ - ~:: Scale2d ...... 219, 252 (orthpoly) ...... 349 - ~:: Scale3d ...... 219, 252 - multiplication by a scalar factor - ~:: Scene2d ...... 212, 219 (multcoeffs) ...... 116 - ~: :Scene3d ...... 212,219 - number of terms (nterms) .. . .. 118 - ~: : setDefault ...... 221 - operands ...... 113 - ~: : Sphere ...... 217 power set (combinat: : subsets) ... 72 - ~: : Spherical ...... 218 powermod ...... 91 - ~: : SpotLight ...... 219 Pref (library for user preferences) .. - ~: : Surface ...... 218 ...... 279-282 - ~:: SurfaceSet ...... 217 - ~:: floatFormat ...... 280 - ~:: SurfaceSTL ...... 217, 260 - ~: : output ...... 281 - ~: : Tetrahedron ...... 217 - ~: :postInput ...... 281 - ~: : Text2d ...... 217,239 - ~:: postOutput ...... 282 - ~::Text3d ...... 217,239 - ~: : report ...... 280 - ~:: Transform2d ...... 219, 252 - resetting preferences ...... 282 - ~:: Transform3d ...... 219, 252 PRETTYPRINT ...... 275 - ~:: Translate2d ...... 219, 252 primitives ...... 2l7-219 - ~:: Translate3d ...... 219, 252 print ... 31, 33, 62, 80-82, 123, 273, - ~: : Tube ...... 218 291-293, 295, 297, 320, 345 - ~: : Turtle ...... 218 probability ...... 179-184 - ~:: VectorField2d ...... 218 probability density function ..... 182 - ~: :XRotate ...... 218 procedures ...... 301-333 - ~: :ZRotate ...... 218 - call ...... 302 plot ...... 203 -- by name ...... 320 plotfunc2d ...... -- by value ...... 320 .. 22, 28, 186, 186-194, 254, 365 - comments (I * *I) ...... 302 plotfunc3d ...... 22, 195, 195-202 - definition ...... 302-303 poly ...... 110, 111-118, 355, 356 - evaluation level ...... 321-322 poly2list ...... 112 - global variables ...... 306 polynomials ...... 110-119 - input parameters ...... 320-321 - accessing terms (nthterm) ..... 118 - local variables (local) .... 306-309 - applying a function to coefficients -- formal parameters ...... 320 (mapcoeffs) ...... 116 -- without a value ...... 322 - arithmetic ...... 114 - MatrixProduct ...... 309 - Chebyshev ~ ...... 85, 349 - option escape ...... 304, 313 - coefficients - option remember ..... 14, 316-320 -- coeff ...... 114 - procname ...... 305 -- nthcoeff ...... 118 - recursion depth (MAXDEPTH) .... . - computing with ~ ...... 113-119 ...... 303,373 - conversion of a polynomial - return value (return) ..... 303-304 -- to a list (poly2list) ...... 112 - scoping ...... 312-313 -- to an expression (expr) ...... 113 - subprocedures ...... 310-311 - default ring (Expr) ...... 113 - symbolic differentiation .... 329-331 410 Index

- symbolic return values .... 304-305 reset ...... 123, 283 - trivial function ...... 316 residue class ring ...... - type declaration ...... 314 · . see domain, Dom: : IntegerMod - variable number of arguments restarting a session (reset 0) . 14, 283 (args) ...... 315-316 ...... 7 procname ...... 305, 316, 325, 371 return .. 303, 305, 307, 314, 330, 376 product ...... 23 revert ...... 89, 348, 351 prog: : exprtree ...... 58 rewrite prompt ...... 7 - targets ...... 166 properties ...... 172 rewrite ...... 108, 164 - global property...... 177 RGB: : ColorNames ...... 229 property inspector ...... 214-216 rings ...... 89-93 protect ...... 48 RootOf ...... 147 Puiseux series ...... 88 roots ...... 27 round ...... 45 rounding errors ...... 1 Q row vectors ...... 96 Q_ ...... 151 runtime information about algorithms quadrature . see numerical integration (userinfo and setuserinfo) quantile function ...... 182 · ...... 282 quit ...... 8 quotient modulo (div) ...... 45, 51 s saving graphics ...... 258-260 R - batch mode ...... 259-260 R_ ...... 151 - interactive ...... 258-259 radical simplification (radsimp) . 169 Schoonship ...... 3 radsimp ...... 21, 169 scoping ...... 312-313 random ...... 119, 181, 364 screen output (print) ...... 273 random number generators (random, - manipulation (Pref: : output) .. 281 frandom, select 29--31, 33, 61, 72, 75, 288, 337, stats::normalRandom) 179-184 338, 344, 356, 365, 366 random numbers semicolon ...... 8 - normally distributed sequence ...... 51 (stats: :normalRandom) 182 sequence generator ($) .... 29, 51, 61 - other distributions ...... 182 - in ...... 61 - uniformly distributed (frandom) 180 sequences ...... 60-64 - uniformly distributed (random) . 179 - deleting elements (delete) ..... 63 range ..... see expressions, range ( .. ) - indexed access ...... 62 RD_INF ...... 120 - of commands ...... 61 RD_NINF...... 120 - of integers ...... 61 Re ...... 16,45, 174, 177 series ...... 28, 87, 88, 350 read ...... 216 322 series expansions ...... reading data (import: : readdata) : 278 · ...... 86-89, see also series real part ...... see Re - asymptotic expansion (series) .. rec ...... 151 362 ...... 28,88 rectform ...... 16,' 165 - conversion to a sum (expr) ..... 86 recurrence equations (rec) ...... 157 - Laurent series (series) ...... 88 Reduce ...... 3 - of inverse functions (revert) .... 89 remainder modulo (mod) ...... 45, 51 - operands ...... 87 - redefinition ...... 51 - point of expansion ...... 87 option remember ...... 316-320 - Puiseux series (series) ...... 88 repeat ...... 345 - Taylor series (taylor) ...... 86 Index 411

- truncation (0) ...... 86 standard deviation (stats: : stdev) . -- order (ORDER) ...... 86 ...... 180 session ...... 7 statistics ...... 179-184 - logging a '" (protocol) ...... 277 -X2 -test (stats: : csGOFT) ...... 183 - quit ...... 8 - equiprobable cells - restart (reset 0) ...... 14, 283 (stats: :equiprobab1eCells) .. 183 - savingarv (write) ...... 277 - frequencies (Dom: :Multiset) .... sets ...... 70-73 ...... 181, 364 - applying a function (map) ...... 72 - library for rv (stats) ...... 180 - basic sets (solvelib: :BasicSet) . - mean value (stats: :mean) .... 180 ...... 151 - normal distribution - combinatorics (combinat) ... 12, 73 (stats: :normalCDF) ...... 183 - difference (minus) ...... 71 - quantile - elements (op) ...... 71 (stats: : normalQuantile) .... 183 - empty set (n, 0) ...... 70 - random numbers (frandom, random, - exchanging elements ...... 71 stats: : normalRandom) ...... - image set (Dom: : ImageSet) .... 152 ...... 179, 180, 182 - intersection (intersect) ...... 71 - standard deviation - intervals (Dom: : Interval) ..... 154 (stats: : stdev) ...... 180 - number of elements (nops) ..... 71 - variance (stats: : variance) ... 180 - order of the elements ...... 70 stats (library for statistics) - power set (combinat: : subsets) .. 72 - rv:: csGOFT ...... 183 - removing elements ...... 71 - rv:: equiprobableCells ...... 183 - selecting according to properties - rv: :mean ...... 180 (select) ...... 72 - rv:: normalCDF ...... 183 - set-valued functions ...... 72 - rv: :normalQuantile ...... 183 - splitting according to properties - rv:: normal Random ...... 182 (split) ...... 72 - rv: : stdev...... 180 - union (union) ...... 71 - rv:: variance ...... 180 setuserinfo ...... 282 strings...... 81-82 + ...... 7 - converting expressions to rv Sierpinski triangle ...... 332, 375 (expr2text) ...... 82, 281 sign ...... 45, 177 - extracting symbols ...... 81 simplification ...... 135 - length (length) ...... 82 - automatic rv ...... 132-134 - library (stringlib) ...... 82 - of expressions (simplify) .. 168- 172 - screen output (print) ...... 81 - of radicals (radsimp) ...... 21, 169 subprocedures ...... 310-311 Simplify...... 168, 171, 364 subs . 28, 100, 124, 135, 136-139, 148, simplify ..... 21 , 168, 177, 362, 377 149, 154, 179, 357, 358, 361, 363 solution subsex ...... 131 - approximate...... see float subsop ...... 65, 138, 139, 330, 356 solve .. 8, 9, 23, 27, 44, 49, 134, 138, substitution ...... 135-139 141, 149-155, 157,340,360- 362 - enforced evaluation (eval) .... 136 solving equations ...... see equations - in sums and products (subsex) . 137 sort ...... 66, 181, 182, 348, 364 - multiple rvs ...... 137 - user-defined order ...... 181 - of operands (subsop) ...... 138 source code (expose) ...... 37, 39 - of sub expressions (subs) ...... 135 source code debugger ...... 4 - of system functions ...... 136 sparse matrices ...... 94, 106-107 - simultaneous rv ...... 138 special purpose systems ...... 3 sum ...... 23 split ...... 68, 72, 75, 367 symbolic computations ...... 1, 17 sqrt ...... 12, 45 symbolic manipulation ...... 2 square root (sqrt) ...... 12, 45 system ...... 284 412 Index

T types of MuPAD objects ..... 285-289 - domain type (domtype) ...... 42 table ...... 65, 73, 75, 79, 346, 347 - library (Type) ...... 287, 314, 369 tables ...... 73-76 - type checking (testtype) ..... 286 - accessing elements ...... 74 - type query (type) ...... 285 - applying a function (map) ...... 75 typeset expressions ...... 274 - deleting entries (delete) ...... 74 - explicit generation ..... see table - implicit generation ...... 74 u - operands ...... 74 - querying indices (contains) .... 75 unassume ...... 174 - selecting according to properties undefined ...... 124, 134 (select) ...... 75 union ...... 71, 73, 121, 345, 366 - splitting according to properties UNIX ...... 7 (split) ...... 75 UNKNOWN ...... 68, 72, 79 tan ...... 171 unknowns ...... see identifiers tangent ...... 204 unprotect ...... 48 taylor . 86, 87, 88, 275, 328, 350, 351 testtype . 173, 286, 288, 296, 305, 367, 369 v Tetrahedron ...... 217 variance (stats: : variance) ..... 180 TEXTWIDTH ...... 275 vectors ...... 93-110 Theorist ...... 3 - column ~ ...... 24, 96 time ..... 76, 269, 281, 317, 318, 347 - indexed access ...... 96 transformations ...... 252-253 - initialization ...... 96 transforming expressions .... 160-167 - row ~ ...... 96 TRUE ...... 79 trunc ...... 45, 340 Type (library for type checking) w - ~:: AnyType ...... 369 Windows ...... 7 - ~:: Complex ...... 175 worksheet ...... 3 - ~: : Even ...... 175,288 write ...... 276, 277 - ~:: Imaginary ...... 175 write protection - ~:: Integer ...... 173, 175, 176 - removing ~ (unprotect) ...... 48 - ~: : Interval ...... 175, 176 - setting ~ (protect) ...... 48 - ~: :ListOf ...... 369 - ~: : Negative ...... 175 - ~: : NegInt ...... 175,288 z - ~:: NegRat ...... 175 - ~:: NonNegati ve ...... 175 Z_ ...... 151 - ~:: NonNegInt ...... 175, 314 zip .... 32, 68, 69, 100, 123, 181, 343, - ~:: NonNegRat ...... 175 347, 373 - ~: : NonZero ...... 175 - ~:: Numeric ...... 286, 305 - ~: : Odd ...... 175,288 - ~: :PosInt ...... 175,288 - ~: :Positive ...... 172,175,177 - ~:: PosRat ...... 175 - ~: : Prime ...... 175 - ~: :Rational ...... 175 - ~: :Real ...... 172-175, 177 - ~: : Residue ...... 175, 177 - ~: :Zero ...... 175 type ...... 285