{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 33 "Forcing floating-point arithmetic" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 158 "Putting \+ a decimal point in a number causes arithmetic operations involving tha t number and rational numbers to be carried out in floating point. Fo r example:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "3.4 - 12/5;" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+++++5!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 419 "However, even if the result is returned in floating poin t, it does not necessarily mean that the calculations were all done in floating point. In the following example, the calculation of (1+1/43 21)^4321 is done in exact rational arithmetic, and then the result con verted to floating point. You can tell that this is the case because \+ (except on a very fast computer) the calculation takes a noticeable am ount of time." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "0.1*(1+1/54 321)^54321;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+3oD=F!#5" }}}{PARA 0 "" 0 "" {TEXT -1 175 "On the other hand, in the following case all c alculations are done in floating point. The result is returned much m ore quickly (but is not as accurate due to roundoff error)." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "(1+1.0/54321)^54321;" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#$\"+.SC=F!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 750 " Thus the statement \"Putting a decimal point in a number causes arithm etic operations involving that number and rational numbers to be carri ed out in floating point\" must be interpreted correctly. In evaluati ng an expression, Maple does a sequence of arithmetic operations (addi tions, multiplications, etc.). Those that directly involve a floating -point number (which may be a number written with a decimal point, or \+ the result of another floating-point operation) are done in floating p oint, while those that only involve rational numbers are done using e xact rational arithmetic. Matters may be complicated by the fact that the way Maple organizes these operations may be somewhat different fr om the way you write the expression. For example: " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "p:= .333333: r:= 1000+p; r - 3001/3;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"rG$\"+LLL+5!\"'" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#$\"\"!F$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "(1000+p)-3001/3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!%LL!#5" }}} {PARA 0 "" 0 "" {TEXT -1 43 "In the first calculation, Maple calculate s " }{MPLTEXT 0 21 1 "r" }{TEXT -1 43 " as a floating-point number. T he fraction " }{MPLTEXT 0 21 6 "3001/3" }{TEXT -1 44 ", when converted to floating point, becomes " }{XPPEDIT 18 0 "1000.333333" "6#$\"+LLL+ 5!\"'" }{TEXT -1 27 " as well, so the result is " }{XPPEDIT 18 0 "0" " 6#\"\"!" }{TEXT -1 192 ". You might expect the same thing to happen \+ in the second calculation, but it doesn't: it seems that Maple's preli minary simplification of the input ignores the parentheses and combine s the " }{XPPEDIT 18 0 "1000" "6#\"%+5" }{TEXT -1 10 " with the " } {MPLTEXT 0 21 7 "-3001/3" }{TEXT -1 1 "," }{TEXT -1 35 " so that the r esult is the same as " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "p - \+ 1/3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!%LL!#5" }}}{PARA 0 "" 0 "" {TEXT -1 76 "The other way to cause a calculation to be done in floati ng point is to use " }{MPLTEXT 0 21 5 "evalf" }{TEXT -1 144 ". Howeve r, this is also affected by automatic simplification, which may cause \+ parts of the calculation to be done in exact rational arithmetic." }}} {SECT 0 {PARA 0 "" 0 "" {TEXT 26 9 "See also:" }{TEXT -1 1 " " } {HYPERLNK 17 "Automatic simplification and evalf" 2 "Automatic_simplif ication_and_evalf" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Digits" 2 "Digit s" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "evalf" 2 "evalf" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Exact vs. floating-point computations" 2 "Exact_vs ._floating-point_computations" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Orde r of operations in floating-point computation" 2 "Order_of_operations_ in_floating-point_computation" "" }{TEXT -1 3 ", " }{HYPERLNK 17 "Rou ndoff error" 2 "Roundoff_error" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "The meaning of Digits" 2 "The_meaning_of_Digits" "" }}}{SECT 0 {PARA 0 " " 0 "" {TEXT 26 24 "Maple Advisor Database, " }{TEXT -1 15 " R. Israel 1997" }}}}{MARK "1 13 2" 45 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }