{VERSION 4 0 "IBM INTEL NT" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 1 }{CSTYLE "Help Head ing" -1 26 "" 1 14 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 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 1 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 8 "Advice: " }{TEXT -1 37 "Exact vs. floating-point computations" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 154 "Maple c an use exact arithmetic, where rational numbers are expressed as fract ions and irrational numbers are expressed using symbolic expressions s uch as " }{XPPEDIT 18 0 "sqrt(2*Pi)" "6#-%%sqrtG6#*&\"\"#\"\"\"%#PiGF( " }{TEXT -1 54 ", or floating-point arithmetic, where numbers such as \+ " }{XPPEDIT 18 0 "2.506628274" "6#$\"+u#Gm]#!\"*" }{TEXT -1 336 " are \+ expressed using a certain number of decimal places. It is often impor tant to decide which of these is more appropriate in a particular prob lem. Often there is a tradeoff to consider: exact arithmetic avoids a ny problems of roundoff error, but can be much slower than floating-po int and may result in very complicated expressions." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 408 "The following is an ex ample of exact arithmetic. To save space, the result has been deleted from this help page: it is a fraction where both numerator and denomi nator have 15710 digits. This example should be no problem to calcula te (except that it takes more than one screen to write), but it is eas y to construct similar examples that will use up all available memory \+ or take a very long time to compute." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "(1+1/4321)^4321;" }}}{PARA 0 "" 0 "" {TEXT -1 258 "Ty pically, however, all you really want is a few decimal places of the a nswer. For this purpose it is better to do the calculation in floatin g point. A numerical expression involving a number with a decimal po int is evaluated in floating point (but see " }{HYPERLNK 17 "Forcing floating-point arithmetic" 2 "Forcing_floating-point_arithmetic" "" } {TEXT -1 24 "). Thus you could use " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "(1+1./4321)^4321;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# $\"+1%ozr#!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 82 "This is calculated ver y quickly, and the answer is in a much more convenient form." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 208 "The main disad vantage of floating point arithmetic is roundoff error. The calculati on above is one in which the roundoff error is rather severe, due to t he fact that we are adding a relatively small number (" }{MPLTEXT 0 21 22 "1./4321=.0002314279102" }{TEXT -1 29 ") to a relatively large o ne (" }{MPLTEXT 0 21 1 "1" }{TEXT -1 147 "), and losing significant di gits in the process. This can be remedied by doing the calculation wi th a larger setting of the environment variable " }{MPLTEXT 0 21 6 "D igits" }{TEXT -1 70 ", which controls the number of decimal digits use d in the calculation." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "Dig its:= 15:\nr:= (1+1./4321)^4321:\nDigits:= 10:\nevalf(r);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+_t'zr#!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 181 "There are some cases, however, in wh ich even a very accurate floating-point approximation is no good, and \+ exact arithmetic is necessary. Suppose, for example, we want to calcu late " }{XPPEDIT 18 0 "Limit(f(x)*(x-a), x = a) " "6#-%&LimitG6$*&-%\" fG6#%\"xG\"\"\",&F*F+%\"aG!\"\"F+/F*F-" }{TEXT -1 7 " where " } {XPPEDIT 18 0 "f(x)" "6#-%\"fG6#%\"xG" }{TEXT -1 22 " is some function and " }{XPPEDIT 18 0 "a" "6#%\"aG" }{TEXT -1 18 " some number with " }{XPPEDIT 18 0 "f(x) -> infinity" "6#R6#-%\"fG6#%\"xG7\"6$%)operatorG% &arrowG6\"%)infinityGF-F-F-" }{TEXT -1 4 " as " }{XPPEDIT 18 0 "x -> a " "6#R6#%\"xG7\"6$%)operatorG%&arrowG6\"%\"aGF*F*F*" }{TEXT -1 50 ". \+ Maple may be able to calculate it correctly if " }{XPPEDIT 18 0 "a" "6 #%\"aG" }{TEXT -1 105 " is given as an exact expression. But if inste ad you give Maple an inexact floating-point approximation " }{XPPEDIT 18 0 "b" "6#%\"bG" }{TEXT -1 16 " of the correct " }{XPPEDIT 18 0 "a" "6#%\"aG" }{TEXT -1 24 ", it will tell you that " }{XPPEDIT 18 0 "Limi t(f(x)*(x-b),x=b) = 0" "6#/-%&LimitG6$*&-%\"fG6#%\"xG\"\"\",&F+F,%\"bG !\"\"F,/F+F.\"\"!" }{TEXT -1 49 ". This is in a sense perfectly corre ct (because " }{XPPEDIT 18 0 "f(x)" "6#-%\"fG6#%\"xG" }{TEXT -1 34 " a pproaches some finite number as " }{XPPEDIT 18 0 "x -> b" "6#R6#%\"xG7 \"6$%)operatorG%&arrowG6\"%\"bGF*F*F*" }{TEXT -1 33 "), but it is not \+ what you wanted." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "f:= x -> 1/sin(x):\nlimit(f(x)*(x-Pi), x = Pi);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#!\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "b:= evalf(Pi ,20);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"5&QKz*e`EfTJ!#>" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "limit(f(x)*(x-b), x = b);" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 9 "See also:" }{TEXT -1 1 " " }{HYPERLNK 17 "Automatic simpli fication and evalf" 2 "Automatic_simplification_and_evalf" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Digits" 2 "Digits" "" }{TEXT -1 1 "," }{TEXT -1 1 " " }{HYPERLNK 17 "evalf" 2 "evalf" "" }{TEXT -1 2 ", " } {HYPERLNK 17 "Forcing floating-point arithmetic" 2 "Forcing_floating-p oint_arithmetic" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Roundoff error" 2 "Roundoff_error" "" }{TEXT -1 3 ", " }{HYPERLNK 17 "The meaning of Di gits" 2 "The_meaning_of_Digits" "" }}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 24 "Maple Advisor Database, " }{TEXT -1 15 " R. Israel 1997" }}}} {MARK "3" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }