{VERSION 3 0 "SGI MIPS UNIX" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text \+ Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Helvetica" 1 14 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Courier" 1 14 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 3" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Fo nt 4" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 5" -1 260 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 6" -1 261 1 {CSTYLE "" -1 -1 "Ti mes" 1 24 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "R3 Font 7" -1 262 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 8" -1 263 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 9" -1 264 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 10" -1 265 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R 3 Font 11" -1 266 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 12" -1 267 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 13" -1 268 1 {CSTYLE "" -1 -1 "T imes" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 14" -1 269 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 1 5" -1 270 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 16" -1 271 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 17" -1 272 1 {CSTYLE "" -1 -1 "T imes" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 18" -1 273 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 1 9" -1 274 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 20" -1 275 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 21" -1 276 1 {CSTYLE "" -1 -1 "T imes" 1 18 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 261 "" 0 "" {TEXT -1 22 "\nIntroduction to Maple " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 1377 "Thi s worksheet is intended to get you started using Maple. By reading thi s worksheet, executing all commands and studying the output of those c ommands you will become familiar with some of the possibilities of Map le. At least you will then be able to work with Maple and explore it f urther.\n\nSome very usefull books concerning Maple are:\n\n B.W . Char, K.O. Geddes, G.H. Gonnet, B.L. Leong, M.B. Monagan, S.M. Watt: \n First Leaves: A Tutorial Introduction to Maple,\n \+ B.W. Char, K.O. Geddes, G.H. Gonnet, B.L. Leong, M.B. Monagan, S. M. Watt:\n Maple V Language Reference Manual\nand\n \+ B.W. Char, K.O. Geddes, G.H. Gonnet, B.L. Leong, M.B. Monagan, S.M . Watt:\n Maple V Library Reference Manual.\n\nThere \+ are many more books on Maple which are very worthwhile.\n\n\nBesides t he text in this worksheet you will also see lines starting with a grea ter than sign ( > ). These lines are command lines and the text on tho se lines are Maple commands. By putting the cursor on such a line and \+ hitting the Return-key the command on that line is executed by Maple a nd the output is shown on the screen. After executing a Maple command \+ in such a way the cursor is automaticcally placed on the next line con taining a Maple command.\n\nMaple contains of course an ordinary pocke t calculator. This is shown by the following Maple commands.\n" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "23+59;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "5*12-13;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 " 2^10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "3^(1/2);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "sqrt(5);" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 12 "sin(1/2*Pi);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 717 "\nYou immediately may notice the following:\n - A M aple command is always ended by a semicolon ( ; ) (or a colon ( :) as \+ you will see later).\n - Multiplication is denoted by an asterisk ( * ), division by a slash ( / ).\n - Maple also knows functions like sqrt, sin, cos, tan, arcsin and so on.\n - Maple knows some constants like Pi, E and gamma.\n\nIt may happen that you forget to t ype the semicolon at the end of your input line and hit the Return-key . In that case Maple won't do anything since it considers the input no t yet to be completed. You can then still complete the input line by t yping a semicolon on the next line and hitting the Return key. The fo llowing example will illustrate this.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "45-16" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 279 "\nThe previous example is in fact an example o f a command distributed over several input lines. Maple will read all input lines until it encounters a semicolon. It will then concatenate all input lines and execute the command this will give. The following is an example of this.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "345+523 *" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "(23-45/3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 216 "\nIn your input you may go to the next line at a ll places except when entering a number or a function name. If however you want to go to the next line inside a number or function name you \+ can use the backslash ( \\ ).\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 11 " 31312321321" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "6765767231;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "34324323432\\" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 10 "423423432;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 188 "\nThe following examples will show a very important characteri stic of computer algebra systems: exact arithmetic. This means that ex pressions are not approximated but are computed exactly.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "3*(1/3); # Compare with 0 .99999999" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "(sqrt(5))^2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 262 "\nIn this example we encounter ed the #-symbol. Everything behind this symbol is ignored by Maple. Th is can be used to put comments between your computations.\n\nIt is how ever possible to approximate expressions by floating point numbers usi ng the `evalf` command..\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "1/3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 523 "\nIn the example above you have already \+ seen an example of the double quote ( \" ) operator (or % in Maple V R elease 5). This operator stands for the previous result. In the same w ay two double quotes stand for the second previous result and you can \+ even use triple double quotes.\n\nThe command evalf (evaluate to float ing point number) evaluates its operand to a floating point number wit h accuracy determined by the Maple variable 'Digits' (default value 10 ). By changing the value of 'Digits' the accuracy can be modified.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "Digits:=40;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalf(1/3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "Digits:=10; # its default value" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 173 "\nIn the last example you have seen how you ca n change the value of a variable in Maple. You can create your own var iables, give them values and use them inside expressions.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "number_of_people:=10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "number_of_people;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "number_of_people+1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 716 "\nIn this last example we have assigned the value 10 to \+ the variable 'number_of_people'. In the second line we asked for the v alue of number_of _people and in the third line we have used the varia ble in an expression. You see that variable names may consist of many \+ characters. Also digits may be used but a variable name may not start \+ with a digit. It is a good habit to give your variables names that exp ress what they mean. This will enlighten your calculation for yourself and for other people.\n\nIf you have assigned a value to a variable i t will keep this value until you change it to another value. If you wa nt a variable to have no value anymore you can use the single quote ( \+ ' ) as in the following example.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "number_of_people:='number_of_people';" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 17 "number_of_people;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 514 "\nAnother important feature of Maple is its on-line help. By c licking on the word 'Help' in the upper right corner of this Maple win dow you will see a menu which is the entrance to the on-line help faci lity of Maple. The best way to learn how to use this on-line help is e xperimenting by yourself.\n\nNow we will show you a lot of Maple comma nds. By executing these commands you will get an idea of some of the c apabilities of Maple. Notice however that this will show only a very s mall part of the power of Maple.\n\n\n" }}{PARA 259 "" 0 "" {TEXT -1 8 "Integers" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "5^(5^5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "length(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "30!;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "ifactor(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "2^89-1;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 11 "isprime(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "a:=121932009755;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "b:=80780187944;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "igcdex( a,b,'s','t');" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "a*s+b*t;" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "a:='a'; b:='b';" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 81 "\nIn this last example you see tha t you can put more commands on one input line.\n\n" }}{PARA 260 "" 0 " " {TEXT -1 16 "Rational numbers" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "(1/3+1/5)*3/6;" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 1 "\n" }}{PARA 262 "" 0 "" {TEXT -1 39 "Real numbers a nd floating point numbers" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 16 "(34/25)^(21/10);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 9 "evalf(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "1/3; 1/3.0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "Digits:= 40;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(E);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalf(sqrt(2));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "Digits:=10;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 262 "" 0 "" {TEXT -1 15 "Complex numbers" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "c:=2 +3*I;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "(3*c^5+2*c^3+10)/( 7*c^3+2*c^2-5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "abs(c);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "Re(c);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "argument(c);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "c:='c':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 112 "\nHer e you see that you can also end a command with a colon ( : ). In that \+ case Maple will not show the output.\n\n" }}{PARA 263 "" 0 "" {TEXT -1 18 "Modular arithmetic" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 9 "47 mod 5;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "5^(5^5) mod 7;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "1/11 mod 7;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }} {PARA 264 "" 0 "" {TEXT -1 17 "Algebraic numbers" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "alias(w=RootOf(_Z^3 +_Z^2+2));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "w^2;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evala(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "w^3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evala(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "(w^5+3* w+1)/(2*w^4-5*w^3+2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "eva la(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "alias(w=w): \+ # unaliassing" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 265 "" 0 "" {TEXT -1 11 "Polynomials" }}{PARA 0 "" 0 "" {TEXT -1 88 " \nThis shows another important feature of computer algebra systems: sy mbolic computation\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "f:=7*x^4-3* x^3+7*x^2-3*x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "g:=5*x^5+ 3*x^3+x^2-2*x+1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "f+g;" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "f*g;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 10 "expand(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 100 "\nYou see that you must force Maple to expand the product (see also lecture on data representation).\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "gcdex(f,g,x,'s','t');" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "expand(s*f+t*g);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "factor(21*x^5-35*x^4*y+14*x^3*y^3+18*y*x^2-30*x*y^2+1 2*y^4+9*x^3*y^2-15*x^2*y^3+6*x*y^5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "factor(x^105-1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "Factor(x^105-1) mod 7;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "f:=x^6+6*x^5+12*x^4+8*x^3+2*x^2+4*x-4;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "factor(f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "alias(w=RootOf(_Z^3+_Z^2+2));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "evala(Factor(f,w));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "randpoly([x,y],terms=20,degree=7);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "f:='f': g:='g': s:='s': t:=' t': alias(w=w):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 266 "" 0 "" {TEXT -1 18 "Rational functions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "f:=7*x^4-3*x^3+7*x^2-3*x; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "g:=5*x^5+3*x^3+x^2-2*x+ 1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "f/g;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "normal(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "f/g+g/f;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "normal(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "convert(1/f, parfrac,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "f:='f': g:=' g':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 267 "" 0 "" {TEXT -1 17 "General functions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "exp(x+y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "expand(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "simplify(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "sin( x+y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "expand(%);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "F:=x->x^3+5*sin(x^2)+sqrt(x) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "F(10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "F:='F':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 268 "" 0 "" {TEXT -1 31 "Differentiation and i ntegration" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "f:=7*x^4-3*x^3+7*x^2-3*x;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 10 "diff(f,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "diff(x^(x^x),x,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "diff(log(x/(x^2+1)),x,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "normal(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "F:=x->x^3 -sin(x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "op(F);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "\nThe operator `op` returns the op erands of an expression.\n " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "diff (F(x),x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "D(F);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "D(sin);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "'int(7*x^4+3*x^3-5*x+11,x)';" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "%;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "diff(%,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "'int(1/(a+b*sin(x)),x)';" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "%;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "diff(%,x);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "simplify(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "f:='f': F:='F':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 269 "" 0 "" {TEXT -1 33 "Taylor series , Laurent expansions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "taylor(sin(x),x=0,15);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "series(cot(x),x=0,15);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 1 "\n" }}{PARA 270 "" 0 "" {TEXT -1 17 "Solving equations" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "s olve(\{26*x^2-y^3+1=0,2*x-y=-1\},\{x,y\});" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 24 "subs(%[1],26*x^2-y^3+1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "solve(\{x+y=3,a*x+b*y=3*a\},\{x,y\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 156 "\nThis example shows that one has to be \+ careful. If a=b in the system above the solution Maple gives is not th e only solution. What are the other solutions?\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "solve(x^5-x+1=0,x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "fsolve(x^5-x-1,x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 100 "\nWe see that when Maple cannot solve an equation symbolically , you can still solve it numerically.\n\n" }}{PARA 271 "" 0 "" {TEXT -1 30 "Solving differential equations" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "eqn:=diff(y(x),x,x)-y(x);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "dsolve(eqn=0,y(x));" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "eqn:='eqn':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 272 "" 0 "" {TEXT -1 14 "Linea r algebra" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "with(linalg):" }}{PARA 2 "" 1 "" {TEXT -1 71 "Warning : new definition for norm\nWarning: new definition for trace\n" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "A:=matrix([[3,2,1],[4,3,1], [5,4,2]]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "B:=matrix([[3 ,1,0],[4,2,1],[5,2,2]]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalm(A&*B);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalm(A+B) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "inverse(A);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "eval(A);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 310 " \nYou see that the command `A` only gives `A` as an answer. To get the value of the variable `A` you must explicitly ask for it by using the function `eval`. This same feature appears when the value of a variab le is an array, table, procedure or function. Compare this to the vari able `number_of_people` above.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "b:=vector([1,2,3]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "lin solve(A,b);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "A:='A':B:='B ':b:='b':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 273 "" 0 "" {TEXT -1 30 "Plotting, 2- and 3-dimensional" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "plot(sin(x),x=0..5* Pi);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "plot(sin(1/x),x=0.0 1..0.1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "f1:=x; f3:=x-x^ 3/3!; f5:=x-x^3/3!+x^5/5!;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "plot(\{sin(x),f1,f3,f5\},x=0..Pi);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 173 "\nHere you see how the succeeding polynomials are better and better approximations of sin(x) in the origin.\nDo some experimen ts using the menus in the windows of the graphs.\n" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 60 "plot3d(x^2+3*BesselJ(0,y^2)*exp(1-x^2-y^2),x=-2..2, y=-2..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "polarplot(sin(2*t),t=0..2 *Pi);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "\n\nNow we will show som e features of Maple as a programming language.\n\n" }}{PARA 274 "" 0 " " {TEXT -1 10 "Data types" }}{PARA 0 "" 0 "" {TEXT -1 85 "\n- Several \+ kinds of numbers\n- Polynomials\n- Rational functions\n- Series\n\nand further\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 99 "1,4,7,2,4; \+ # \+ Sequence" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 93 "[4,7,3,9,3,3]; \+ \+ # List" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "\{3,4,4,4,5,3,2 ,1\}; \+ # Set" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "`This is a string containing the numbers 1 and 2`; # String" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 88 "array(3..6,[4,8,3,1]); \+ # Array" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "table([(peter)=`11-09-58`,(mary)=`05-12-61`]); \+ # Table" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "34,` Hello`,[array([[1,2],[5,6]]),Pi];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 276 "" 0 "" {TEXT -1 22 "Assignment, evaluation" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "a:=3 ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "b:=a;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "b;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "a:=9;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "b;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "c:=d;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 5 "d:=5;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "c;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "d:=7;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "c;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "''a'';" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "%; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "%;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "a:='a': b:='b': c:='c': d:='d':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 275 "" 0 "" {TEXT -1 18 "Contr ol structures" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 117 "i:=5; b:=3*i+1; \+ # Sequence" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 108 "for i from 2 to 4 do print( i^2) od; # Repetition" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 108 "i:=17; whil e i>=5 do i:=i-5 od; \+ # Repetition" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 108 "i:=-5; if i>=0 then i else -i fi; \+ # Choice" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 180 "maximum:=proc(m,n)\n if m>n then\n m\n else \n n\n fi\nend; \+ # Procedures" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "maximum(9,4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "maximum;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 14 "eval(maximum);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "\nYou see the same feature as with matrices.\n" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 33 "i:='i':b:='b':maximum:='maximum':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "\nMany, many, many,......... built-in procedur es (see the on-line help).\n\n" }}{PARA 258 "" 0 "" {TEXT -1 31 "An ex ample: Fibonacci's numbers" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "fib1:=proc(n)\n if n<2 then\n 1\n else \n fib1(n-2)+fib1(n-1)\n fi\nend;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "fib1(20);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 146 "\nT his is very slow since fib1(n) is computed over and over again (also i n the procedure body). To avoid this one can use Maple's remember opti on.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 91 "fib2:=proc(n)\noption reme mber;\n if n<2 then\n 1\n else\n fib2(n-2)+fib2(n-1)\n fi\nen d;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "fib2(50);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "\nNow each computed value fib2(n) is stor ed and will be retrieved by table lookup.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "fib1:='fib1': fib2:='fib2':" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 1 "\n" }}{PARA 258 "" 0 "" {TEXT -1 10 "Parameters" }} {PARA 0 "" 0 "" {TEXT -1 689 "\nWhen you define a procedure like\n\n \+ f:=proc(a,b) procedure-body end;\n\nthe parameters a and b are cal led formal parameters. When you call this procedure like\n\n f(c,d );\n\nthe parameters c and d are called actual parameters.\n\nMaple us es the call-by-value paramter mechanism. This means that in the call f (c,d); first c and d are evaluated, then the respective values are ass igned to the formal parameters a and b and then the procedure-body is \+ executed. When, in a procedure-body, you want to assign a value to an \+ actual parameter you must be sure the value passed to the procedure is a name (variable). This can be achieved using the single quote to pre vent evaluation. An example:\n " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 63 " f:=proc(a,b,m)\n if a>b then\n m:=a\n else\n m:=b\n fi\nend; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "f(5,2,maximum);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "f(23,6,maximum);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 538 "\nIn the first call maximum evaluates to the name maximum since it has not yet a value. The value 5 is then as signed to maximum during execution of the procedure body. In the secon d call of f the name maximum evaluates to 5 and this value, i.e 5, is \+ passed to the procedure in stead of the name maximum. During execution of the procedure-body an attempt is made to assign 23 to the value 5 \+ and this yields an error message. One can prevent this by not using ma ximum as actual parameter but 'maximum' (this evaluates to the name ma ximum). \n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "f(23,6,'maximum');" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 353 "\nNotice that evaluation insid e a procedure-body is different from outside a procedure-body. Outside a procedure body full evaluation is used, i.e. a name is evaluated as far as possible (except for names for arrays, tables, procedures, etc ). Inside a procedure-body however we only have one-step evaluation. T he following example will make this clear.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "x:=y;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "y:= 3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "f:=proc()\nlocal x,y;\n x:=y;\n y:=3;\n \+ x\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "f();" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "\nTo force further evaluation one can use the eval function.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "f:=proc() \nlocal x,y;\n x:=y;\n y:=3;\n eval(x,2)\nend:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 4 "f();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "f:='f':maximum:='maximum':x:='x':y:='y':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 259 "" 0 "" {TEXT -1 17 "Names (variables )" }}{PARA 0 "" 0 "" {TEXT -1 221 "\nMaple distinguishes between local and global names. A name outside a procedure-body is global. A name i nside a procedure-body is local unless stated otherwise. A local name \+ overrules the same global name. Some examples.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "x:=5; # x is a global name" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "f:=proc() local x; x:=3; print(x) end; # x is local inside the procedure-body" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "f();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "x; \+ # this is again the global x" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 99 "g:=proc() global x; x:=7; print(x) end; # x is now a global name, even inside the procedure-body" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "g();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "x; \+ # g() has changed the value of the global name x" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "\nNotice that global and local names are complete ly different.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "h:=proc() local \+ z; z end;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "h()-z;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "x:='x':f:='f':g:='g':h:='h': " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 260 "" 0 "" {TEXT -1 14 "args and nargs" }}{PARA 0 "" 0 "" {TEXT -1 181 "\nIt is not nec essary to actually mention all formal parameters when defining a proce dure. This is very handy when one does not know the number of paramete rs in advance. An example.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 174 "ma ximum:=proc()\nlocal max; \n if nargs=1 then\n args[1]\n else\n \+ max:=maximum(args[2..nargs]);\n if max > args[1] then\n max\n else\n args[1]\n fi\n fi\nend: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "maximum(34,-6,22,45,12,-9);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 212 "\nWe have used the Maple-routines args and nargs. Inside a procedure-body nargs returns the number of actual parameters when the procedure is called. The routine args returns the list of ac tual parameters itself.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "maximu m:='maximum':" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 202 "\nAs we have se en before you have to use the eval command if you want to see the defi nition of a procedure, defined by yourself, on the screen. This does n ot work for routines inside Maple, for example:\n" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 10 "eval(gcd);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 133 "\nIf you want to see the definition of a Maple routine you first have to give the interface variabale `verboseproc` the right value.\n " }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "interface(verboseproc=2);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "eval(gcd);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "\nIf you want to monitor the execution of a com putation you can increase the printlevel.\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "igcd(56749620128,13112621504);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 15 "printlevel:=10;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "igcd(56749620128,13112621504);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 46 "printlevel:=1; # the default value " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "116 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }