{VERSION 2 3 "IBM INTEL NT" "2.3" } {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 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 236 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 6 6 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 225 0 20 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }} {SECT 0 {PARA 18 "" 0 "" {TEXT -1 22 "Assignment Expressions" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 53 "This worksheet \+ is designed to accompany Chapter 3 of " }{TEXT 256 87 "Introduction to Scientific Programming: Computational Problem Solving Using Maple and C" }{TEXT -1 127 " by Joseph L. Zachary. In it, we will use Maple to explore operator precedence and assigment statements in Maple (AW, J an 97)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 10 "Assignment" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 193 "When a number is used several times in a worksheet, it is better to assign a name to that number, rather than retyping it on every occasion. This eliminates errors and speeds up your workrate." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 221 "For example, suppose we \+ are doing computations that involve the population of the earth like w e did in Chapter 2. Rather than typing the number 5.761e9 every time \+ it is used, we can assign its value to a variable, say P:" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "P := 5.761e9 ;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "Similarly, we can assign the land area to a variable, say A:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "A : = 57.8e6;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 167 "The variables A and P will now retain these values for f urther computations in this worksheet. For example, we can compute \+ the number of persons per square mile as " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "P/A;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "Or we could comput e the side length of the square (in feet) that each of us get by" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "528 0 * sqrt(A/P);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 148 "Note that the colon that precedes the equal to sign is an essential part of the assignment statement; it cannot be ignor ed. Execute the assignment" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "B = 14.56e-1;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 26 "followed by the expressi on" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "2*B;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 132 "That did not help much did it? Now insert the colon r ight before the equals sign and reevaluate these two expressions. B etter?" }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 23 "Choosing Variable Names" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 352 "It is a good strategy to pick descriptive names that you can q uickly recall. For example, suppose we need to solve the population \+ density problem of Chapter 2 for the planets Mars and Venus (assuming \+ a means of sustaining the entire population of the earth on these plan ets has been found.) Then it will be good to name these variables a s follows:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "Aearth := 57.8e6; Amars := 56.0e6; Avenus := 177.7e 6;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 63 "(Note how several expressions can be entered on the same line.) " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 192 "Now \+ return to the expressions P/A and 5280*sqrt(A/P) above. Re-execute t hem, with the appropriate variable inserted in place of A, to solve th e population density problem for Mars and Venus." }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 15 "Special Symbols" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 161 "There are a few symbols that ha ve a pre-defined meaning in Maple that you may not use as variable nam es. Maple will warn you should you transgress. For example" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "Pi := 3;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 109 "The problem is that the symbol Pi is reserved for the mathematica l constant 3.14159... If you evaluate this," }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "evalf(Pi);" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 40 "You will se e the first ten digits of Pi." }{MPLTEXT 1 0 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 56 "Observe how you can use G reek letters as variable names:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "alpha := 1;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "omega := 100;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "pi := 22/7;" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 264 "Notice the difference between this pi and the Pi above. The lower case pi is si mply the Greek letter for p, with no special meaning attached to it. \+ The upper case Pi, on the other hand, stands for the ratio between the circumference of a circle and its diameter." }{MPLTEXT 1 0 0 "" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "A useful built-in Maple variable is Digits. It allows you to specify t he mantissa length for floating-point computations. The default value of Digits is 10." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 7 "Digits;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "So a ten-digit computation of 10/3 looks \+ like this:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalf(10/3);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 31 "If we set Digits to 2, however," } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "Di gits := 2;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "We get a result with only two digits" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalf(10/3);" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "an d if we set Digits to 30," }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 13 "Digits := 30;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 31 "we get a result with 30 dig its." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalf(10/3);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 7 "Now try" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "Digits := 2;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "999 - 1;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "99 9. - 1.;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 47 "Explain the difference between the two answers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 209 "When you exper iment with changing the value of Digits, always be sure to reset its v alue to the default value of 10 before continuing. Otherwise, you may get some unpleasant surprises later in your worksheet." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "Digits := 10; " }}}}}{MARK "0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }