{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 "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 } {CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "2 D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 }{CSTYLE "Help Heading" -1 26 "" 1 14 0 0 0 0 0 1 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 6 6 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 }} {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 29 "An exception to this is that " }{MPLTEXT 0 21 3 "0.0" } {TEXT -1 37 " is always simplified to the integer " }{MPLTEXT 0 21 1 " 0" }{TEXT -1 1 "." }{TEXT -1 55 " Thus you don't get a floating-point result by adding " }{MPLTEXT 0 21 3 "0.0" }{TEXT -1 17 " to a rationa l. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "3.4 - 17/5;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "0.0 + 17/5;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6##\"#< \"\"&" }}}{PARA 0 "" 0 "" {TEXT -1 15 "Multiplying by " }{MPLTEXT 0 21 3 "1.0" }{TEXT -1 42 ", on the other hand, should work, because " } {MPLTEXT 0 21 3 "1.0" }{TEXT -1 34 " is not simplified to the integer \+ " }{MPLTEXT 0 21 1 "1" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "1.0 * 17/5;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+++ ++M!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 419 "However, even if the result \+ is returned in floating point, it does not necessarily mean that the c alculations were all done in floating point. In the following example , the calculation of (1+1/4321)^4321 is done in exact rational arithme tic, and then the result converted to floating point. You can tell th at this is the case because (except on a very fast computer) the calcu lation takes a noticeable amount of time." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "0.1*(1+1/4321)^4321;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+_t'zr#!#5" }}}{PARA 0 "" 0 "" {TEXT -1 175 "On the other hand, \+ in the following case all calculations are done in floating point. Th e result is returned much more quickly (but is not as accurate due to \+ roundoff error)." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "(1+1.0/4 321)^4321;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+1%ozr#!\"*" }}} {PARA 0 "" 0 "" {TEXT -1 750 "Thus the statement \"Putting a decimal p oint in a number causes arithmetic operations involving that number an d rational numbers to be carried out in floating point\" must be inter preted correctly. In evaluating an expression, Maple does a sequence \+ of arithmetic operations (additions, multiplications, etc.). Those th at directly involve a floating-point number (which may be a number wri tten with a decimal point, or the result of another floating-point ope ration) are done in floating point, while those that only involve rat ional numbers are done using exact rational arithmetic. Matters may b e complicated by the fact that the way Maple organizes these operation s may be somewhat different from the way you write the expression. Fo r 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#\"\"!" }}}{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 calculates " }{MPLTEXT 0 21 1 "r" }{TEXT -1 43 " as a floating-point number. The 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 re sult is " }{XPPEDIT 18 0 "0" "6#\"\"!" }{TEXT -1 192 ". You might ex pect the same thing to happen in the second calculation, but it doesn' t: it seems that Maple's preliminary simplification of the input ignor es the parentheses and combines 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 result 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 calcul ation to be done in floating point is to use " }{MPLTEXT 0 21 5 "evalf " }{TEXT -1 144 ". However, this is also affected by automatic simpli fication, which may cause parts of the calculation to be done in exact rational arithmetic." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 3 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 9 "See also:" } {TEXT -1 1 " " }{HYPERLNK 17 "Automatic simplification and evalf" 2 "A utomatic_simplification_and_evalf" "" }{TEXT -1 2 ", " }{HYPERLNK 17 " Digits" 2 "Digits" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "evalf" 2 "evalf " "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Exact vs. floating-point computat ions" 2 "Exact_vs._floating-point_computations" "" }{TEXT -1 2 ", " } {HYPERLNK 17 "Order of operations in floating-point computation" 2 "Or der_of_operations_in_floating-point_computation" "" }{TEXT -1 3 ", " }{HYPERLNK 17 "Roundoff error" 2 "Roundoff_error" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "The meaning of Digits" 2 "The_meaning_of_Digits" "" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 24 "M aple Advisor Database, " }{TEXT -1 15 " R. Israel 1997" }}}}{MARK "1 1 8 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }