{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 "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 }{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 }}
{SECT 0 {PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT
26 8 "Advice: " }{TEXT -1 14 "Roundoff error" }}{PARA 0 "" 0 "" {TEXT
-1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 302 "\"Real\" numbers are generally
represented in computers using floating-point arithmetic, which is s
imilar to so-called \"scientific notation\". While most computers use
a base-2 system in their \"hardware floats\", Maple uses base 10. Th
us a nonzero floating-point number could be represented in the form "
}{MPLTEXT 0 21 15 "(+ or -) r*10^k" }{TEXT -1 7 " where " }{XPPEDIT
18 0 "k" "I\"kG6\"" }{TEXT -1 34 ", the exponent, is an integer and "
}{XPPEDIT 18 0 "r" "I\"rG6\"" }{TEXT -1 35 ", the mantissa, is in the \+
interval " }{XPPEDIT 18 0 "0.1 <= r *`<`* 1" "1$\"\"\"!\"\"*(%\"rGF$%
\" " 0 "" {MPLTEXT 1 0 28 "Digits:= \+
4: evalf(Pi*76.54);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"%0C!\"\"" }}
}{PARA 0 "" 0 "" {TEXT -1 476 "Maple's built-in functions are also sub
ject to roundoff error when they operate on floating-point numbers. I
n most cases what is computed is an approximation to the function (usi
ng a few more digits than Digits), and then the result is rounded. Th
is usually results in the correct rounded value of the function, but o
nce in a while it may be off by a digit or two. In the example below,
the correct value with Digits=14 would end in 27, but the computed va
lue ends in 31. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "x := 1.
5707963267949: \nevalf(tan(x),14);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#
$!/J`&>2z&H\"\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "evalf(
tan(x),20); evalf(\",14);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!5x1PF`&
>2z&H!\"&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!/F`&>2z&H\"\"\"" }}}
{PARA 0 "" 0 "" {TEXT -1 361 " The error in a calculation can be measu
red in two ways: the absolute error is the magnitude of the difference
between the true value and the approximation, while the relative erro
r is the absolute error divided by the magnitude of the true value. I
n many cases, the relative error is the more useful (of course, it is \+
not much use when the true value is 0). " }}{PARA 0 "" 0 "" {TEXT -1
0 "" }}{PARA 0 "" 0 "" {TEXT -1 215 "Multiplication and division do no
t cause too many problems of accuracy, because they have little effect
on relative error. For addition and subtraction, on the other hand, \+
there are two important problems to note.\n" }}{PARA 0 "" 0 "" {TEXT
-1 257 "The first is that when two numbers of very different magnitude
s are added, many of the digits of the smaller one will have no effect
on the result. This means that calculating a sum of very many, very \+
small quantities can lead to very inaccurate results. " }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "Digits:= 4: add(4./9000,i=1..900);
" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"%#p$!\"%" }}}{PARA 0 "" 0 ""
{TEXT -1 40 "The correct result, of course, would be " }{XPPEDIT 18 0
"0.4" "$\"\"%!\"\"" }{TEXT -1 77 ". But when the total gets to .1, ea
ch addition of 4./9000 = .000444... with " }{MPLTEXT 0 21 10 "Digits =
4" }{TEXT -1 127 " has only the effect of adding .0004. Even more st
rikingly, when the total gets to 1, further additions have no effect a
t all." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "add(4./9000,i=1..9
000);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"%+5!\"$" }}}{PARA 0 "" 0 "
" {TEXT -1 133 "The second problem is that subtraction of two nearly e
qual quantities will result in a large relative error. For example,st
ill with " }{MPLTEXT 0 21 10 "Digits = 4" }{TEXT -1 1 ":" }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "4.322-4.321;" }}{PARA 11 "" 1 ""
{XPPMATH 20 "6#$\"\"\"!\"$" }}}{PARA 0 "" 0 "" {TEXT -1 464 "This in i
tself is a completely correct calculation, with no roundoff. But if o
ne or both of the numbers 4.322 and 4.321 are approximations for other
numbers, the relative error in the difference may be very large. For
example, the true values might be 4.3216 and 4.3214 respectively, so \+
the true difference is .0002, for a huge relative error of 4. One pla
ce where this can cause unexpected problems is in the standard formula
for solving a quadratic equation:\n" }{XPPEDIT 18 0 "r[`-`] = (-b - s
qrt(b^2-4*a*c))/(2*a), r[`+`] = (-b+sqrt(b^2-4*a*c))/(2*a)" "6$/&%\"rG
6#%\"-G*&,&%\"bG!\"\"-%%sqrtG6#,&*$F*\"\"#\"\"\"*(\"\"%F2%\"aGF2%\"cGF
2F+F+F2*&F1F2F5F2F+/&F%6#%\"+G*&,&F*F+-F-6#,&*$F*F1F2*(F4F2F5F2F6F2F+F
2F2*&F1F2F5F2F+" }}{PARA 0 "" 0 "" {TEXT -1 8 "Suppose " }{XPPEDIT 18
0 "b" "I\"bG6\"" }{TEXT -1 36 " is positive, and large compared to " }
{XPPEDIT 18 0 "a" "I\"aG6\"" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "c" "I
\"cG6\"" }{TEXT -1 8 ". Then " }{XPPEDIT 18 0 "sqrt(b^2 -4* a* c)" "-
%%sqrtG6#,&*$%\"bG\"\"#\"\"\"*(\"\"%F)%\"aGF)%\"cGF)!\"\"" }{TEXT -1
16 " will be nearly " }{XPPEDIT 18 0 "b" "I\"bG6\"" }{TEXT -1 26 ". Al
though it's fine for " }{XPPEDIT 18 0 "r[`-`]" "&%\"rG6#%\"-G" }
{TEXT -1 55 ", the formula can produce a relatively very inaccurate "
}{XPPEDIT 18 0 "r[`+`]" "&%\"rG6#%\"+G" }{TEXT -1 20 ". We'll try it \+
for " }{XPPEDIT 18 0 "a=c" "/%\"aG%\"cG" }{XPPEDIT 18 0 "``=1" "/%!G\"
\"\"" }{TEXT -1 6 " and " }{XPPEDIT 18 0 "b = 130, 13000,1300000" "6%
/%\"bG\"$I\"\"&+I\"\"(++I\"" }{TEXT -1 7 " with " }{MPLTEXT 0 21 11 "
Digits = 10" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
120 "Digits:= 10: \nr[`-`]:= b -> (-b - sqrt(b^2-4))/2: \nr[`+`]:= b -
> (-b + sqrt(b^2-4))/2:\nblist:= [130., 13000., 1300000.]:" }}}{PARA
0 "" 0 "" {TEXT -1 25 "Here are the results for " }{XPPEDIT 18 0 "r[`-
`]" "&%\"rG6#%\"-G" }{TEXT -1 10 " at these " }{XPPEDIT 18 0 "b" "I\"b
G6\"" }{TEXT -1 8 " values:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
18 "map(r[`-`],blist);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%$!+tI#**H
\"!\"($!+$******H\"!\"&$!+++++8!\"$" }}}{PARA 0 "" 0 "" {TEXT -1 6 "Us
ing " }{MPLTEXT 0 21 6 "fsolve" }{TEXT -1 6 " with " }{MPLTEXT 0 21
11 "Digits = 20" }{TEXT -1 75 " confirms that these are accurate to ne
arly 10 digits (the final digits of " }{XPPEDIT 18 0 "r[`-`](130)" "-&
%\"rG6#%\"-G6#\"$I\"" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "r[`-`](13000
)" "-&%\"rG6#%\"-G6#\"&+I\"" }{TEXT -1 15 " are off by 1)." }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "Digits:= 20: map(b -> min(fsolve(x^
2+b*x+1,x)),blist);\nDigits:= 10:" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7
%$!5)Go(3PsI#**H\"!#<$!5AE#p2B******H\"!#:$!5#p2B**********H\"!#8" }}}
{PARA 0 "" 0 "" {TEXT -1 13 "However, the " }{XPPEDIT 18 0 "r[`+`]" "&
%\"rG6#%\"+G" }{TEXT -1 46 " results are much poorer in relative accur
acy." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "map(r[`+`],blist);"
}}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%$!'v#p(!\")$!#v!\"'\"\"!" }}}
{PARA 0 "" 0 "" {TEXT -1 13 "According to " }{MPLTEXT 0 21 6 "fsolve"
}{TEXT -1 34 ", we have five correct digits for " }{XPPEDIT 18 0 "b = \+
130" "/%\"bG\"$I\"" }{TEXT -1 10 ", one for " }{XPPEDIT 18 0 "b = 1300
0" "/%\"bG\"&+I\"" }{TEXT -1 14 " and none for " }{XPPEDIT 18 0 "b = 1
300000" "/%\"bG\"(++I\"" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 67 "Digits:= 20: map(b -> max(fsolve(x^2+b*x+1,x)),blist)
;\nDigits:= 10:" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7%$!54K;rJ7Hw#p(!#A
$!5.T1V#yt2Bp(!#C$!5!pRC7Bp2Bp(!#E" }}}{PARA 0 "" 0 "" {TEXT -1 21 "A \+
better formula for " }{XPPEDIT 18 0 "r[`+`]" "&%\"rG6#%\"+G" }{TEXT
-1 71 " in this case exploits the fact that the product of the two roo
ts is 1." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "s:= unapply(norm
al(1/r[`-`](b)),b);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"sG:6#%\"bG6
\"6$%)operatorG%&arrowGF(,$*$,&9$\"\"\"*$,&*$F/\"\"#F0!\"%F0#F0F4F0!\"
\"!\"#F(F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "map(s,blist);
" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%$!+7Hw#p(!#7$!+OxI#p(!#9$!+#p2Bp
(!#;" }}}{PARA 0 "" 0 "" {TEXT -1 119 "There is no subtraction of near
ly equal quantities here, and the results have 10, 9 and 10 correct di
gits respectively." }}}{PARA 3 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA
0 "" 0 "" {TEXT 26 9 "See also:" }{TEXT -1 1 " " }{HYPERLNK 17 "Automa
tic simplification and evalf" 2 "Automatic_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 computations" 2 "Exact_vs_floating-point_comp
utations" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Forcing floating-point ar
ithmetic" 2 "Forcing_floating-point_arithmetic" "" }{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 3
2 0" 119 }{VIEWOPTS 1 1 0 1 1 1803 }