{VERSION 3 0 "IBM INTEL NT" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 257 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 269 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 272 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 273 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 274 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 275 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 276 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 277 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 278 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 279 "" 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 280 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 281 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 282 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 283 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 284 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 285 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 286 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 8 2 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Plot" 0 13 1 {CSTYLE "" -1 -1 " " 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 18 "" 0 "" {TEXT -1 5 "Lab 5" }}{PARA 19 "" 0 "" {TEXT -1 35 "Math 181: Computational Mathematics" }}{PARA 19 "" 0 "" {TEXT -1 11 "R. Robinson" }}{PARA 0 "" 0 "" {TEXT -1 10 "9/99, 2/01" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 20 "M aple Number Formats" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "If you type a number without a decimal point, Maple interprets it as an " }{TEXT 257 7 "integer" }{TEXT -1 1 ":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "1024;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 47 "You type evalf to convert it to floating point:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalf(1024);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 42 "Maple also allows numbers to be store d as " }{TEXT 258 8 "rational" }{TEXT -1 9 " numbers " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "22/7;" }{TEXT -1 0 "" }}{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "But Maple au tomatically " }{TEXT 259 7 "reduces" }{TEXT -1 17 " to lowest terms." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "440/(-140);" }{TEXT -1 0 "" }}{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 85 "A rational number in Maple, then, is a pair of integers (that a re relatively prime). " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 262 13 "Theoretically" }{TEXT -1 179 " any rational number \+ can represented but since there is a practical limit to how large an i nteger can be in Maple (the machine integer size: 32 bits for a PC), t his restricts the " }{TEXT 263 8 "accuracy" }{TEXT -1 49 " of the rati onal numbers that can be represented." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT 264 11 "Exercise 1:" }{TEXT -1 64 " See if y ou can discover (about) how big the largest integre is." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 76 "You can convert a rational numbe r to a floating point number using \"evalf\". " }}{PARA 0 "" 0 "" {TEXT -1 2 " " }}{PARA 0 "" 0 "" {TEXT -1 82 "If you type a number wi th a decimal point, Maple automatically interprets it as a " }{TEXT 256 4 "real" }{TEXT -1 23 " floating point number:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "3.14159;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 66 "Maple's floating point numbers are stored with a b ase 10 mantissa." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 149 "Floating point numbers can also be input in (base 10) sc ientific notation. Maple has its own way to normalize floating point n umbers that it outputs." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "6 02e21;" }{TEXT -1 0 "" }}{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 195 "However, Maple represents floating point numbers internally as a pair of integrs (so rationals and floating po int numbers are similar in this respect). Here is the actual data stru cture involved:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 17 "n:=Float(602,23);" }}{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 262 "\nThe following is som e general Maple technique that is useful in this context. The \"op\" c ommand is used to pick off a part of a Maple object. So \"op(1,num);\" should pick off part 1 of num and \"op(2,num)\" should pick off part \+ 2. \"op(0,num)\" reads the object type." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 265 11 "Exercise 2:" }{TEXT -1 152 " Try th is (i.e., op(0,num), op(1,num), op(2,num)) on a few real numbers, inte gers and rationals. This will give you a clue about how Maple really w orks." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 291 "Even though Maple can s tore vary large integers, and floating point constructed out of intege rs, floating point numbers in Maple retain only a fixed number of digi ts in the mantissa. The number of such digits is controlled by an envi ronment variable called \"Digits\". The default value is 10." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 138 "You should rea d the \"Help\" page on \"Float\". In particular, you will note that a \+ floating point number can be a lot bigger than an integer." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 266 11 "Exercise 3:" } {TEXT -1 82 " What is the largest possible floating point number in Ma ple? (Assuming Digits=10)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "Maple has a third kind of nu mber: " }{TEXT 267 8 "hardware" }{TEXT -1 25 " floating point numbers. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalhf(22/7);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "You can get the approximate number of decimal digits of accuracy using:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalhf(Digits);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 241 "This shows that these are pretty much the same as Matlab numbers. Computations with these machine numbers are faster (by a factor of 40 or so) than Maple's ordinary floating point numbers, which are really \"software\" floating point numbers. " }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 39 "Matlab is probably a bit faster still . " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 140 "On the other hand a Fortran or C program is probably 40 times faster sti ll (see Essential Maple by Robert M. Corless, Springer Verlag, 1995." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 268 5 "Note:" }{TEXT -1 314 " There are complicated rules and restriction about usin g Maple's hardware floating point numbers. In particular, it is easy t o \"contaminate\" a hardware number calculation so that it actually ev eluates in software floating point. This will rob your program of the \+ hardware speed advantage. See \"Help\" on this topic." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 269 8 "Comment: " }{TEXT -1 94 " This lab is on Maple numbers, but similar principles \+ apply to other Computer Algebra Systems." }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 28 "Experimenting with accuracy " }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "Let's reduce accuracy to Digits:=2. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 278 "The goal here is to use \+ Maple's control (as a CAS) to do experiments in numerical analysis! In particular, we can force Maple to use a rediculously innaccurate numb er system to illustrate features of all number systems which may be mo re difficult to observe in a better systems." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 71 "As we did in Lecture 3 and Lab \+ 3, we will use quadrature as an example." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "Digits:=2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 46 " A n integral (which we discussed in Lab 3) is:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "Int(1/x,x=1/10..1);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 116 "Note the upper case \"I\" in \"Int\". Th is shows how to get Maple to just print an integral, but not try to ev aluate it." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "Now of course this integral is easy and Maple can just " } {TEXT 260 3 "do " }{TEXT -1 38 "in an exact way. This is a CAS answer. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "int(1/x,x=1/10..1);" } {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "However our task is to experiment with round off error. " }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 64 "To this end we imp lement the trapezoid rule as a function of n. " }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 70 "trap1:=n->(10+sum(2*(1/(1/10+(9*i)/(10*n))),i= 1..n-1)+1)*(9/10)/(2*n);" }{TEXT -1 0 "" }}{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "Before going on, let me ex plain the syntax. The n->... notation defines a " }{TEXT 270 0 "" } {TEXT 271 8 "function" }{TEXT 272 0 "" }{TEXT -1 53 " of n. This is es sentially a simple Maple \"program\". " }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 119 "Unlike MATLAB, we can enter a progra m right inside the Maple GUI. This is convenient for short programs li ke this one. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 182 "More complicated programs can also be edited inside sepa rate files and read in. As we will see below Maple has all the usual p rogramming control structures (loops, conditions, etc.)." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 79 "Note that the inte grand (the unction f(x)=1/x) is built in to this expression. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 78 "You might want to verify this is a correct implemtation of the trapezoid rule. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 83 "Now t ry evaluating this. Replace the 12's with some other numbers. Look at \+ the plot" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "trap1(12);" } {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "evalf(%);" } {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "err1:=n->ab s(evalf(trap1(n))-evalf(log(10)));" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 9 "err1(12);" }{TEXT -1 0 "" }}{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "list1:=[seq ([n,err1(n)],n=1..12)];" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "plot(list1);" }{TEXT -1 0 "" }} {PARA 13 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 273 11 "Exercise 3:" }{TEXT -1 216 " The error here seems less than theory mi ght predict. In particular, we see the truncation error but not the ro und-off error. Note the \"rational\" outputs from trap1. Can you expla in what Maple is actually doing here?" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 182 "Hint: Plug \"n\" into 'err1\" instea d of a number. Look up the Greek letter you see in \"Help\". You might also look up \"sum\". It is less straightforward than might appear on the surface." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 155 "The answer to this question explains why a more sophisti cated approach is necessary if we want to do \"numerical analysis\" ex periments with a CAS (Maple). " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 193 "Here is a different approach, which more closely resembles traditional programming. It also illustrates some M aple features, including control structures and how to pass functions \+ to functions." }}}{PARA 11 "" 1 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 111 "trapc:=proc(k,n) # Makes the coeffs 1,2,2,2,. ..,1 \n if k=1 or k=n then \n 1; \n else \n 2; \n fi \n en d;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 176 "trap2 :=proc(n,a,b,fun) # Implements the trapezoid rule.\n local h,s,i;\n \+ s:=0;\n h:=(b-a)/n;\n for i from 0 to n do\n s:=s+trapc(k,n) *fun(a+i*h);\n od;\n (s*h)/2;\nend;" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "rec:=x ->1/x; # The function" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "trap2(12.3,.1,1,rec);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "err2:=n->abs(trap2(n,.1,1,rec)-eval f(log(10)));" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "err2(12);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "list2:=[seq ([n,err2(n)],n=1..100)];" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "plot(list2);" }{TEXT -1 0 "" }}{PARA 13 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 274 11 "Exercise 4." }{TEXT -1 220 " Try several different values of n and different numbers of digits. Try some diffe rent functions. What sort of functions would likely lead to round off \+ errors? Write a short text explaining your results and observations." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 21 "Example from robotics" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "The main point of a CAS is that it can solve big systems \+ of equations exactly. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 51 "We will now illustrate this point with an example. \+ " }}{PARA 4 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "This example comes from " }{TEXT 261 28 "Computer Algebra in Indus try" }{TEXT -1 74 " by Arjeh M. Cohen, Wiley (1993). The discussion th ere is more extensive. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 97 "This problem concerns a robotic arm with two links a nd three segments (see the picture in class)." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "We want to find values for a1, a2 and a3 (i.e., design an arm) so that if the " }{TEXT 275 5 "crank" }{TEXT -1 55 " has a sp ecific angular velocity and acceleration, the " }{TEXT 276 8 "follower " }{TEXT -1 66 " will also have a specified velocity and acceleration \+ (see below)." }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 7 "Algebra" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 131 "siderels:=\{x1=-a1*cos(phi), y1=a1*sin(phi) , x2=-a4-a3*cos(psi), \ny2=a3*sin(psi), cos(phi)^2+sin(phi)^2=1, cos(p si)^2+sin(psi)^2=1\};" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "vars:=[x1,x2,y1,y2,a1,a 2,a3,a4,cos(phi),sin(phi),cos(psi),sin(psi)];" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 " equn1:=(x2-x1)^2+(y2-y1)^2=a2^2;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 36 "exp1:=simplify(equn1,siderels,vars);" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 85 "See \"Help\" to understand this useful command. Note that the siderels were input as a " }{TEXT 277 3 "set" }{TEXT -1 17 " (cur ly bracket: " }{TEXT 278 9 "unordered" }{TEXT -1 1 " " }{TEXT 280 4 "d ata" }{TEXT -1 35 "), wheras the vars were input as a " }{TEXT 279 4 " list" }{TEXT -1 18 " (square bracket: " }{TEXT 281 7 "ordered" }{TEXT -1 1 " " }{TEXT 282 4 "data" }{TEXT -1 2 ")." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "exp2:=combine(exp1,'trig');" }{TEXT -1 0 "" }} {PARA 12 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 127 "Here we have applied trig identities. Next we use a library function \+ called \"isolate\" that we need to read in before we use it." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "readlib(isolate);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "exp3:=isolate(exp 2,cos(phi-psi));" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "collect(exp3,\{cos(psi),cos( phi)\});" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 111 "Note the form of the RHS: \"-K1*cos(psi)+K2*Cos(phi)+K3. Now we solve explicit ly for psi (with dummy variables):" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "exp4:=solve(cos(phi-psi)=-K 1*cos(phi)+K2*cos(psi)+K3,psi);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 171 "A careful examination of this (massive) output will reveal two solutions. These correspond to two positions of the linkag e. We concentrate on the first, psi+ (or psiplus)." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "exp5:=exp4[1];" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "exp6:=subs(sin(phi)^2=1-cos(phi)^2, exp5);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "ps iplus:=simplify(exp6);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 64 "This shows how psi depends on theta, exactly. Pretty impr essive!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 8 "Calculus" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 94 "Now we define some \"aliases\" for psi and phi as functions of \+ t, as well as their derivatives. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 63 "(Note the I. Maple comes with one built i n alias I=(-1)^(1/2).)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 122 " alias(\nphi=phi(t),psi=psi(t), \nw_phi=diff(phi(t),t), w_psi=diff(psi( t),t),\na_phi=diff(phi(t),t$2),a_psi=diff(psi(t),t$2));" }{TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "eqn1:=cos(phi-psi)=-K1* cos(phi)+K2*cos(psi)+K3;" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "eqn2:=diff(eqn1,t);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "eqn3:=diff(eqn1,t$2);" }{TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "eqns:=\{eqn.(1..3)\}; #Note \+ some interesting syntax here" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 65 "Here we see the purpose of the aliases: implicit differ entiation." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "sol:=solve(eq ns,\{K1,K2,K3\});" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 285 11 "Exercise 5:" }{TEXT 286 1 " " } {TEXT -1 91 "The next line is a bit of a cheat! Can you figure out a w ay to do it using Maple commands? " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "sys:=\{K1=a4/a3, K2=a4/a1, K3=(a1^2+a3^2+a4^2-a2^2)/( 2*a1*a3)\};" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "solutions:=solve(sys,\{a1,a2,a3\});" }{TEXT -1 0 "" }}{PARA 12 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 94 "The RootOf i n the output indicates a root of a polynomial equation with no algebra ic solution." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 63 "Now we input the design specifications from the Cohen article. \+ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 144 "Name ly, when the crank is upright and moving forward with a uniform veloci ty, the follower is also upright and moving forward, but accelerating. " }}}{PARA 11 "" 1 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 71 "values:=\{phi=Pi/2, w_phi=3, a_phi=0, psi=Pi/2, w_psi =6/5, a_psi=81/50\};" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "kvals:=eval(subs(values,sol));" }{TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "assign(kvals);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "subs(\{RootOf(_Z^2-4)=2,a4=4\},solu tions);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 64 "Comment : There must be a better way to do this! Can you find it?" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "assign(%); a4:=4; " }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "psiplus;" }{TEXT -1 0 "" } }{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "alias(phi=phi); #Turn phi back into a variable!" }{TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(psiplus,phi=0..2*P i);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 283 11 "Exercise 6:" }{TEXT -1 52 " Can you fix this plot so it does not have the jump?" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "We can also draw the crank:" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "phi: =Pi/3; " }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "x 1:=evalf(-a1*cos(phi)); y1:=evalf(a1*sin(phi));" }{TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "x2:=evalf(-a4-a3*cos(psiplus )); y2:=evalf(a3*sin(psiplus));" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 49 "plot([[0,0],[x1,y1],[x2,y2],[-a4,0]],style=LIN E);" }{TEXT -1 0 "" }}{PARA 13 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 284 11 " Exercise 7:" }{TEXT -1 91 " Show the arm in a few other positions. (Fo r a real challenge consider doing an animation!)" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 277 "Comment: For some reason Maple seems to choose different orders for the two solutions p si+ and psi- different times (at least for me). If you get psi- by mis take you can go back to the algebra section and make the opposite choi ce. This should not happen, but sometimes it does!" }}}}}}{MARK "7" 0 }{VIEWOPTS 1 1 0 3 2 1804 }