{VERSION 6 0 "IBM INTEL NT" "6.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 2 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 "Help Normal" -1 30 "Times" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 35 "" 0 1 104 64 92 1 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "Blue Emphasis" -1 256 "Times" 0 0 0 0 255 1 0 1 0 0 0 0 0 0 0 1 }{CSTYLE " Green Emphasis" -1 257 "Times" 1 12 0 128 0 1 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "Maroon Emphasis" -1 258 "Times" 1 12 128 0 128 1 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "Purple Emphasis" -1 259 "Times" 1 12 102 0 230 1 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "Red Emphasis" -1 260 "Times" 1 12 255 0 0 1 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" 258 261 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 258 262 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" 258 263 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 258 264 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "Dark Red Emphasi s" -1 265 "Times" 1 12 128 0 0 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" 260 266 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" 265 267 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 258 268 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 270 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "Grey Em phasis" -1 271 "Times" 1 12 96 52 84 1 0 1 0 0 0 0 0 0 0 0 }{CSTYLE " " -1 272 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 273 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 274 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 275 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 276 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 258 277 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 278 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 279 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "" -1 280 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 281 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 0 282 "" 1 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 283 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 284 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 285 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 286 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 287 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 288 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 289 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 265 290 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" 265 291 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 271 292 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 265 293 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 271 294 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 271 295 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 271 296 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 271 297 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 265 298 " " 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 299 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 30 300 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 30 301 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 302 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 303 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 304 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 305 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 306 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 307 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 308 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE " " -1 309 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 310 " System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 311 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 312 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 313 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 314 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 315 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE " " -1 316 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 317 " System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 318 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 319 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 320 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 321 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 322 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 323 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 324 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 258 325 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 326 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 327 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 328 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 329 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 330 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 331 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE " " -1 332 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 258 333 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 258 334 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 265 335 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" 265 336 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 337 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 338 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 339 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 340 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" 35 341 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 342 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 343 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 344 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 345 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" 35 346 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 347 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 348 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 349 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 350 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 351 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 352 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 353 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 354 "System" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 355 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 356 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 357 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 358 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 359 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 35 360 "" 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 128 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 3 0 3 0 2 2 0 1 }{PSTYLE "Heading 2" -1 4 1 {CSTYLE "" -1 -1 "Time s" 1 14 128 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 2 1 0 1 0 2 2 0 1 } {PSTYLE "Maple Output" -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Bullet Item " -1 15 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 } 1 1 0 0 3 3 1 0 1 0 2 2 15 2 }{PSTYLE "Fixed Width" -1 17 1 {CSTYLE " " -1 -1 "Courier" 1 10 0 0 0 1 2 2 2 2 2 2 3 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 17 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Norma l" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {PARA 3 "" 0 "" {TEXT -1 33 "Maple's floating-point arithmetic " }}{PARA 0 "" 0 "" {TEXT -1 37 "by Peter Stone, Nanaimo, B.C., Canada " }}{PARA 0 "" 0 "" {TEXT -1 19 "Version: 24.3.2007" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 63 "Floating point numbers and the precision of computer a rithmetic" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 " " 0 "" {TEXT -1 10 "A decimal " }{TEXT 259 21 "floating-point number" }{TEXT -1 27 " f is a number of the form:" }}{PARA 256 "" 0 "" {TEXT -1 3 " " }{XPPEDIT 18 0 "f = `+`;" "6#/%\"fG%\"+G" }{TEXT -1 5 " 0 . " }{XPPEDIT 18 0 "d[1]*d[2]*` . . . `*d[k]*`.`*10^e" "6#*.&%\"dG6#\" \"\"F'&F%6#\"\"#F'%(~.~.~.~GF'&F%6#%\"kGF'%\".GF')\"#5%\"eGF'" }{TEXT -1 8 " or " }{XPPEDIT 18 0 "f = ``;" "6#/%\"fG%!G" }{XPPEDIT 18 0 "-0" "6#,$\"\"!!\"\"" }{TEXT -1 3 " . " }{XPPEDIT 18 0 "d[1]*d[2]*` . \+ . . `*d[k]*`.`*10^e" "6#*.&%\"dG6#\"\"\"F'&F%6#\"\"#F'%(~.~.~.~GF'&F%6 #%\"kGF'%\".GF')\"#5%\"eGF'" }{TEXT -1 1 "," }}{PARA 0 "" 0 "" {TEXT -1 6 "where " }}{PARA 15 "" 0 "" {XPPEDIT 18 0 "d[1],d[1],` . . . `,d[ k];" "6&&%\"dG6#\"\"\"&F$6#F&%(~.~.~.~G&F$6#%\"kG" }{TEXT -1 31 " are \+ the decimal digits of the " }{TEXT 259 8 "mantissa" }{TEXT -1 2 " " } {XPPEDIT 18 0 "m=0" "6#/%\"mG\"\"!" }{TEXT -1 3 " . " }{XPPEDIT 18 0 " d[1]*d[2]*` . . . `*d[k];" "6#**&%\"dG6#\"\"\"F'&F%6#\"\"#F'%(~.~.~.~G F'&F%6#%\"kGF'" }{TEXT -1 6 ", and " }}{PARA 15 "" 0 "" {TEXT -1 12 "t he integer " }{TEXT 270 1 "e" }{TEXT -1 8 " is the " }{TEXT 259 8 "exp onent" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 38 "A floating-point number is said to be " }{TEXT 259 10 "normalised" }{TEXT -1 4 " if " }{XPPEDIT 18 0 "d[1] <> 0;" "6#0&%\"dG 6#\"\"\"\"\"!" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT 267 8 "Examples " }{TEXT -1 2 ": " }}{PARA 0 "" 0 "" {TEXT -1 3 " 0" }{XPPEDIT 18 0 " .3141592654*`.`*10^(-2);" "6#*(-%&FloatG6$\"+aEfTJ!#5\"\"\"%\".GF))\"# 5,$\"\"#!\"\"F)" }{TEXT -1 5 ", 0" }{XPPEDIT 18 0 ".1414213562*`.`*1 0^(-8);" "6#*(-%&FloatG6$\"+iN@99!#5\"\"\"%\".GF))\"#5,$\"\")!\"\"F)" }{TEXT -1 5 ", 0" }{XPPEDIT 18 0 ".1282248765*`.`*10^50;" "6#*(-%&Fl oatG6$\"+l([AG\"!#5\"\"\"%\".GF)\"#5\"#]" }{TEXT -1 21 " are all norm alised." }}{PARA 0 "" 0 "" {TEXT -1 17 " 0.001282248765 " }{TEXT 269 1 "." }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^52;" "6#*$\"#5\"#_" }{TEXT -1 45 " is an unnormalised form of the last number." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 107 "We assume that zero is a floating-point number represented by taking both the mantissa and e xponent to be 0" }}{PARA 0 "" 0 "" {TEXT -1 74 "The set of numbers whi ch can be represented exactly depends on the number " }{TEXT 278 1 "k " }{TEXT -1 76 " of digits in the mantissa and the range of possible v alues of the exponent." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 125 "In Maple output floating-point numbers are displaye d in normalised form when the exponent has a sufficiently large magnit ude." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "evalf(Pi*10^6,10);\nevalf(Pi*10^(-6),10);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+aEfTJ!\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+aEfTJ!#:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 81 "The largest and smallest floating-point numbers which M aple can handle are . . . " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "Maple_floats(MAX_FLOAT);\nMaple_flo ats(MIN_FLOAT);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"\"+YO[Z@" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"!+YO[Z@" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "Maple_floats (MAX_FLOAT*10);\nMaple_floats(MIN_FLOAT/10);\n" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"%)infinityG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"\"!F$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 12 "The command " } {TEXT 0 5 "evalf" }{TEXT -1 77 " causes Maple to perform floating-poin t arithmetic and, in the default mode, " }{TEXT 259 110 "Maple perform s software floating-point arithmetic with floating-point numbers havin g 10 digits in the mantissa" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 72 "Maple performs arithmetic using the standard decimal, or base 10 format." }}{PARA 0 "" 0 "" {TEXT -1 167 "Many computers have a built-in hardware floating-point unit, whic h performs arithmetic operations on floating-point numbers represented in base 2 rather than base 10. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 77 "The number of digits in the mantissa of f loating-point numbers is called the " }{TEXT 259 9 "precision" }{TEXT -1 61 " of the arithmetic, and is controlled by the global variable " }{TEXT 0 6 "Digits" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 21 "The default value of " }{TEXT 0 6 "Digits" }{TEXT -1 54 " is 10, but it c an be set to another value if desired." }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 6 "Using " }{TEXT 0 5 "evalf" }{TEXT -1 91 " with a second argument, which is a positive integer, will tempora rily change the value of " }{TEXT 0 6 "Digits" }{TEXT -1 39 " during t he evaluation, and then reset " }{TEXT 0 6 "Digits" }{TEXT -1 63 " bac k to its original value.\nThe following example checks this." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "Di gits := 10;\nevalf(10^Digits,20);\nDigits;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'DigitsG\"#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"5+ ++++++++5\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#5" }}}{PARA 0 " " 0 "" {TEXT -1 173 "\n\nIt is important to understand that most numbe rs are represented only approximately in floating-point form. The exac t decimal equivalent of the fraction or rational number " }{XPPEDIT 18 0 "2/3;" "6#*&\"\"#\"\"\"\"\"$!\"\"" }{TEXT -1 26 " is the infinite decimal 0" }{XPPEDIT 18 0 ".6666666666*` . . . `;" "6#*&-%&FloatG6$\" +mmmmm!#5\"\"\"%(~.~.~.~GF)" }{TEXT -1 44 ". There is no exact floatin g-point form for " }{XPPEDIT 18 0 "2/3;" "6#*&\"\"#\"\"\"\"\"$!\"\"" } {TEXT -1 68 ". However, we can represent it as accurately as we want b y setting " }{TEXT 0 6 "Digits" }{TEXT -1 28 " appropriately, or by u sing " }{TEXT 0 5 "evalf" }{TEXT -1 45 " with a second argument to tem porarily reset " }{TEXT 0 6 "Digits" }{TEXT -1 1 "." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "twoThirds \+ := evalf(2/3,15);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%*twoThirdsG$\"0 nmmmmmm'!#:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 111 "If we multiply this number by 3, using 16 digit arithmetic, we get the exact decimal result which ends in a 1. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 146 "(The last digit of the r esult is 1 because multiplying the last digit 7 of 0.666666666666667 b y 3 gives 21 with 1 to \"put down\" and 2 \"to carry\".)" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "evalf (twoThirds*3,16);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"1,++++++?!#:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 104 "On th e other hand, if we multiply by 3 using 15 digit arithmetic we get a r ounded answer with 15 digits." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "evalf(twoThirds*3,15);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0+++++++#!#9" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 31 "The decimal approximation for " }{XPPEDIT 18 0 "2/3;" "6#*&\"\"#\"\"\"\"\"$!\"\"" }{TEXT -1 58 " has behaved nicely here and given an \"exact\" answer for " } {XPPEDIT 18 0 "``(2/3)*`.`*3;" "6#*(-%!G6#*&\"\"#\"\"\"\"\"$!\"\"F)%\" .GF)F*F)" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 42 "Multiplying t he decimal approximation for " }{XPPEDIT 18 0 "1/3;" "6#*&\"\"\"F$\"\" $!\"\"" }{TEXT -1 58 ", in any precision, by 3 does not give the exact answer 1." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 48 "oneThird := evalf(1/3,15);\nevalf(oneThird*3,15);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%)oneThirdG$\"0LLLLLLL$!#:" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0***************!#:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 266 8 "Warning:" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 71 "In any single calculation the sma llest error you should expect is that " }{TEXT 259 34 "the last digit \+ may be \"out by one\"" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 31 " This kind of error is called a " }{TEXT 259 14 "rounding error" } {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 216 "If a Maple variable has been assigned a floating-point v alue, then any arithmetic which involves that variable will automatica lly be performed in floating-point arithmetic using the precision of t he current value of " }{TEXT 0 6 "Digits" }{TEXT -1 1 "." }}{PARA 0 " " 0 "" {TEXT -1 66 "Even if the number has higher precision than the c urrent value of " }{TEXT 0 6 "Digits" }{TEXT -1 49 ", this precision w ill be lost in the calculation." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 61 "Compare the following two methods of perf orming the addition " }{XPPEDIT 18 0 "1/3+3/7;" "6#,&*&\"\"\"F%\"\"$! \"\"F%*&F&F%\"\"(F'F%" }{TEXT -1 36 " to obtain a floating-point resul t. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "Digits :=10;\nevalf(1/3+3/7,15);\nevalf(1/3,15)+evalf (3/7,15);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'DigitsG\"#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0iZ!>w/>w!#:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+>w/>w!#5" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 40 "In the first case, the the calculation " } {XPPEDIT 18 0 "1/3+3/7 = 16/21;" "6#/,&*&\"\"\"F&\"\"$!\"\"F&*&F'F&\" \"(F(F&*&\"#;F&\"#@F(" }{TEXT -1 119 " is performed, and then the res ult is converted to a 15 digit floating-point number.\nThis can be bro ken up as follows." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 39 "a := 1/3;\nb := 3/7;\na + b;\nevalf(%,15);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG#\"\"\"\"\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG#\"\"$\"\"(" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 ##\"#;\"#@" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0iZ!>w/>w!#:" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 20 "In the s econd case, " }{XPPEDIT 18 0 "1/3;" "6#*&\"\"\"F$\"\"$!\"\"" }{TEXT -1 6 " and " }{XPPEDIT 18 0 "3/7;" "6#*&\"\"$\"\"\"\"\"(!\"\"" } {TEXT -1 159 " are converted to the15 digit floating-point numbers, a nd then the addition is performed in floating-point arithmetic with th e default precision of 10 digits." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "Digits := 10:\na := evalf(1/ 3,15);\nb := evalf(3/7,15);\na + b;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>%\"aG$\"0LLLLLLL$!#:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"0H9 dG9dG%!#:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+>w/>w!#5" }}}{PARA 0 "" 0 "" {TEXT -1 28 "\nIf you change the value of " }{TEXT 0 6 "Digits " }{TEXT -1 54 " for a series of calculations, it is good practice to \+ " }{TEXT 259 30 "reset it to its original value" }{TEXT -1 25 " when y ou have finished. " }}{PARA 0 "" 0 "" {TEXT -1 159 "This can be achiev ed by saving the original setting and then returning to that setting a fterwards.\nAlternatively, you can always return to the default settin g " }{TEXT 260 11 "Digits = 10" }{TEXT -1 23 " after the calculation. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 101 "saveDigits := Digits: Digits := 30:\na := evalf(Pi);\nb := ev alf(sqrt(2));\na + b;\nDigits := saveDigits:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"?G$QVEYQKz*e`EfTJ!#H" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"?@C()o,)[]4tBc8UT\"!#H" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"?\\2@LksG))G'f@1eb%!#H" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 80 "Note that the following commands p roduce exactly the same result as those above." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "Digits := 30 :\nPi + sqrt(2);\nevalf(%);\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,&%#PiG\"\"\"*$\"\"##F%F'F%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"?\\2@LksG))G'f@1eb%!#H" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 32 "Rounding and significant figures" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 112 "The conversion of s ome fractions (rational numbers) to decimals often gives a decimal whi ch does not terminate. " }}{PARA 0 "" 0 "" {TEXT -1 13 "For example: \+ " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "5/7 =0" "6#/*&\" \"&\"\"\"\"\"(!\"\"\"\"!" }{TEXT -1 13 ".714285714285" }{TEXT 287 8 " \+ . . . ." }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 49 "Also, certain \+ square roots and constants such as " }{XPPEDIT 18 0 "Pi" "6#%#PiG" } {TEXT -1 4 " or " }{XPPEDIT 18 0 "exp(1)" "6#-%$expG6#\"\"\"" }{TEXT -1 50 " have decimal expansions which do not terminate. " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "sqrt(2) = 1.414213562373095 04880168872421*` . . . `;" "6#/-%%sqrtG6#\"\"#*&-%&FloatG6$\"?@C()o,)[ ]4tBc8UT\"!#H\"\"\"%(~.~.~.~GF." }{TEXT -1 1 " " }}{PARA 256 "" 0 "" {XPPEDIT 18 0 "Pi = 3.14159265358979323846264338328*` . . . `;" "6#/%# PiG*&-%&FloatG6$\"?G$QVEYQKz*e`EfTJ!#H\"\"\"%(~.~.~.~GF+" }{TEXT -1 1 " " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "exp(1) = 2.7182 8182845904523536028747135*` . . . `;" "6#/-%$expG6#\"\"\"*&-%&FloatG6$ \"?NruGg`BX!f%G=G=F!#HF'%(~.~.~.~GF'" }{TEXT -1 1 " " }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 180 "In order to use such n umbers in a floating-point calculation we must cut them down to fit th e \"size\" of the numbers in the floating-point arithmetic being used \+ for the calculation." }}{PARA 0 "" 0 "" {TEXT -1 39 "This process of c utting down is called " }{TEXT 259 8 "rounding" }{TEXT -1 77 " , and t he following rules are used so as to cause the least possible error. \+ " }}{PARA 0 "" 0 "" {TEXT -1 36 "To round a floating-point number to \+ " }{TEXT 288 1 "n" }{TEXT -1 59 " significant figures, or digits, disc ard all digits of the " }{TEXT 259 8 "mantissa" }{TEXT -1 11 " after t he " }{TEXT 289 1 "n" }{TEXT -1 11 " th place. " }}{PARA 0 "" 0 "" {TEXT -1 97 "If the number formed by these discarded digits (with the \+ place value of each digit retained) is: " }}{PARA 15 "" 0 "" {TEXT -1 1 " " }{TEXT 271 231 "less than half a unit in the n th place, (that i s, the (n+1)st digit is 4 or less ) \n \+ --- the n t h digit of the rounded number is not altered" }{TEXT -1 2 ", " }} {PARA 15 "" 0 "" {TEXT -1 1 " " }{TEXT 271 234 "greater than half a un it in the n th place, (that is, the (n+1)st digit is 5 or more, and is followed by at least one nonzero digit) \n \+ --- 1 is added to the n th digit of the rounded num ber" }{TEXT -1 44 " (carrying over to the left, if necessary),\n" }} {PARA 15 "" 0 "" {TEXT -1 1 " " }{TEXT 271 39 "exactly half a unit in \+ the n th place, " }{TEXT -1 1 "(" }{TEXT 271 154 "the (n+1) st digit i s 5 and subsequent digits are 0) \n \+ --- the last digit is not altered if it is " } {TEXT 259 4 "even" }{TEXT 271 33 ", but is increased by 1 if it is " } {TEXT 259 3 "odd" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 40 "The resulting number is then said to be \+ " }{TEXT 259 32 "correct to n significant figures" }{TEXT -1 14 " (or \+ digits). " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 18 "Maple's procedure " }{TEXT 0 5 "evalf" }{TEXT -1 45 " performs rou nding according to these rules. " }}{PARA 0 "" 0 "" {TEXT -1 96 "The f ollowing commands shows how various 4 digit numbers are rounded to 3 s ignificant figures. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 154 "0.236499,`rounds to`,evalf[3](0.236499); \n0.236501,`rounds to`,evalf[3](0.2366);\n0.2365,`rounds to`,evalf[3]( 0.2365);\n0.2375,`rounds to`,evalf[3](0.2375);\n" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%$\"'*\\O#!\"'%*rounds~toG$\"$O#!\"$" }}{PARA 11 "" 1 " " {XPPMATH 20 "6%$\"',lB!\"'%*rounds~toG$\"$P#!\"$" }}{PARA 11 "" 1 " " {XPPMATH 20 "6%$\"%lB!\"%%*rounds~toG$\"$O#!\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%$\"%vB!\"%%*rounds~toG$\"$Q#!\"$" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 259 4 "Note" }{TEXT -1 358 ": In rounding values obtained from physical measurements a slightly differ ent convention is often used whereby a number in the third case above \+ is always rounded upwards. The reasoning behind this is that an overes timate is considered to be preferable to an underestimate. However, th is method involves a bias which is avoided by the convention given abo ve. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 26 "Errors cau sed by rounding " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 79 "The following examples indicate how the rounding of numbe rs can produce errors." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 290 9 "Example 1" }{TEXT -1 2 ": " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 271 25 "0.7243 + 0.2623 = 0.9866 " }{TEXT 292 1 "~" }{TEXT 271 6 " 0.987" }{TEXT -1 36 " (correct to 3 significant fig ures) " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 100 "On the other hand, if the two numbers to be added are rounded to \+ 3 digits before adding, we obtain: " }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 271 21 "0.724 + 0.262 = 0.986 " }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT 293 9 "Example 2" }{TEXT -1 2 ": " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 271 7 "0.1542 " } {TEXT 295 1 "x" }{TEXT 271 21 " 0.3734 = 0.05757828 " }{TEXT 294 1 "~ " }{TEXT 271 7 " 0.0576" }{TEXT -1 36 " (correct to 3 significant figu res) " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 100 "On the other hand, if the two numbers to be added are rounded to 3 di gits before adding, we obtain: " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 271 6 "0.154 " }{TEXT 297 1 "x " }{TEXT 271 18 " 0.373 = 0.057442 " }{TEXT 296 1 "~" }{TEXT 271 7 " 0 .0574" }{TEXT -1 36 " (correct to 3 significant figures) " }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 46 "These two examples can be handled using Maple." }}{PARA 0 "" 0 "" {TEXT 298 9 "Example 1 " }{TEXT -1 2 ": " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "a := 0.7243;\nb := 0.2623;\na+b;\nevalf[3](%) ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"%Vs!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"%BE!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#$\"%m)*!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"$()*!\"$" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "a := 0.7243;\nb := 0.2623;\na := evalf[3](a);\nb := evalf[3](b);\n a+b;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"%Vs!\"%" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%\"bG$\"%BE!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"$C(!\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"$i# !\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"$')*!\"$" }}}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 40 "The same result is obta ined if we reset " }{TEXT 260 6 "Digits" }{TEXT -1 7 " to 3. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "a := 0.7243;\nb := 0.2623;\nDigits := 3:\na+b;\nDigits := 10:" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"%Vs!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"%BE!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\" $')*!\"$" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 291 9 "Example 2" }{TEXT -1 2 ": " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "a := 0.1542;\nb := 0.3734;\n a*b;\nevalf[3](%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"%U:!\"% " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"%MP!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"(Gyv&!\")" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"$ w&!\"%" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "a := 0.1542;\nb := 0.3734;\na := evalf[3](a);\nb := e valf[3](b);\na*b;\nevalf[3](%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>% \"aG$\"%U:!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"%MP!\"%" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"$a\"!\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"$t$!\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\" &Uu&!\"'" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"$u&!\"%" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 40 "The same result is o btained if we reset " }{TEXT 260 6 "Digits" }{TEXT -1 7 " to 3. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 57 "a := 0.1542;\nb := 0.3734;\nDigits := 3:\na*b;\nDigits := 10:" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"%U:!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"%MP!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\" $u&!\"%" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 242 "The examples above \+ suggest that rounding errors can be reduced by performing a calculatio n with more digits (with a higher precision) than is actualled desired in the result, and then rounding off at the end. The extra digits use d are called " }{TEXT 259 12 "guard digits" }{TEXT -1 95 ". In the pre vious examples, just one guard digits was used in the first method of \+ calculation. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 57 "Signi ficant digits in relation to physical measurements " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 118 "When m aking physical measurements it is important to know how many digits to use in representing the data numerically." }}{PARA 0 "" 0 "" {TEXT -1 300 "For example, if you measure the height of a page with a ruler, you can probably determine the height correct to the nearest millimet re. So if you measure the height as 23.4 cm, you are claiming that the actual height is closer to 23.4 cm than to either 23.3 cm or 23.5 cm. Your value is correct to 3 " }{TEXT 259 18 "significant digits" } {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 63 "Suppose that you also measure the width of the page as 17 .6 cm." }}{PARA 0 "" 0 "" {TEXT -1 89 "Then the area of the page, in s quare cm, is calculated as the product of 23.4 with 17.6. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "23.4 *17.6;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"&%=T!\"#" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 79 "The exact product is 411.84, but it is inappropriate to s tate that the area is " }{XPPEDIT 18 0 "411.84*cm^2;" "6#*&-%&FloatG6$ \"&%=T!\"#\"\"\"*$%#cmG\"\"#F)" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 145 "You might be pretty sure that the height is between 23.37 and 23.43 cm, and the width is bewee n 17.57 and 17.63 cm, which puts the area between " }{XPPEDIT 18 0 "2 3.37*`.`*17.57*cm^2;" "6#**-%&FloatG6$\"%PB!\"#\"\"\"%\".GF)-F%6$\"%d< F(F)%#cmG\"\"#" }{TEXT -1 6 " and " }{XPPEDIT 18 0 "23.43*`.`*17.63*c m^2;" "6#**-%&FloatG6$\"%VB!\"#\"\"\"%\".GF)-F%6$\"%j " 0 "" {MPLTEXT 1 0 25 "23.37*17.57;\n23.43*17.63;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"(4h5%!\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"(428 %!\"%" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 54 "This means that the area of the page is between about " }{XPPEDIT 18 0 "410.6*cm^2;" "6#*&-%&FloatG6$\"%1T!\"\"\"\"\"*$%#cmG\"\"#F)" } {TEXT -1 5 " and " }{XPPEDIT 18 0 "413.1*cm^2;" "6#*&-%&FloatG6$\"%JT! \"\"\"\"\"*$%#cmG\"\"#F)" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 64 "Rounding the value 411.84 to 3 figures, and giving an answer of " }{XPPEDIT 18 0 "412*cm^2;" "6#*&\"$7%\"\"\"*$%#cmG\"\"#F%" }{TEXT -1 78 " is even a bit optimistic. It is probably safer to say that the ar ea is about " }{XPPEDIT 18 0 "410*cm^2;" "6#*&\"$5%\"\"\"*$%#cmG\"\"#F %" }{TEXT -1 44 ", quoting a value to 2 significant figures. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "The signi ficant digits of a number may be thought of as those digits which can \+ be used " }{TEXT 259 15 "with confidence" }{TEXT -1 1 "." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 103 "We can get Maple \+ to perform the calculation of the area of the page using a precision o f just 3 digits." }}{PARA 0 "" 0 "" {TEXT -1 46 "This gives the result to 3 significant digits." }}{PARA 0 "" 0 "" {TEXT -1 66 "The answer c an then be rounded to 2 significant digits if desired." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "evalf(2 3.4*17.6,3);\nevalf(%,2);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"$7%\" \"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"#T\"\"\"" }}}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}} {SECT 1 {PARA 4 "" 0 "" {TEXT -1 37 "Exact vs. floating-point computat ions" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 " " {TEXT -1 200 "The following information is adapted from the Maple Ad visor Database, which is a project of the Symbolic Computation Group o f the University of British Columbia, under the direction of Robert Is rael. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 73 "Robert Israel, Department of Mathematics, University of British Colum bia," }}{PARA 0 "" 0 "" {TEXT -1 29 "Vancouver, BC, CanadaV6T 1Z2 " }} {PARA 0 "" 0 "" {TEXT -1 19 "israel@math.ubc.ca " }}{PARA 0 "" 0 "" {TEXT 268 23 "_______________________" }{TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 154 "Maple can use exact ar ithmetic, where rational numbers are expressed as fractions and irrati onal numbers are expressed using symbolic expressions such 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#-%&FloatG6$\"+u#Gm]#!\"*" }{TEXT -1 231 " are expressed using a certain number of decimal places. It is o ften important to decide which of these is more appropriate in a parti cular problem. Often there is a trade-off to consider: exact arithmet ic avoids any problems of " }{TEXT 259 8 "rounding" }{TEXT -1 4 " or \+ " }{TEXT 259 8 "roundoff" }{TEXT -1 110 " error, but can be much slowe r than floating-point arithmetic, and may result in very complicated e xpressions." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 36 "Consider the problem of calculating " }{XPPEDIT 18 0 "(1+1/t)^t ;" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 43 " for successively larger integer values of " }{TEXT 280 1 "t" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 14 "The values of " }{XPPEDIT 18 0 "(1+1/t)^t;" "6# ),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 4 " as " }{TEXT 281 1 "t" } {TEXT -1 55 " increases approach the value of mathematical constant " }{XPPEDIT 18 0 "exp(1);" "6#-%$expG6#\"\"\"" }{TEXT -1 2 " " }{TEXT 279 1 "~" }{TEXT -1 21 " 2.718281828, because" }}{PARA 256 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "Limit((1+1/t)^t,t = infinity) = exp(1) ;" "6#/-%&LimitG6$),&\"\"\"F)*&F)F)%\"tG!\"\"F)F+/F+%)infinityG-%$expG 6#F)" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 44 "Maple can \"verif y\" this theoretical result. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "Limit((1+1/t)^t,t = infinity );\nvalue(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%&LimitG6$),&\"\"\"F (*&F(F(%\"tG!\"\"F(F*/F*%)infinityG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #-%$expG6#\"\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "For " } {XPPEDIT 18 0 "t = 43" "6#/%\"tG\"#V" }{TEXT -1 75 " both numerator an d denominator have 71 digits when using exact arithmetic." }}{PARA 0 " " 0 "" {TEXT -1 161 "Maple can then obtain the corresponding 10 digit \+ floating-point value by performing a single division with essentially \+ no possibilty of rounding errors arising. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "eval((1+1/t)^t,t=4 3);\nevalf(%,10);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6##\"bo%)>7'o%HmI*y !Q,I3XS,nx2`>47!RD13$e@.7))G\"y.*>vEI qOtPM<" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+&3Lto#!\"*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 303 "Typically, however, all you really wan t is a few decimal places of the answer. For this purpose it is better to do the calculation in floating-point arithmetic. A simple way to e nsure that the calculation is performed using floating-point arithmeti c is to introduce a decimal point into the expression. " }}{PARA 0 "" 0 "" {TEXT -1 120 "Performing the whole calculation using 10 digit flo ating-point arithmetic leads to a noticeable rounding error of 5 ulp. " }}{PARA 0 "" 0 "" {TEXT -1 30 "(5 units in the last place). " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "Digits := 10:\neval((1+1/t)^t,t=43.); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+!4Lto#!\"*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 15 "Given a number " }{TEXT 284 1 "x" }{TEXT -1 20 ", 1 ulp relative t o " }{TEXT 285 1 "x" }{TEXT -1 20 " is the Maple value " }{TEXT 271 29 "Float(1, -Digits+1+ilog10(x))" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }{TEXT 0 6 "ilog10" }{TEXT -1 53 " is the the integer b ase 10 logarithm function. (See " }{HYPERLNK 17 "ilog10" 2 "ilog10" " " }{TEXT -1 2 ") " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 124 "eval((1+1/t)^t,t=43):\nvalue1 := evalf(%);\n value2 := eval((1+1/t)^t,t=43.);\nvalue2-value1;\nFloat(5,-Digits+1+il og10(value1));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'value1G$\"+&3Lto# !\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'value2G$\"+!4Lto#!\"*" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"&!\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"&!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "For " }{XPPEDIT 18 0 "t = 4321" "6#/%\"tG\"%@V" } {TEXT -1 78 " both numerator and denominator have 15710 digits when us ing exact arithmetic." }}{PARA 0 "" 0 "" {TEXT -1 75 "The number of di gits in the numerator and denominator are given as follows." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "il og10(4322^4321)+1;\nilog10(4321^4321)+1;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"&5d\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"&5d\"" }}}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 40 "A command to compu te the exact value of " }{XPPEDIT 18 0 "(1+1/t)^t" "6#),&\"\"\"F%*&F%F %%\"tG!\"\"F%F'" }{TEXT -1 6 " when " }{XPPEDIT 18 0 "t=4321" "6#/%\"t G\"%@V" }{TEXT -1 34 " is given in the next subsection. " }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT 0 6 "Danger" } {TEXT -1 5 " . . " }{TEXT 256 1 " " }{TEXT 259 42 "extensive output re sults from this command" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "eval((1+1/t)^t,t=4321);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 84 "The o utput for the first line in the next code block is suppressed by using a colon " }{TEXT 282 1 ":" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 127 "Using exact arithmetic essentially avoids rounding errors at t he expense of a time-consuming and memory-consuming computation. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "eval((1+1/t)^t,t=4321):\nevalf(%,10);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+_t'zr#!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 116 "Considerable rounding error arises when \+ performing the whole calculation using 10 digit floating-point arithme tic. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "Digits := 10:\neval((1+1/t)^t,t=4321.);" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#$\"+1%ozr#!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 205 "A simpler way to dispose of rounding errors is to perform the computation using Maple's software floating -point arithmetic with the number of digits increased. The extra digi ts used are sometimes called " }{TEXT 259 12 "guard digits" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 45 "The result can then be rounded to 10 digits. " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "Digits := 15:\neval((1+1/t)^t,t=4321.);\nevalf(% ,10);\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"00y?Nnzr#!# 9" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+_t'zr#!\"*" }}}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "For " }{XPPEDIT 18 0 "t \+ = 54321" "6#/%\"tG\"&@V&" }{TEXT -1 79 " both numerator and denominato r have 257209 digits when using exact arithmetic." }}{PARA 0 "" 0 "" {TEXT -1 73 "The number of digits in the numerator and denominator are given from . . " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 69 "ceil(evalf(54321*log[10](54322)));\nceil(evalf (54321*log[10](54321)));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"'4sD" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#\"'4sD" }}}{PARA 0 "" 0 "" {TEXT -1 40 "A command to compute the exact value of " }{XPPEDIT 18 0 "(1+1/t)^ t" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 6 " when " }{XPPEDIT 18 0 "t = 54321;" "6#/%\"tG\"&@V&" }{TEXT -1 34 " is given in the next subsection. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT 0 6 "Danger" }{TEXT -1 5 " . . " }{TEXT 256 1 " " }{TEXT 259 42 "extensive output results from this command" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 109 "It is not advisable to r eplace the colon by a semi-colon in the following, because the output \+ involves about " }{TEXT 259 21 "half a million digits" }{TEXT -1 1 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "eval((1+1/t)^t,t=54321);\nevalf(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+3oD=F!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 129 "The following code block perfo rms the same computation with the extensive output suppressed. The tim e needed is also determined. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 111 "start_time := time():\neval ((1+1/t)^t,t=54321):\nevalf(%);\nprint(`time required: `,time()-start_ time,` seconds`);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+3oD=F!\"*" }} {PARA 11 "" 1 "" {XPPMATH 20 "6%%0time~required:~G$\"%?X!\"$%)~seconds G" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 132 "Wh en the whole computation is performed with 10 digit floating-point ari thmetic the result is only correct to 4 significant figures." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "Di gits := 10:\neval((1+1/t)^t,t=54321.);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+.SC=F!\"*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }} }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 138 "The cal culation above is one in which the roundoff error is rather severe, du e to the fact that we are adding the relatively small number " } {XPPEDIT 18 0 "1/54321;" "6#*&\"\"\"F$\"&@V&!\"\"" }{TEXT -1 1 " " } {TEXT 283 1 "~" }{TEXT -1 109 " 0.00001840908673 to the number 1, whic h is relatively large, and we lose significant digits in the process. \+ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "evalf(1/54321,17);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"2iv?D n34%=!#@" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 67 "Using 6 guard digits yields a result which is correct to10 digits. " }}{PARA 0 "" 0 "" {TEXT -1 77 "(Check what happens when the number \+ of guard digits is increased or reduced.)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "Digits := 16:\neval(( 1+1/t)^t,t=54321.);\nevalf(%,10);\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"1]wI3oD=F!#:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+ 3oD=F!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 55 "Maple's \+ hardware and software floating-point arithmetic" }}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 86 "As mentioned previously, Maple (usually) performs floating-point arithmetic in bas e10." }}{PARA 0 "" 0 "" {TEXT -1 208 "Without being told this fact, it would be entirely possible for a different base such as 2, 16 or 256 \+ to be used internally, and for numbers to be converted between the bas es for purposes of input and output." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 24 "The following procedure " }{TEXT 0 8 "g et_base" }{TEXT -1 209 " is adapted from C code in the book: \"Numeri cal Recipies in C\", Cambridge University Press. It determines the num ber base of the floating-point arithmetic being used from the way that this arithmetic behaves." }}{PARA 0 "" 0 "" {TEXT -1 118 "The method \+ is due to M. Malcom.\nYou can check that Maple's software floating-poi nt arithmetic is performed in base 10." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 377 "get_base := proc()\n \+ local one,zero,temp,temp1,itemp,a,b;\n\n one := 1.:\n zero := one- one;\n a := one;\n temp1 := one;\n while temp1-one=zero do\n \+ a := a + a;\n temp := a + one;\n temp1 := temp - a;\n en d do;\n itemp := 0;\n b := one;\n while itemp=0 do\n b := b + b;\n temp := a + b;\n itemp := floor(temp - a);\n end d o;\n itemp;\nend proc:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 32 "The following command gives the " }{TEXT 259 50 "b ase of Maple's software floating-point arithmetic" }{TEXT -1 1 "." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "get_base();" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 48 "Maple provides for the possibility of u sing the " }{TEXT 259 28 "hardware floating-point unit" }{TEXT -1 107 " of the processor on a computer if available. This could be useful in situations where speed is important.\n" }}{PARA 0 "" 0 "" {TEXT -1 46 "To make use of this facility, use the command " }{TEXT 0 6 "evalhf " }{TEXT -1 13 " in place of " }{TEXT 0 5 "evalf" }{TEXT -1 6 ". The \+ " }{TEXT 0 1 "h" }{TEXT -1 116 " is to indicate that hardware is being used to perform the floating-point arithmetic, rather than Maple's s oftware." }}{PARA 0 "" 0 "" {TEXT -1 14 "The procedure " }{TEXT 0 8 "g et_base" }{TEXT -1 103 " can be used to determine the base of the hard ware floating-point arithmetic, which will usually be 2. " }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "The " }{TEXT 259 42 "base of hardware floating-point arithmetic" }{TEXT -1 10 " is . . \+ . " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "evalhf(get_base());" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#$\"\"#\"\"!" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 53 "Calculations will generally be performed faster with " } {TEXT 0 6 "evalhf" }{TEXT -1 11 " than with " }{TEXT 0 5 "evalf" } {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 47 "Try executing the follow ing loops to test this." }}{PARA 0 "" 0 "" {TEXT 259 4 "Note" }{TEXT -1 18 ": The setting for " }{TEXT 271 6 "Digits" }{TEXT -1 124 " used \+ in the first instance ensures that Maple does not make use of hardware floating-point arithmetic \"behind the scenes\". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 194 "Digits := c eil(evalhf(Digits));\nv := 1:\nstart_time := time():\nfor i from 1 to \+ 10000 do v := evalf(sin(v)) end do:\nprint(`elapsed time =`,time()-sta rt_time,`seconds`);\nDigits := 10:\nv;\nevalf(v); " }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%'DigitsG\"#9" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%%/e lapsed~time~=G$\"%s@!\"$%(secondsG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# $\"/QB7@OJ " 0 "" {MPLTEXT 1 0 149 "v := 1:\nstart_time := time():\nfor i from 1 to 10000 do v := eva lhf(sin(v)) end do:\nprint(`elapsed time =`,time()-start_time,`seconds `);\nv;\nevalf(v); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6%%/elapsed~time~ =G$\"#%*!\"$%(secondsG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3!RONA6i8 t\"!#>" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+7@OJ " 0 "" {MPLTEXT 1 0 104 "xx := ev alf(Pi,9);\nDigits := ceil(evalhf(Digits));\nevalf(evalhf(sin(xx)));\n evalf(sin(xx));\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#x xG$\"*l#fTJ!\")" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'DigitsG\"#9" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"/3$RZ$z*e$!#A" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"/EYQKz*e$!#A" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 213 "By performing the calculation using soft ware floating-point arithmetic with a larger number of digits and then rounding the result we can check that the second value is accurate to the number of digits displayed. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "Digits := ceil(evalhf(Digits ));\nevalf(sin(xx),2*Digits);\nevalf(%);\nDigits := 10:" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%'DigitsG\"#9" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#$\"=c`XpbPVEYQKz*e$!#O" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"/EYQKz* e$!#A" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 75 "The largest and smallest floating-point numbers which can be handled \+ using " }{TEXT 0 6 "evalhf" }{TEXT -1 27 " are supposed to be . . . \+ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "evalhf(DBL_MAX);\nevalhf(DBL_MIN);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"2-+++!********\"$\"H" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3,++++,++5!$C$" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 60 "However, it may be possible to obtain a smaller nu mber than " }{TEXT 260 7 "DBL_MIN" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "evalhf(DBL_M AX*2);\nevalhf(DBL_MIN/4);\nevalhf(DBL_MIN/8);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"%)infinityG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"3-+++]-++D!$D$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"!F$" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 19 "The machine epsilon" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 54 "In a given environment for floating-point arithmetic, " }{TEXT 259 101 "the machine epsilon is the smallest number which, when added \+ to 1, produces a number different from 1" }{TEXT -1 1 "." }}{PARA 0 " " 0 "" {TEXT -1 131 "Since Maple has the facility of changing the prec ision, the machine epsilon will depend on the current value of the glo bal variable" }{TEXT 0 7 " Digits" }{TEXT -1 2 ".\n" }}{PARA 0 "" 0 " " {TEXT -1 25 "Here are a few examples.\n" }{TEXT 262 25 " ___________ ____________ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 65 "Set up Maple to perform floating-point arithmetic with 10 digits." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "Digits := 10:\nevalf(1) + evalf(10^(-9));\nevalf(1) + evalf(10^(-10));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+,+++5!\"*" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+++++5!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 42 "When Digits = 10, the mac hine epsilon is " }{XPPEDIT 18 0 "1/2" "6#*&\"\"\"F$\"\"#!\"\"" } {TEXT -1 1 " " }{TEXT 314 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-9 );" "6#)\"#5,$\"\"*!\"\"" }{TEXT -1 5 " = 5 " }{TEXT 315 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-10)" "6#)\"#5,$F$!\"\"" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 93 "Digits := 10:\nevalf(1) + evalf(0.5000000001*10^(-9));\nevalf(1) + evalf(0.4999999999*10^(-9));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\" +,+++5!\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+++++5!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 261 24 " _______________________" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 65 "Set up Ma ple to perform floating-point arithmetic with 15 digits." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "Digit s := 15:\nevalf(1) + evalf(10^(-14));\nevalf(1) + evalf(10^(-15));\nDi gits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0,++++++\"!#9" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0+++++++\"!#9" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 41 "When Digits = 15, the machine epsilon is " }{XPPEDIT 18 0 "1/2 \+ " "6#*&\"\"\"F$\"\"#!\"\"" }{TEXT -1 2 " " }{TEXT 312 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-14);" "6#)\"#5,$\"#9!\"\"" }{TEXT -1 4 " = 5 " }{TEXT 313 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-15)" "6#) \"#5,$\"#:!\"\"" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 119 "Digits := 15:\nevalf(1) + e valf(0.500000000000001*10^(-14));\nevalf(1) + evalf(0.499999999999999* 10^(-14));\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0,++++ ++\"!#9" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"0+++++++\"!#9" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 263 24 " _______________________" } {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 65 "Set up Maple to perform floating-point arithmetic with 20 digit s." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "Digits := 20:\nevalf(1) + evalf(10^(-19));\nevalf(1) \+ + evalf(10^(-20));\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"5,++++++++5!#>" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"5+++++++++5!#> " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 41 "When Digits = 20, the machine epsilon is \+ " }{XPPEDIT 18 0 "1/2 " "6#*&\"\"\"F$\"\"#!\"\"" }{TEXT -1 1 " " } {TEXT 316 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-19);" "6#)\"#5,$ \"#>!\"\"" }{TEXT -1 4 "= 5 " }{TEXT 317 1 "x" }{TEXT -1 2 " 1" } {XPPEDIT 18 0 "0^(-20);" "6#)\"\"!,$\"#?!\"\"" }{TEXT -1 1 "." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 129 "Digits := 20:\nevalf(1) + evalf(0.50000000000000000001*10^(-19)); \nevalf(1) + evalf(0.49999999999999999999*10^(-19));\nDigits := 10:" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"5,++++++++5!#>" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#$\"5+++++++++5!#>" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 264 24 " __ _____________________" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 31 "In general, when using Maple's " } {TEXT 259 8 "software" }{TEXT -1 32 " floating-point arithmetic with \+ " }{TEXT 260 6 "Digits" }{TEXT -1 8 " set to " }{TEXT 305 6 "Digits" } {TEXT -1 6 ", the " }{TEXT 259 15 "machine epsilon" }{TEXT -1 7 " is \+ 5 " }{TEXT 309 2 "x " }{XPPEDIT 18 0 "10^(-Digits);" "6#)\"#5,$%'Digit sG!\"\"" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 63 "In the defaul t precision of 10 digits the machine epsilon is 5 " }{TEXT 310 1 "x" } {TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-10)" "6#)\"#5,$F$!\"\"" }{TEXT -1 3 " = " }{XPPEDIT 18 0 "1/2" "6#*&\"\"\"F$\"\"#!\"\"" }{TEXT -1 2 " \+ " }{TEXT 311 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-9)" "6#)\"#5,$ \"\"*!\"\"" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "eps := Float(5,-Digits);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$epsG$\"\"&!#5" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 132 "When using hardware floating-point arithmetic, where t he base is likely to be 2, the machine epsilon is independent of the v alue of " }{TEXT 0 6 "Digits" }{TEXT -1 55 ".\nIn most implementations the machine epsilon is about " }{XPPEDIT 18 0 "2^(-52);" "6#)\"\"#,$ \"#_!\"\"" }{TEXT 286 1 "~" }{TEXT -1 5 " 0.2 " }{TEXT 308 1 "x" } {TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-15)" "6#)\"#5,$\"#:!\"\"" }{TEXT -1 11 ", so using " }{TEXT 0 6 "evalhf" }{TEXT -1 34 " is roughly equi valent to setting " }{TEXT 0 6 "Digits" }{TEXT -1 7 " to 16." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 24 "The following p rocedure " }{TEXT 0 8 "mach_eps" }{TEXT -1 26 " below will calculate t he " }{TEXT 259 52 "machine epsilon for base 2 floating-point arithmet ic" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 " " {TEXT -1 142 "The procedure contains a loop in which the number 1 is successively divided by 2 to obtain a binary digit of progressively l ess significance. " }}{PARA 15 "" 0 "" {TEXT -1 140 "At each stage thi s number is added to 1, and a check made to see if the resulting sum r egisters as being different from 1 in the arithmetic." }}{PARA 15 "" 0 "" {TEXT -1 208 "The loop stops when there is no detectable differen ce from 1. At this stage the small added number is smaller than the m achine epsilon by a factor of 2, so it is multiplied by 2 to obtain th e desired number." }}{PARA 15 "" 0 "" {TEXT -1 89 "The machine epsilon can be expressed as a power of 2 by computing its base 2 logarithm. \+ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 223 "mach_eps := proc()\n local one,eps,one_plus_eps;\n one := 1.;\n eps := one;\n one_plus_eps := one+eps;\n while one_plus_e ps-one<>0 do\n eps := eps/2;\n one_plus_eps := one+eps;\n \+ end do;\n eps*2;\nend proc: " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "eps := evalhf(mach_eps()):\n print(`Machine epsilon = `,eps);\nprint(``= 2^``(log[2](eps)));" }} {PARA 11 "" 1 "" {XPPMATH 20 "6$%3Machine~epsilon~=~G$\"338.D\\gW?A!#L " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/%!G)\"\"#-F$6#$!+++++_!\")" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 92 "We can ch eck the value given for the machine epsilon for hardware floating-poin t arithmetic." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "eps := evalhf(2^(-52));\nevalhf(1.+eps);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%$epsG$\"338.D\\gW?A!#L" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#$\"3A+++++++5!#<" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "eps := evalhf(2^(-53)); \nevalhf(1.+eps);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$epsG$\"3ac^iCI A56!#L" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"\"\"!" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 19 "The Maple constant \+ " }{TEXT 271 11 "DBL_EPSILON" }{TEXT -1 33 " can also be used to obtai n, via " }{TEXT 0 6 "evalhf" }{TEXT -1 62 ", the machine epsilon for h ardware floating-point arithmetic. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "evalhf(DBL_EPSILON);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"338.D\\gW?A!#L" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 136 "In many implementations \+ the mantissa in the (double precision) binary hardware floating-point \+ number has (effectively) 53 binary digits." }}{PARA 0 "" 0 "" {TEXT -1 195 "Actually only 52 bits are needed if it is assumed that the num ber is in normalised form in which the first binary digit after the bi nary point is 1, since it is not necessaary to store this bit. " }} {PARA 0 "" 0 "" {TEXT -1 19 "The Maple constant " }{TEXT 271 12 "DBL_M ANT_DIG" }{TEXT -1 33 " can also be used to obtain, via " }{TEXT 0 6 " evalhf" }{TEXT -1 89 ", the effective number binary digits in the mant issa of a hardware floating-point number." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "evalhf(DBL_MANT_DIG); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"#`\"\"!" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 155 "In this case, adding the machine epsilon to 1 can be thought of as the following binary additi on in which each of the numbers has 53 binary digits (bits). " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 256 "" 0 "" {TEXT -1 55 " 1.0000 000000000000000000000000000000000000000000000000" }{XPPEDIT 18 0 "``[2 ];" "6#&%!G6#\"\"#" }{TEXT -1 1 " " }}{PARA 256 "" 0 "" {TEXT -1 55 " \+ 0.0000000000000000000000000000000000000000000000000001" }{XPPEDIT 18 0 "``[2]" "6#&%!G6#\"\"#" }{TEXT -1 1 " " }}{PARA 256 "" 0 "" {TEXT -1 56 " _______________________________________________________" }} {PARA 256 "" 0 "" {TEXT -1 55 " 1.000000000000000000000000000000000000 0000000000000001" }{XPPEDIT 18 0 "``[2];" "6#&%!G6#\"\"#" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 29 "A close lo ok at the graph of " }{XPPEDIT 18 0 "y = 1+x;" "6#/%\"yG,&\"\"\"F&%\"x GF&" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 76 "The following picture takes a close look at a small sec tion of the graph of " }{XPPEDIT 18 0 "y = 1+x;" "6#/%\"yG,&\"\"\"F&% \"xGF&" }{TEXT -1 74 " when plotted using base 10 floating-point arith metic with a precision of " }{TEXT 271 9 "10 digits" }{TEXT -1 2 " (" }{TEXT 260 3 "red" }{TEXT -1 8 " graph)." }}{PARA 0 "" 0 "" {TEXT -1 4 "The " }{TEXT 265 5 "brown" }{TEXT -1 29 " line is the \"true\" grap h of " }{XPPEDIT 18 0 "y = 1+x;" "6#/%\"yG,&\"\"\"F&%\"xGF&" }{TEXT -1 2 ". " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{GLPLOT2D 651 523 523 {PLOTDATA 2 "67-%'CURVESG6%7\\v7$$!\"%!#5F(7$$!+\"Hq(4Q!#>F(7$$!+#eS&> OF.F(7$$!+>6;yNF.F(7$$!+c;yONF.F(7$$!+!zOk_$F.F(7$$!+C>4;NF.F(7$$!+equ 0NF.F(7$$!+#>-a\\$F.$!\"$F*7$$!+gCruMF.FD7$$!+HF-aMF.FD7$$!+-QErLF.FD7 $$!+w[])G$F.FD7$$!+SFO-JF.FD7$$!+/1A;HF.FD7$$!+'fW)GFF.FD7$$!+*eo9a#F. FD7$$!+[K\")HDF.FD7$$!+3z:=DF.FD7$$!+oD]1DF.FD7$$!+Gs%[\\#F.$!\"#F*7$$ !+[l`rCF.Fdo7$$!+oeA[CF.Fdo7$$!+3Xg,CF.Fdo7$$!+[J)\\N#F.Fdo7$$!+F/uhAF .Fdo7$$!+1x\\o@F.Fdo7$$!+I=g&*>F.Fdo7$$!+`fqA=F.Fdo7$$!+?T>L@;\"Fh[lFcz7$$\"+!R%y +7Fh[lFcz7$$\"+#fm`B\"Fh[lFcz7$$\"+J%QAF\"Fh[lFcz7$$\"+([HvI\"Fh[lFcz7 $$\"+ocrY8Fh[lFcz7$$\"+A![1Q\"Fh[lFcz7$$\"+Z:;>9Fh[lFcz7$$\"+WCEa9Fh[l Fcz7$$\"+w)fMZ\"Fh[lFcz7$$\"+4tl#\\\"Fh[lFcz7$$\"+Eys%\\\"Fh[lFcz7$$\" +W$)z'\\\"Fh[lFcz7$$\"+-O$y\\\"Fh[lFcz7$$\"+h)o))\\\"Fh[lFcz7$$\"+?T!* *\\\"Fh[lFcz7$$\"+y$R4]\"Fh[l$\"\"#Fez7$$\"+7/30:Fh[lFfal7$$\"+Z9A4:Fh [lFfal7$$\"+;N]<:Fh[lFfal7$$\"+&e&yD:Fh[lFfal7$$\"+/-lW:Fh[lFfal7$$\"+ B[^j:Fh[lFfal7$$\"+0%f**f\"Fh[lFfal7$$\"+y,QO;Fh[lFfal7$$\"+mpms;Fh[lF fal7$$\"+5s_2Fh[lFfal 7$$\"+iAKj>Fh[lFfal7$$\"+6]1,?Fh[lFfal7$$\"+gu#e.#Fh[lFfal7$$\"+j*G92# Fh[lFfal7$$\"+_st5@Fh[lFfal7$$\"+)oFj9#Fh[lFfal7$$\"+wbs#=#Fh[lFfal7$$ \"+!HT(>AFh[lFfal7$$\"+Nfw`AFh[lFfal7$$\"+/^.!H#Fh[lFfal7$$\"+!>GgK#Fh [lFfal7$$\"+.'HXO#Fh[lFfal7$$\"+La])R#Fh[lFfal7$$\"+)[1xV#Fh[lFfal7$$ \"+_WRbCFh[lFfal7$$\"+B(GFh[lFghl7$$\"+oq33HFh[lFghl7$$\"+F zcWHFh[lFghl7$$\"+DqB$)HFh[lFghl7$$\"+.Gp=IFh[lFghl7$$\"+2Ap`IFh[lFghl 7$$\"+&*f5\"4$Fh[lFghl7$$\"+O$Q%GJFh[lFghl7$$\"+Hj%>;$Fh[lFghl7$$\"#KF *Fghl-%'COLOURG6&%$RGBG$\"*++++\"!\")FjtFjt-%*THICKNESSG6#Fgal-F$6%7`q 7$$!39+++++++S!#FFb^m7$$!31#===eS&>OFd^mFf^m7$$!3EOOOw[])G$Fd^mFi^m7$$ !3,kjj.1A;HFd^mF\\_m7$$!36444*eo9a#Fd^mF__m7$$!3qXXX0x\\o@Fd^mFb_m7$$! 36tss_fqA=Fd^mFe_m7$$!3U#===ieYY\"Fd^mFh_m7$$!3S+++gbO%4\"Fd^mF[`m7$$! 3oHFFF.g_s!#GF^`m7$$!3A#444H'*eX$F``mFb`m7$$!36?\"444tv6\"!#HFe`m7$$\" 3)[sss7^Hl$F``mFi`m7$$\"3;;===y6LuF``mF\\am7$$\"3\"psss)3g26Fd^mF_am7$ $\"3*RXXXH5%Q9Fd^mFbam7$$\"3!fjjjnu<$=Fd^mFeam7$$\"3'\\aaa!f+l@Fd^mFha m7$$\"3+jjjVIj_DFd^mF[bm7$$\"3'4===u[d*GFd^mF^bm7$$\"3WjjjV5?sKFd^mFab m7$$\"3^<==eEnIOFd^mFdbm7$$\"3O\"====+Z+%Fd^mFgbm7$$\"3#psss?u\"[VFd^m Fjbm7$$\"3+WXXXtl=ZFd^mF]cm7$$\"3uijj._[.^Fd^mF`cm7$$\"3![aaa)*y%QaFd^ mFccm7$$\"3wDFFZ9G+eFd^mFfcm7$$\"3#=FFFzeS<'Fd^mFicm7$$\"3[ijj.qsRlFd^ mF\\dm7$$\"3S*******zHN*oFd^mF_dm7$$\"3Oijj$[njG(Fd^mFbdm7$$\"3S_aa9' \\$RwFd^mFedm7$$\"3$4===QLi,)Fd^mFhdm7$$\"3A)3444YxN)Fd^mF[em7$$\"3\"p ssso46t)Fd^mF^em7$$\"39_aaMdT#3*Fd^mFaem7$$\"3!f\"==y@; \"F\\fmFgfm7$$\"3Xaaa!R%y+7F\\fmFjfm7$$\"3%)*****>fm`B\"F\\fmF]gm7$$\" 3SjjjJ%QAF\"F\\fmF`gm7$$\"3o!44p[HvI\"F\\fmFcgm7$$\"3QOOOocrY8F\\fmFfg m7$$\"3'z\"==A![1Q\"F\\fmFigm7$$\"39F\\fmF\\hm7$$\"3COOOWCEa9F \\fmF_hm7$$\"3AXXX4tl#\\\"F\\fmFbhm7$$\"3gsss%e&yD:F\\fmFehm7$$\"39FFF B[^j:F\\fmFhhm7$$\"314440%f**f\"F\\fmF[im7$$\"3Xaaay,QO;F\\fmF^im7$$\" 3Aaaampms;F\\fmFaim7$$\"3v\"==)4s_2F\\fmFfjm7$$\"3qaaaiA Kj>F\\fmFijm7$$\"3C\"444,l5+#F\\fmF\\[n7$$\"3%)******fu#e.#F\\fmF_[n7$ $\"3!444H'*G92#F\\fmFb[n7$$\"3ROOO_st5@F\\fmFe[n7$$\"3Usss)oFj9#F\\fmF h[n7$$\"3SOOOwbs#=#F\\fmF[\\n7$$\"3naaa!HT(>AF\\fmF^\\n7$$\"39\"44\\$f w`AF\\fmFa\\n7$$\"3%******R5N+H#F\\fmFd\\n7$$\"3l\"==)*=GgK#F\\fmFg\\n 7$$\"3!ROOOgHXO#F\\fmFj\\n7$$\"3AXXXLa])R#F\\fmF]]n7$$\"3%)*****z[1xV# F\\fmF`]n7$$\"3;XXXr\\+p#F\\fmFe^n7$$\"3FXXXD$y'GFF\\f mFh^n7$$\"3?+++;G5iFF\\fmF[_n7$$\"3Paaae?\\+GF\\fmF^_n7$$\"3lsssk*zl$G F\\fmFa_n7$$\"3+444,$>B(GF\\fmFd_n7$$\"3;$F\\fmF\\an7$$\"37+++++++KF\\fmF_an-Fe]m6&Fg]m$\")#)eq kFj]m$\"))eqk\"Fj]mFeanF[^m-F$6%7$7$$!3!)*************\\$Fd^mFb^m7$F[b nF_an-Fe]m6&Fg]mFjtFjtFh]m-%*LINESTYLEG6#Fhhl-F$6%7$7$$!3;+++++++DFd^m Fb^m7$FgbnF_anF^bnF`bn-F$6%7$7$$!3++++++++:Fd^mFb^m7$F^cnF_anF^bnF`bn- F$6%7$7$$!3=+++++++]F``mFb^m7$FecnF_anF^bnF`bn-F$6%7$7$$\"3K+++++++]Fd ^mFb^m7$F\\dnF_anF^bnF`bn-F$6%7$7$$\"3)**************\\\"F\\fmFb^m7$Fc dnF_anF^bnF`bn-F$6%7$7$$\"31+++++++DF\\fmFb^m7$FjdnF_anF^bnF`bn-F$6%7$ 7$$!3)***************HFd^mFb^m7$FaenF_an-%&COLORG6&Fg]mFjt$\"\"(FdrFjt F`bn-F$6%7$7$$!33+++++++?Fd^mFb^m7$F]fnF_anFdenF`bn-F$6%7$7$$!3/++++++ +5Fd^mFb^m7$FdfnF_anFdenF`bn-F$6%7$7$FjtFb^m7$FjtF_anFdenF`bn-F$6%7$7$ $\"31+++++++5F\\fmFb^m7$F`gnF_anFdenF`bn-F$6%7$7$$\"37+++++++?F\\fmFb^ m7$FggnF_anFdenF`bn-F$6%7$7$$\"3)***************HF\\fmFb^m7$F^hnF_anFd enF`bn-%*AXESTICKSG6$\"\")7)/Fdo%-0.9999999998G/Fjt%,1.000000000G/Fcz% ,1.000000001G/Ffal%,1.000000002G/Fghl%,1.000000003G/$\"\"%Fez%,1.00000 0004G/$\"\"&Fez%,1.000000005G-%+AXESLABELSG6%Q\"x6\"Q\"yF\\jn-%%FONTG6 #%(DEFAULTG-%*AXESSTYLEG6#%&FRAMEG-F_jn6$%*HELVETICAG\"\"*-%%VIEWG6$;F (Fb]mF][o" 1 2 0 1 10 0 2 9 1 3 2 1.000000 45.000000 45.000000 0 0 "Cu rve 1" "Curve 2" "Curve 3" "Curve 4" "Curve 5" "Curve 6" "Curve 7" "Cu rve 8" "Curve 9" "Curve 10" "Curve 11" "Curve 12" "Curve 13" "Curve 14 " "Curve 15" "Curve 16" }}{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 4 "The " }{TEXT 337 1 "x" }{TEXT -1 51 " values where the 10 digit float ing-point value of " }{XPPEDIT 18 0 "1+x;" "6#,&\"\"\"F$%\"xGF$" } {TEXT -1 7 " is in " }{TEXT 259 15 "exact agreement" }{TEXT -1 66 " wi th the true value are indicated in the picture by the vertical " } {TEXT 257 5 "green" }{TEXT -1 52 " dashed lines and are shown in the f ollowing table. " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "m atrix([[x, 1+x], [________, ________], [-3*`.`*10^(-10), .9999999997], [-2*`.`*10^(-10), .9999999998], [-1*`.`*10^(-10), .9999999999], [0, 1 .000000000], [1*`.`*10^(-9), 1.000000001], [2*`.`*10^(-9), 1.000000002 ], [3*`.`*10^(-9), 1.000000003]]);" "6#-%'matrixG6#7+7$%\"xG,&\"\"\"F* F(F*7$%)________GF,7$,$*(\"\"$F*%\".GF*)\"#5,$F3!\"\"F*F5-%&FloatG6$\" +(*********!#57$,$*(\"\"#F*F1F*)F3,$F3F5F*F5-F76$\"+)*********F:7$,$*( F*F*F1F*)F3,$F3F5F*F5-F76$\"+**********F:7$\"\"!-F76$\"+++++5!\"*7$*(F *F*F1F*)F3,$\"\"*F5F*-F76$\"+,+++5FQ7$*(F>F*F1F*)F3,$FVF5F*-F76$\"+-++ +5FQ7$*(F0F*F1F*)F3,$FVF5F*-F76$\"+.+++5FQ" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 3 "As " }{TEXT 338 1 "x" }{TEXT -1 24 " increases the value of " }{XPPEDIT 18 0 "1+x" "6#,& \"\"\"F$%\"xGF$" }{TEXT -1 199 " when calculated with 10 digit floatin g-point arithmetic does not change continuously. The value remains con stant over a small interval and then \"jumps\" to a new (higher) value . These jumps occur at " }{TEXT 339 1 "x" }{TEXT -1 70 " values mid-wa y the values where exact agreement occurs. The relevant " }{TEXT 340 1 "x" }{TEXT -1 20 " values where these " }{TEXT 259 14 "sudden change s" }{TEXT -1 17 " in the value of " }{XPPEDIT 18 0 "1+x" "6#,&\"\"\"F$ %\"xGF$" }{TEXT -1 52 " occur are indicated in the picture by the vert ical " }{TEXT 256 4 "blue" }{TEXT -1 56 " dashed lines and are also sh own in the following table." }}{PARA 256 "" 0 "" {TEXT -1 1 " " } {XPPEDIT 18 0 "matrix([[x, 1+x], [________, ________],[-35*`.`*10^(-11 ), .99999999965], [-25*`.`*10^(-11), .99999999975], [-15*`.`*10^(-11), .99999999985], [-5*`.`*10^(-11), .99999999995], [0, 1.0000000005], [1 5*`.`*10^(-10), 1.0000000015], [25*`.`*10^(-10), 1.0000000025]])" "6#- %'matrixG6#7+7$%\"xG,&\"\"\"F*F(F*7$%)________GF,7$,$*(\"#NF*%\".GF*) \"#5,$\"#6!\"\"F*F6-%&FloatG6$\",l*********!#67$,$*(\"#DF*F1F*)F3,$F5F 6F*F6-F86$\",v*********F;7$,$*(\"#:F*F1F*)F3,$F5F6F*F6-F86$\",&)****** ***F;7$,$*(\"\"&F*F1F*)F3,$F5F6F*F6-F86$\",&**********F;7$\"\"!-F86$\" ,0++++\"!#57$*(FHF*F1F*)F3,$F3F6F*-F86$\",:++++\"Ffn7$*(F?F*F1F*)F3,$F 3F6F*-F86$\",D++++\"Ffn" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 4 " " 0 "" {TEXT -1 34 "A unit in the last place .. 1 ulp " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 236 "The least possible \+ non-zero error which can possibly occur in a numerical calculation is \+ that the last digit of the computed result differs by 1 in the last di git from the correct result (to the specified number of significant di gits). " }}{PARA 0 "" 0 "" {TEXT -1 36 "For example, in the multiplica tion: " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "1/7;" "6#*& \"\"\"F$\"\"(!\"\"" }{TEXT -1 1 " " }{TEXT 299 1 "x" }{TEXT -1 3 " 3 \+ " }}{PARA 0 "" 0 "" {TEXT -1 52 "performed in 10 digit floating-point \+ arithmetic as: " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 30 13 "0.14 28571429 " }{TEXT 300 1 "x" }{TEXT 30 6 " 3 = 0" }{TEXT -1 13 ".428571 4287, " }}{PARA 0 "" 0 "" {TEXT -1 23 "the result differs by: " }} {PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 30 12 "0.0000000001" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 51 "from the most accurate 10 sign ificant digit value: " }}{PARA 256 "" 0 "" {TEXT -1 15 "0 .4285714286. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 10 "Note that " }{XPPEDIT 18 0 "3/7" "6#*&\"\"$\"\"\"\"\"(!\"\"" }{TEXT -1 47 " has the infinite repeating decimal expansion: " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "3/7=0" "6#/*&\"\"$\"\"\"\"\"(!\"\"\"\"! " }{TEXT -1 1 "." }{XPPEDIT 18 0 "428571428571428571*` . . . `" "6#*& \"3r&G9dG9dG%\"\"\"%(~.~.~.~GF%" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "evalf(1/7); \n%*3;\nevalf(3/7);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+H9dG9!#5" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+(G9dG%!#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+'G9dG%!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 27 "In this example, the value " }{TEXT 30 11 "0.000000000" }{XPPEDIT 18 0 "1 = 10^(-10);" "6#/\"\"\")\"#5,$F&!\"\"" }{TEXT 30 14 " represen ts 1 " }{TEXT 259 22 "unit in the last place" }{TEXT 30 48 " or 1 ulp, with respect to either of the values." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 20 "In the calculation: " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "1/70" "6#*&\"\"\"F$\"#q!\"\"" } {TEXT -1 1 " " }{TEXT 302 1 "x" }{TEXT -1 3 " 3 " }}{PARA 0 "" 0 "" {TEXT -1 52 "performed in 10 digit floating-point arithmetic as: " }} {PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 30 14 "0.01428571429 " }{TEXT 301 1 "x" }{TEXT 30 6 " 3 = 0" }{TEXT -1 14 ".04285714287, " }}{PARA 0 "" 0 "" {TEXT -1 23 "the result differs by: " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{TEXT 30 13 "0.00000000001" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 51 "from the most accurate 10 significant digit value : " }}{PARA 256 "" 0 "" {TEXT -1 16 "0 .04285714286. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "evalf(1/70);\n%*3;\nevalf(3/70);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+H9dG9!#6" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+(G9dG%!#6" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+'G 9dG%!#6" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "In the second exampl e, the error in the first value is " }{TEXT 30 11 "0.000000000" } {XPPEDIT 18 0 "1 = 10^(-11);" "6#/\"\"\")\"#5,$\"#6!\"\"" }{TEXT 30 12 " represents " }{TEXT 259 24 "1 unit in the last place" }{TEXT 30 49 " or 1 ulp, with respect to either of the values. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 138 "To provide a mechanic al way via Maple of obtaining 1 ulp with respect to a given floating-p oint number and a given precision (setting for " }{TEXT 260 6 "Digits " }{TEXT -1 31 ") consider first the following " }{TEXT 259 34 "intege r base 10 logarithm function" }{TEXT -1 1 " " }{TEXT 271 9 "ilog10(x) " }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 4 "The " }{TEXT 271 9 "i log10(x)" }{TEXT -1 35 " function returns the integer base " }{TEXT 271 2 "10" }{TEXT -1 14 " logarithm of " }{TEXT 271 1 "x" }{TEXT -1 23 ", that is, the integer " }{TEXT 271 1 "r" }{TEXT -1 11 " such that " }{TEXT 271 25 "10^r <= abs(x) < 10^(r+1)" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 161 "' ilog10(100)'=ilog10(100);\n'ilog10(99.9)'=ilog10(99.9);\n'ilog10(10)'= ilog10(10);\n'ilog10(9.99)'=ilog10(9.99);\n'ilog10(1)'=ilog10(1);\n'il og10(0.99)'=ilog10(0.99);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%'ilog1 0G6#\"$+\"\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%'ilog10G6#$\"$** *!\"\"\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%'ilog10G6#\"#5\"\" \"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%'ilog10G6#$\"$***!\"#\"\"!" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%'ilog10G6#\"\"\"\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%'ilog10G6#$\"#**!\"#!\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 23 "The following function " }{TEXT 271 6 "ul p(x)" }{TEXT -1 53 " finds 1 ulp with respect to a floating-point numb er " }{TEXT 303 1 "x" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 71 "T his function is based on a formula which appears on the help page ... \+ " }{HYPERLNK 17 "testfloat" 2 "testfloat" "" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "ul p := x -> Float(1,-Digits+1+ilog10(x));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$ulpGf*6#%\"xG6\"6$%)operatorG%&arrowGF(-%&FloatG6$\"\"\",(%'D igitsG!\"\"F/F/-%'ilog10G6#9$F/F(F(F(" }}}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "ulp(.4285714287);\nulp( .04285714287);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"!#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"!#6" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 84 "1 ulp with respect to a number close to 1 can be compared with the machine epsilon. " }}{PARA 0 "" 0 "" {TEXT -1 83 "For 10 dig it (Maple software) floating-point arithmetic, 1 ulp for the number 1 \+ is:" }}{PARA 256 "" 0 "" {TEXT -1 11 " 0.00000000" }{XPPEDIT 18 0 "1=1 0^(-9)" "6#/\"\"\")\"#5,$\"\"*!\"\"" }{TEXT -1 2 ", " }}{PARA 0 "" 0 " " {TEXT -1 44 "while 1 ulp for 0.9999999999 is 0.000000000" } {XPPEDIT 18 0 "1=10^(-10)" "6#/\"\"\")\"#5,$F&!\"\"" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 22 "The machine epsilon 5 " }{TEXT 307 1 "x " }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-10)" "6#)\"#5,$F$!\"\"" }{TEXT -1 5 " is " }{TEXT 259 20 "between these values" }{TEXT -1 1 "." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 66 "More gene rally, for Maple software floating-point arithmetic with " }{TEXT 260 6 "Digits" }{TEXT -1 8 " set to " }{TEXT 304 6 "Digits" }{TEXT -1 27 " , 1 ulp for the number 1 is" }}{PARA 256 "" 0 "" {TEXT -1 1 " " } {XPPEDIT 18 0 "10^(-Digits+1)" "6#)\"#5,&%'DigitsG!\"\"\"\"\"F(" } {XPPEDIT 18 0 "``= 10" "6#/%!G\"#5" }{TEXT -1 1 " " }{TEXT 319 1 "x" } {TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-Digits)" "6#)\"#5,$%'DigitsG!\"\" " }{TEXT -1 2 ", " }}{PARA 0 "" 0 "" {TEXT -1 30 "while 1 ulp for 0.9 999...99 (" }{TEXT 306 6 "Digits" }{TEXT -1 19 " number of 9's) is " } {XPPEDIT 18 0 "10^(-Digits)" "6#)\"#5,$%'DigitsG!\"\"" }{TEXT -1 2 ". \+ " }}{PARA 0 "" 0 "" {TEXT -1 22 "The machine epsilon 5 " }{TEXT 318 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^(-Digits);" "6#)\"#5,$%'DigitsG !\"\"" }{TEXT -1 26 " is between these values." }}{PARA 0 "" 0 "" {TEXT -1 31 "In fact the machine epsilon is " }{XPPEDIT 18 0 "1/2" "6# *&\"\"\"F$\"\"#!\"\"" }{TEXT -1 23 " ulp for the number 1. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 62 "Characteristics of Maple's so ftware floating-point arithmetic " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 71 "Some of the material in this section is a dapted from Maple help pages: " }{HYPERLNK 17 "float" 2 "float" "" } {TEXT -1 2 ", " }{HYPERLNK 17 "Maple_floats" 2 "Maple_floats" "" } {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 128 "A Maple software floating-point number can be constructe d from integer values for the mantissa and exponent using the procedur e " }{TEXT 0 5 "Float" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 70 "The mantissa and exponent can be recovered by means of the procedures " }{TEXT 0 14 "SFloatMantissa" }{TEXT -1 5 " and " }{TEXT 0 14 "SFloa tExponent" }{TEXT -1 15 " respectively. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 104 "A software floating-point number is represented internally in Maple by a pair of integers (the mantiss a " }{TEXT 35 1 "M" }{TEXT -1 18 " and the exponent " }{TEXT 35 1 "E" }{TEXT -1 3 "). " }}{PARA 15 "" 0 "" {TEXT -1 4 "The " }{TEXT 35 11 "F loat(M, E)" }{TEXT -1 60 " command can be used to construct the floati ng-point number " }{TEXT 35 8 "M * 10^E" }{TEXT -1 2 ". " }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "a := \+ Float(123456789,-5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG$\"**ycM 7!\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "a_mantissa := SFlo atMantissa(a);\na_exponent := SFloatExponent(a);\n" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%+a_mantissaG\"**ycM7" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%+a_exponentG!\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 " ;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 148 "Va rious parameters and constants associated with Maple's arbitrary preci sion software floating-point arithmetic can be evaluated with the proc edure " }{TEXT 0 12 "Maple_floats" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 31 "Some of the constants kn own to " }{TEXT 0 12 "Maple_floats" }{TEXT -1 6 " are: " }}{PARA 17 " " 0 "" {TEXT -1 32 " " }}{PARA 17 "" 0 "" {TEXT -1 71 " MAX_DIGITS Maximum setting of Digits \+ " }}{PARA 17 "" 0 "" {TEXT -1 355 " MAX_EXP M aximum exponent \n MIN_EXP \+ Minimum exponent \n MAX_FLOAT \+ Float(1,MAX_EXP) \n MIN_FLOAT \+ Float(1,MIN_EXP) \n LN_MAX_F LOAT evalf(ln(MAX_FLOAT)) - 1 ULP \n" }} {PARA 15 "" 0 "" {TEXT 359 10 "MAX_DIGITS" }{TEXT -1 51 ": The maximum setting for the environment variable " }{TEXT 260 6 "Digits" }{TEXT -1 107 " which controls the number of digits that Maple uses when calc ulating with software floating-point numbers." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "Maple_floats (MAX_DIGITS);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"*[aVo#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 355 7 "MAX_EXP" }{TEXT -1 151 ": The maximum \+ (largest positive) exponent of a normalised software floating-point nu mber, that is, one which has no leading zeros in the the mantissa. " } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "Maple_floats(MAX_EXP);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"+YO[ Z@" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 358 7 "MIN_EXP" }{TEXT -1 90 ": The minimum (largest negative) exponent of a normalised software floa ting-point number. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "Maple_floats(MIN_EXP);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#!+YO[Z@" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 "; " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 356 9 "MAX _FLOAT" }{TEXT -1 78 ": The maximum (largest positive) representable s oftware floating-point number." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "Maple_floats(MAX_FLOAT);\nFl oat(1,Maple_floats(MAX_EXP));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\" \"\"+YO[Z@" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"\"+YO[Z@" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 357 9 "MIN_FLOAT" }{TEXT -1 79 ": The minimum (smallest positive) representable software floating-point num ber." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "Maple_floats(MIN_FLOAT);\nFloat(1,Maple_floats(MIN_EX P));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"!+YO[Z@" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"!+YO[Z@" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 " " {TEXT 360 12 "LN_MAX_FLOAT" }{TEXT -1 45 ": The largest software flo ating-point number " }{TEXT 271 1 "x" }{TEXT -1 11 " such that " } {TEXT 271 6 "exp(x)" }{TEXT -1 5 " and " }{TEXT 271 7 "exp(-x)" } {TEXT -1 84 " are representable as software floating-point numbers.\nI t is ln(MAX_FLOAT) - 1 ulp ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "Maple_floats(LN_MAX_FLOAT); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+IQwW\\\"\"!" }}}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 278 "ln_max_fl oat_plus := ln(Maple_floats(MAX_FLOAT));\n'exp(ln_max_float_plus)'=exp (ln_max_float_plus);\n'exp(-ln_max_float_plus)'=exp(-ln_max_float_plus );\nln_max_float := NextAfter(ln_max_float_plus,-1);\n'exp(ln_max_floa t)'=exp(ln_max_float);\n'exp(-ln_max_float)'=exp(-ln_max_float);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%2ln_max_float_plusG$\"+JQwW\\\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%$expG6#%2ln_max_float_plusG$\"\" \"%)infinityG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%$expG6#,$%2ln_max_ float_plusG!\"\"$!\"!\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%-ln_ma x_floatG$\"+IQwW\\\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%$expG6#% -ln_max_floatG$\"#[\"+WO[Z@" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%$exp G6#,$%-ln_max_floatG!\"\"$\"\"#!+YO[Z@" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 " " 0 "info" {TEXT -1 76 "Characteristics of Maple's hardware floating-p oint arithmetic available via " }{TEXT 0 6 "evalhf" }{TEXT -1 1 " " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 72 "Some of t he material in this section is adapted from a Maple help page: " } {HYPERLNK 17 "evalhf[constant]" 2 "evalhf[constant]" "" }{TEXT -1 1 " \+ " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT -1 16 "Firs t note that " }{TEXT 260 14 "evalhf(Digits)" }{TEXT -1 125 " returns t he approximate number of digits of the hardware floating-point system in use, regardless of the actual setting of " }{TEXT 260 6 "Digits" } {TEXT -1 98 ". This constant takes into account the precision returned by the standard mathematical functions. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalhf(Digits);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"#9\"\"!" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 147 "The following constants give the characteristics of th e hardware floating-point arithmetic available for use in Maple on a p articular platform via " }{TEXT 0 6 "evalhf" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 206 "They are taken from the (American National Sta ndards Institute) ANSI-C definition of floating-point parameters of an (Institute of Electrical and Electronics Engineers) IEEE-standard flo ating-point system. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 17 "" 0 "wmitable" {TEXT -1 196 "FLT_RADIX DBL_MANT_DIG DBL_DIG \+ DBL_EPSILON \n DBL_EPSILON DBL_MIN_EXP DBL_MIN \+ DBL_MIN_10_EXP \nDBL_MAX_EXP DBL_MAX DBL_MAX_10_EXP LNM AXFLOAT " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 127 "The particular information discussed and obtained with M aple below is obtained on a typical PC with an Intel Pentium processor ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 345 9 "FLT _RADIX" }{TEXT -1 59 ": The base (or radix) of the floating-point numb er system. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 18 "evalhf(FLT_RADIX);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"#\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 344 12 "DBL_MAN T_DIG" }{TEXT -1 114 ": The number of significant base digits, that is , the number of digits in the mantissa of a floating-point number." }} {PARA 0 "" 0 "" {TEXT -1 33 " For a standard 64 bit binary " } {TEXT 259 16 "double precision" }{TEXT -1 63 " floating-point number, \+ 53 bits are allocated for the mantissa." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "evalhf(DBL_MANT_DIG);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"#`\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 " " 0 "" {TEXT 343 7 "DBL_DIG" }{TEXT -1 69 ": The (approximate) equival ent number of significant decimal digits. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "evalhf(DBL_DIG);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"#:\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 " " 0 "" {TEXT 342 11 "DBL_EPSILON" }{TEXT -1 24 ": The smallest positiv e " }{TEXT 35 1 "x" }{TEXT -1 11 " such that " }{TEXT 35 14 "1.0 + x < > 1.0" }{TEXT -1 66 " , that is, the machine epsilon for the floating- point arithmetic." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "evalhf(DBL_EPSILON);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"338.D\\gW?A!#L" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 " " {TEXT 341 11 "DBL_MAX_EXP" }{TEXT -1 172 ": The maximum (largest pos itive) exponent of a normalised floating-point number, that is, one wh ich has no leading zeros in the the mantissa. \nFor a standard 64 bit \+ binary " }{TEXT 259 16 "double precision" }{TEXT -1 138 " floating-poi nt number, 11 bits are allocated for the exponent, one of which gives \+ the sign. \nIn this case the maximum exponent will be " }{XPPEDIT 18 0 "2^10 = 1024;" "6#/*$\"\"#\"#5\"%C5" }{TEXT -1 1 "." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 24 " More precisely , the " }{TEXT 259 16 "two's complement" }{TEXT -1 43 " format is used whereby the binary numbers " }}{PARA 256 "" 0 "" {TEXT -1 71 "0000000 0000, 00000000001, 00000000010, ... , 01111111111, 10000000000, " }} {PARA 0 "" 0 "" {TEXT -1 90 " represent the numbers 0, 1, 2, ... ,1 023, 1024 respectively, while the binary numbers " }}{PARA 256 "" 0 " " {TEXT -1 71 " 10000000001, 10000000010, 10000000011, ... , 111111111 10, 11111111111," }}{PARA 0 "" 0 "" {TEXT -1 74 " represent the num bers -1023, -1022, -1021, ... , -2, -1, respectively." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "evalhf(DB L_MAX_EXP);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"%C5\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 346 7 "DBL_MAX" }{TEXT -1 326 ": The maximum \+ (largest positive) normalised representable hardware floating-point nu mber.\nFor a normalised 64 bit binary double precision floating-point \+ number, 53 (effective) bits are allocated for the mantissa (excluding \+ the sign bit) and 11 bits are allocated for the exponent. Note that th e first bit of the mantissa is a " }{TEXT 259 11 "phantom bit" }{TEXT -1 111 ", that is, it does not need to be stored since it is always a \+ 1.\nThis leaves 1 bit for the sign of the number. " }}{PARA 0 "" 0 "" {TEXT -1 4 " " }}{PARA 0 "" 0 "" {TEXT -1 25 " The largest manti ssa " }}{PARA 256 "" 0 "" {TEXT -1 3 " 0." }{TEXT 349 0 "" }{TEXT -1 53 "11111111111111111111111111111111111111111111111111111" }{XPPEDIT 18 0 "``[2] = ``(1-2^(-53));" "6#/&%!G6#\"\"#-F%6#,&\"\"\"F+)F',$\"#`! \"\"F/" }{TEXT -1 2 ", " }}{PARA 0 "" 0 "" {TEXT -1 36 " taken with the maximum exponent " }{XPPEDIT 18 0 "2^10 = 1024;" "6#/*$\"\"#\"#5 \"%C5" }{TEXT -1 51 ", gives a largest possible floating-point value o f " }{XPPEDIT 18 0 " ``(1-2^(-53))" "6#-%!G6#,&\"\"\"F')\"\"#,$\"#`!\" \"F," }{TEXT -1 1 " " }{TEXT 350 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "2^(1024)" "6#*$\"\"#\"%C5" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 77 " The approximate decimal equivalent of this value is 1.7976 9313486231571 " }{TEXT 354 1 "x" }{TEXT -1 1 " " }{XPPEDIT 18 0 "10^30 8" "6#*$\"#5\"$3$" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "(1-2^(-53))*2^1024:\nevalf[1 8](evalf[25](%));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3r:B'[8$p(z\" \"$\"H" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 29 " The Maple value given by " }{TEXT 260 15 "evalhf(DBL_MAX)" } {TEXT -1 23 " is smaller than this. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "evalhf(DBL_MAX);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"2-+++!********\"$\"H" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 95 " However the largest r epresentable hardware floating-point number which can be obtained via \+ " }{TEXT 0 6 "evalhf" }{TEXT -1 38 " appears to be the larger value ab ove." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 173 "(1-2^(-53))*2^1024:\nlargest_double := evalf[18](eva lf[25](%));\nexcess := evalf[18](largest_double-evalhf(DBL_MAX));\ndou ble_max := evalhf(DBL_MAX);\nevalhf(double_max+excess);" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%/largest_doubleG$\"3r:B'[8$p(z\"\"$\"H" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%'excessG$\"2p:B'[9$p(z\"$\"H" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%+double_maxG$\"2-+++!********\"$\"H " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3s:B'[8$p(z\"\"$\"H" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 32 " But then in some situations " }{TEXT 0 6 "evalhf" }{TEXT -1 33 " cannot handle th e larger value. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 71 "evalhf(largest_double);\nevalhf(.9999999999999 9999e308);\nevalhf(.1e309);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\" %)infinityG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3-+++++++5\"$\"H" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"\"\"%)infinityG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 347 14 "DBL_MAX_10_EXP" }{TEXT -1 47 ": Maximum expon ent of a representable power of " }{TEXT 35 2 "10" }{TEXT -1 1 " " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "evalhf(DBL_MAX_10_EXP);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"$3$ \"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 353 11 "DBL_MIN_EXP" }{TEXT -1 304 ": The minimum (largest negative) exponent of a normalised floa ting-point number, that is, one which has no leading zeros in the the \+ mantissa.\nFor a 64 bit binary double precision floating-point number, 11 bits are allocated for the exponent. As indicated above, the minim um exponent will be around -1023." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "evalhf(DBL_MIN_EXP);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$!%@5\"\"!" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 352 7 "DBL_MIN" }{TEXT -1 73 ": The minimum (normalised) repr esentable hardware floating-point number. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "evalhf(DBL_MIN);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3,++++,++5!$C$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 15 "" 0 "" {TEXT 351 14 "DBL_MIN_10_EXP" }{TEXT -1 47 ": Minimum exponent of a representable power of " }{TEXT 35 2 "10" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "evalhf(DBL_MIN_10_EXP);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$!$2$\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 348 10 "LNMAXFL OAT" }{TEXT -1 52 ": A number slightly smaller than the largest number " }{TEXT 35 1 "x" }{TEXT -1 11 " such that " }{TEXT 35 14 "evalhf(exp (x))" }{TEXT -1 5 " and " }{TEXT 35 15 "evalhf(exp(-x))" }{TEXT -1 103 " both successfully compute, and such that the results of those co mputations can continue to be used in " }{TEXT 35 6 "evalhf" }{TEXT -1 41 ". On most machines, this value is set as " }{TEXT 35 20 "evalhf (-ln(DBL_MIN))" }{TEXT -1 32 " truncated to 6 decimal places. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "evalhf(LNMAXFLOAT);\nevalhf(-ln(DBL_MIN));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3I+++++$*oq!#:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"3#3s\"\\Mi$*oq!#:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }} }{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {SECT 1 {PARA 4 "" 0 "" {TEXT -1 5 "Tasks" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 2 "Q1" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 8 "Perform " }{TEXT 259 14 "floating-point" }{TEXT -1 44 " calculat ions to verify experimentally that " }{XPPEDIT 18 0 "Limit((1+1/t)^t,t = infinity) = exp(1);" "6#/-%&LimitG6$),&\"\"\"F)*&F)F)%\"tG!\"\"F)F+ /F+%)infinityG-%$expG6#F)" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 38 "To be more precise, compute values of " }{XPPEDIT 18 0 "(1+1/t)^t; " "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 50 " for a sequence of progressively larger values of " }{TEXT 272 1 "t" }{TEXT -1 31 ", hop efully finding a value of " }{TEXT 273 1 "t" }{TEXT -1 43 " which is l arge enough to give a value for " }{XPPEDIT 18 0 "(1+1/t)^t;" "6#),&\" \"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 41 " which agrees with the decim al value for " }{XPPEDIT 18 0 "exp(1);" "6#-%$expG6#\"\"\"" }{TEXT -1 17 " up to 10 digits." }}{PARA 0 "" 0 "" {TEXT 259 4 "Note" }{TEXT -1 26 ": If you try to evaluate " }{XPPEDIT 18 0 "(1+1/t)^t;" "6#),&\"\" \"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 39 " using floating-point arithmet ic with " }{XPPEDIT 18 0 "t = 10^10;" "6#/%\"tG*$\"#5F&" }{TEXT -1 3 " ( " }{TEXT 260 12 "t = (10.)^10" }{TEXT -1 14 " ) , and with " } {TEXT 0 6 "Digits" }{TEXT -1 93 " set to 10, you will get the value 1. Why is this? How can you get around this difficulty? " }}{PARA 0 " " 0 "" {TEXT -1 42 "__________________________________________" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 " " {TEXT -1 42 "__________________________________________" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 2 "Q2" }}{PARA 0 "" 0 "" {TEXT -1 33 "(i) In the following ca lculation " }{TEXT 274 1 "a" }{TEXT -1 32 " is assigned the value 0, w hile " }{TEXT 275 1 "b" }{TEXT -1 43 " is assigned a non-zero value. W hy is this?" }}{PARA 0 "" 0 "" {TEXT -1 30 "(ii) Is the value assigned to " }{TEXT 276 1 "b" }{TEXT -1 95 " greater or less in magnitude tha n the machine epsilon for hardware floating-point arithmetic? " }} {PARA 0 "" 0 "" {TEXT -1 36 " Is this what you would expect? " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 277 4 "Hint" } {TEXT -1 83 ": Which rational numbers (fractions) can be represented e xactly as binary numbers? " }}{PARA 0 "" 0 "" {TEXT -1 42 "___________ _______________________________" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "Digits := 20:\na := abs(.75- evalhf(3/4));\nb := abs(.8-evalhf(4/5));\nDigits := 10:" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%\"aG$\"\"!F&" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#>%\"bG$\"#U!#=" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 42 "__ ________________________________________" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}} }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 42 " Specimen solutions for the task questions " }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 1 ";" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 "solution \+ for Q1" }}{PARA 0 "" 0 "" {TEXT 333 8 "Question" }{TEXT -1 2 ": " }} {PARA 0 "" 0 "" {TEXT -1 8 "Perform " }{TEXT 259 14 "floating-point" } {TEXT -1 44 " calculations to verify experimentally that " }{XPPEDIT 18 0 "Limit((1+1/t)^t,t = infinity) = exp(1);" "6#/-%&LimitG6$),&\"\" \"F)*&F)F)%\"tG!\"\"F)F+/F+%)infinityG-%$expG6#F)" }{TEXT -1 1 "." }} {PARA 0 "" 0 "" {TEXT -1 38 "To be more precise, compute values of " } {XPPEDIT 18 0 "(1+1/t)^t;" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 50 " for a sequence of progressively larger values of " }{TEXT 320 1 "t" }{TEXT -1 31 ", hopefully finding a value of " }{TEXT 321 1 "t" }{TEXT -1 43 " which is large enough to give a value for " }{XPPEDIT 18 0 "(1+1/t)^t;" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 41 " w hich agrees with the decimal value for " }{XPPEDIT 18 0 "exp(1);" "6#- %$expG6#\"\"\"" }{TEXT -1 17 " up to 10 digits." }}{PARA 0 "" 0 "" {TEXT 259 4 "Note" }{TEXT -1 26 ": If you try to evaluate " } {XPPEDIT 18 0 "(1+1/t)^t;" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 39 " using floating-point arithmetic with " }{XPPEDIT 18 0 "t = 10 ^10;" "6#/%\"tG*$\"#5F&" }{TEXT -1 3 " ( " }{TEXT 260 12 "t = (10.)^10 " }{TEXT -1 14 " ) , and with " }{TEXT 0 6 "Digits" }{TEXT -1 93 " set to 10, you will get the value 1. Why is this? How can you get aroun d this difficulty? " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT 336 8 "Solution" }{TEXT -1 2 ": " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 13 "The value of " }{XPPEDIT 18 0 "exp (1)" "6#-%$expG6#\"\"\"" }{TEXT -1 38 " correct to 10 digits is 2.7182 81828. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "exp(1)=evalf[10](evalf[15](exp(1)));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%$expG6#\"\"\"$\"+G=G=F!\"*" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 125 "Digits := 1 0: t := 't':\nfor k to 10 do\n tt := 10.^k;\n print((1+1/t)^t =eva l((1+1/t)^t,t=tt),` when`,t =``(10)^k);\nend do:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"+gCu$f#!\"*%&~whenG/ F(-%!G6#\"#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"t G!\"\"F&F($\"+HQ\"[q#!\"*%&~whenG/F(*$)-%!G6#\"#5\"\"#F&" }}{PARA 11 " " 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"+KR#pr#!\"*%& ~whenG/F(*$)-%!G6#\"#5\"\"$F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),& \"\"\"F&*&F&F&%\"tG!\"\"F&F($\"+Ff9=F!\"*%&~whenG/F(*$)-%!G6#\"#5\"\"% F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F( $\"+P#o#=F!\"*%&~whenG/F(*$)-%!G6#\"#5\"\"&F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"+p/G=F!\"*%&~whenG/F (*$)-%!G6#\"#5\"\"'F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&* &F&F&%\"tG!\"\"F&F($\"+#p\"G=F!\"*%&~whenG/F(*$)-%!G6#\"#5\"\"(F&" }} {PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"+:= G=F!\"*%&~whenG/F(*$)-%!G6#\"#5\"\")F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"+F=G=F!\"*%&~whenG/F(*$)-%!G6 #\"#5\"\"*F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"t G!\"\"F&F($F&\"\"!%&~whenG/F(*$)-%!G6#\"#5F3F&" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 86 "Using Maple' s 10 digit floating-point arithmetic we obtain the value 2.718281827 f or " }{XPPEDIT 18 0 "(1+1/t)^t;" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F'" }{TEXT -1 6 " when " }{XPPEDIT 18 0 "t=10^9" "6#/%\"tG*$\"#5\"\"*" } {TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 4 "When" }{XPPEDIT 18 0 " t =10^10" "6#/%\"tG*$\"#5F&" }{TEXT -1 2 ", " }{XPPEDIT 18 0 "1/t =10^( -10)" "6#/*&\"\"\"F%%\"tG!\"\")\"#5,$F)F'" }{XPPEDIT 18 0 "``=0" "6#/% !G\"\"!" }{TEXT -1 13 ".0000000001. " }}{PARA 0 "" 0 "" {TEXT -1 35 "S ince this number is less than the " }{TEXT 271 15 "machine epsilon" } {TEXT -1 77 " for 10 digit floating-point arithmetic, we obtain the va lue 1.000000000 for " }{XPPEDIT 18 0 "1+1/t" "6#,&\"\"\"F$*&F$F$%\"tG! \"\"F$" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 24 "The resulting v alue for " }{XPPEDIT 18 0 "(1+1/t)^t" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F% F'" }{TEXT -1 4 " is " }{XPPEDIT 18 0 "1^10000000000=1" "6#/*$\"\"\"\" ,+++++\"F%" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 48 "More decim al digits in the decimal expansion of " }{XPPEDIT 18 0 "exp(1)" "6#-%$ expG6#\"\"\"" }{TEXT -1 49 " can be obtained by performing the evaluat ion of " }{XPPEDIT 18 0 "(1+1/t)^t" "6#),&\"\"\"F%*&F%F%%\"tG!\"\"F%F' " }{TEXT -1 23 " with higher precision." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 147 "Digits := 18: t := 't' :\nfor k from 10 to 18 do\n tt := 10.^k;\n print((1+1/t)^t =eval(( 1+1/t)^t,t=tt),` when`,t =``(10)^k);\nend do:\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"39JJKG=G= F!#<%&~whenG/F(*$)-%!G6#\"#5F4F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/) ,&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"3$QXX%G=G=F!#<%&~whenG/F(*$)-%!G6#\"# 5\"#6F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\" \"F&F($\"34'od%G=G=F!#<%&~whenG/F(*$)-%!G6#\"#5\"#7F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"3K4*e%G=G=F!#<% &~whenG/F(*$)-%!G6#\"#5\"#8F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),& \"\"\"F&*&F&F&%\"tG!\"\"F&F($\"3kJ!f%G=G=F!#<%&~whenG/F(*$)-%!G6#\"#5 \"#9F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\" F&F($\"3)Q/f%G=G=F!#<%&~whenG/F(*$)-%!G6#\"#5\"#:F&" }}{PARA 11 "" 1 " " {XPPMATH 20 "6%/),&\"\"\"F&*&F&F&%\"tG!\"\"F&F($\"35X!f%G=G=F!#<%&~w henG/F(*$)-%!G6#\"#5\"#;F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%/),&\"\" \"F&*&F&F&%\"tG!\"\"F&F($\"3AX!f%G=G=F!#<%&~whenG/F(*$)-%!G6#\"#5\"# " 0 "" {MPLTEXT 1 0 36 "exp(1)=evalf[15](evalf[2 0](exp(1)));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%$expG6#\"\"\"$\"00f %G=G=F!#9" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 1 ";" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 "solution for Q2" }}{PARA 0 "" 0 "" {TEXT 334 8 "Question" }{TEXT -1 2 ": " }} {PARA 0 "" 0 "" {TEXT -1 33 "(i) In the following calculation " } {TEXT 322 1 "a" }{TEXT -1 32 " is assigned the value 0, while " } {TEXT 323 1 "b" }{TEXT -1 43 " is assigned a non-zero value. Why is th is?" }}{PARA 0 "" 0 "" {TEXT -1 30 "(ii) Is the value assigned to " } {TEXT 324 1 "b" }{TEXT -1 95 " greater or less in magnitude than the m achine epsilon for hardware floating-point arithmetic? " }}{PARA 0 "" 0 "" {TEXT -1 36 " Is this what you would expect? " }}{PARA 0 "" 0 "" {TEXT 325 4 "Hint" }{TEXT -1 83 ": Which rational numbers (fracti ons) can be represented exactly as binary numbers? " }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 335 8 "Solution" }{TEXT -1 2 " : " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "Digits := 20:\na := abs(.75-evalhf(3/4));\nb := abs(. 8-evalhf(4/5));\nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\" aG$\"\"!F&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG$\"#U!#=" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 15 "(i) The number " }{XPPEDIT 18 0 "4/5" "6#*&\"\"%\"\"\"\"\"&!\"\"" }{TEXT -1 90 " canot be represente d exactly as a binary fraction with a finite number of binary digits. \+ " }}{PARA 0 "" 0 "" {TEXT -1 151 "The only fractions between 0 and 1 w hich can be expressed exactly with a finite number of binary digits ar e those which have a denominator of the form " }{XPPEDIT 18 0 "2^n" "6 #)\"\"#%\"nG" }{TEXT -1 8 ", where " }{TEXT 326 1 "n" }{TEXT -1 24 " i s a positive integer. " }}{PARA 0 "" 0 "" {TEXT -1 68 "Hence the resul t of the division of 4 by 5, performed in binary via " }{TEXT 0 6 "eva lhf" }{TEXT -1 52 ", and then converted to decimal is not exactly 0.8. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalhf(4/5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3U +++++++!)!#=" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 257 "(ii) Suppose t hat the mantissas in the (double precision) binary hardware floating-p oint numbers involved have (effectively) 53 binary digits. In this cas e the machine epsilon for hardware floating-point arithmetic is 1 ulp \+ for the number 1, that is, it is " }{XPPEDIT 18 0 "2^(-52)" "6#)\"\"#, $\"#_!\"\"" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 85 "On the oth er hand, the error in the hardware binary floating-point representatio n of " }{XPPEDIT 18 0 "4/5" "6#*&\"\"%\"\"\"\"\"&!\"\"" }{TEXT -1 14 " is less than " }{XPPEDIT 18 0 "1/2" "6#*&\"\"\"F$\"\"#!\"\"" }{TEXT -1 31 " ulp, that is, it is less than " }{XPPEDIT 18 0 "2^(-54)" "6#) \"\"#,$\"#a!\"\"" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 37 "Henc e we would expect the the number " }{TEXT 327 1 "b" }{TEXT -1 82 " in \+ (i), which is an estimate for this error to be less than the machine e psilon. " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "evalhf(2^(-52));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"338.D\\gW?A!#L" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "evalhf(2^(-54));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"3s#yDJ7:6b&!#M" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{SECT 1 {PARA 4 "" 0 " " {TEXT -1 26 "More detailed explanation " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 61 "The situation can be investigated \+ in more detail as follows. " }}{PARA 0 "" 0 "" {TEXT -1 5 "When " } {XPPEDIT 18 0 "4/5" "6#*&\"\"%\"\"\"\"\"&!\"\"" }{TEXT -1 54 " is conv erted to a binary representation we obtain an " }{TEXT 271 34 "infinit e repeating binary fraction" }{TEXT -1 1 "." }}{PARA 256 "" 0 "" {TEXT -1 59 " .1100110011001100110011001100110011001100110011001100110 0 " }{TEXT 328 5 ". . ." }{TEXT -1 2 " ." }}{PARA 0 "" 0 "" {TEXT -1 145 "We can check that this expansion is correct by grouping the digit s in groups of 4 digits as would be done to perform a conversion to he xadecimal." }}{PARA 256 "" 0 "" {TEXT -1 98 " .1100 | 1100 | 1100 | 11 00 | 1100 | 1100 | 1100 | 1100 | 1100 | 1100 | 1100 | 1100 | 1100 | 11 00 " }{TEXT 329 5 ". . ." }{TEXT -1 2 " ." }}{PARA 0 "" 0 "" {TEXT -1 83 "This enables us to see that the number in question corresponds to \+ the infinite sum " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 " 12/16+12/16^2+12/16^3+12/16^4+` . . . `" "6#,,*&\"#7\"\"\"\"#;!\"\"F&* &F%F&*$F'\"\"#F(F&*&F%F&*$F'\"\"$F(F&*&F%F&*$F'\"\"%F(F&%(~.~.~.~GF&" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 22 "When the common ratio \+ " }{TEXT 330 1 "r" }{TEXT -1 34 " of the infinite geometric series " } }{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "a+a*r+a*r^2+a*r^3+` \+ . . . `" "6#,,%\"aG\"\"\"*&F$F%%\"rGF%F%*&F$F%*$F'\"\"#F%F%*&F$F%*$F' \"\"$F%F%%(~.~.~.~GF%" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 10 " satisfies " }{XPPEDIT 18 0 "abs(r)<1" "6#2-%$absG6#%\"rG\"\"\"" } {TEXT -1 25 " it converges to the sum " }{XPPEDIT 18 0 "a/(1-r)" "6#*& %\"aG\"\"\",&F%F%%\"rG!\"\"F(" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 59 "Using this result shows that the preceding infinite sum i s " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "``(12/16)/(1-1/ 16)=``(12/16)/``(15/16)" "6#/*&-%!G6#*&\"#7\"\"\"\"#;!\"\"F*,&F*F**&F* F*F+F,F,F,*&-F&6#*&F)F*F+F,F*-F&6#*&\"#:F*F+F,F," }{XPPEDIT 18 0 "``=1 2/15" "6#/%!G*&\"#7\"\"\"\"#:!\"\"" }{XPPEDIT 18 0 "``=4/5" "6#/%!G*& \"\"%\"\"\"\"\"&!\"\"" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 154 "The mantissa of the standard 64 bit \+ double precision binary floating-point number which is closest to the \+ \"correct\" infinite binary fraction representing " }{XPPEDIT 18 0 "4/ 5" "6#*&\"\"%\"\"\"\"\"&!\"\"" }{TEXT -1 31 " is given by the 53 bit n umber " }}{PARA 256 "" 0 "" {TEXT -1 56 " .110011001100110011001100110 01100110011001100110011010." }}{PARA 257 "" 0 "" {TEXT -1 98 "Note tha t this result is obtained by truncating the infinite expansion and the n rounding upwards. " }}{PARA 0 "" 0 "" {TEXT -1 58 "The error involve d in using this binary approximation for " }{XPPEDIT 18 0 "4/5" "6#*& \"\"%\"\"\"\"\"&!\"\"" }{TEXT -1 4 " is " }}{PARA 256 "" 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "12/16+12/(16^2)+` . . . `+12/(16^12)+13/(16^3 )-4/5" "6#,.*&\"#7\"\"\"\"#;!\"\"F&*&F%F&*$F'\"\"#F(F&%(~.~.~.~GF&*&F% F&*$F'F%F(F&*&\"#8F&*$F'\"\"$F(F&*&\"\"%F&\"\"&F(F(" }{TEXT -1 1 " " } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 256 "" 0 "" {TEXT -1 1 " " } {XPPEDIT 18 0 "``=12/16+12/(16^2)+` . . . `+12/(16^12)+13/(16^3)-(12/1 6+12/(16^2)+12/(16^3)+12/(16^4)+` . . . `)" "6#/%!G,.*&\"#7\"\"\"\"#;! \"\"F(*&F'F(*$F)\"\"#F*F(%(~.~.~.~GF(*&F'F(*$F)F'F*F(*&\"#8F(*$F)\"\"$ F*F(,,*&F'F(F)F*F(*&F'F(*$F)F-F*F(*&F'F(*$F)F4F*F(*&F'F(*$F)\"\"%F*F(F .F(F*" }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 256 " " 0 "" {TEXT -1 1 " " }{XPPEDIT 18 0 "`` = 1/(16^13)-(12/(16^14)+12/(1 6^15)+12/(16^16)+12/(16^17)+` . . . `);" "6#/%!G,&*&\"\"\"F'*$\"#;\"#8 !\"\"F',,*&\"#7F'*$F)\"#9F+F'*&F.F'*$F)\"#:F+F'*&F.F'*$F)F)F+F'*&F.F'* $F)\"# " 0 "" {MPLTEXT 1 0 55 "Digits := 53:\nconvert(evalf(4/5),binary); \nDigits := 10:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"V,5,5,5,5,5,5,5, 5,5,5,5,5,5\"!#`" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "1/(5*16^13);\nevalf[5](evalf(%));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6##\"\"\"\"2![_o8)*z^A" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"&4W%!#@" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 11 "Wh en using " }{TEXT 0 6 "evalhf" }{TEXT -1 241 " Maple automatically con verts the result to a decimal with about 18 decimal digits. In the cur rent situation the error calculated from this automatically converted \+ decimal value for the double precision binary floating-point represent ion of " }{XPPEDIT 18 0 "4/5" "6#*&\"\"%\"\"\"\"\"&!\"\"" }{TEXT -1 216 " only has two significant digits. Given that we only obtain a two digit approximation for the error in this way, it is comforting to se e that it is not vastly different from the previously calculated error estimate. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{SECT 1 {PARA 0 "" 0 "" {TEXT -1 17 "Code for picture " } }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}{SECT 1 {PARA 0 "" 0 " " {TEXT -1 16 "Graphs of y=x+1 " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 683 "pp_varprcsn := proc(x,d)\n \+ evalf[d](x+1);\nend proc:\ny0 := -4e-10:y1 := 3e-9+2e-10:\nDigits := 10:\np1 := plot(['pp_varprcsn'(x,10)-1,x],x=y0..y1,y=y0..y1, color=[r ed,brown],\n numpoints=100,thickness=2):\nfor i from 0 to 6 do x||i := evalf[11](-(7-i)*5e-11) end do:\nfor i from 0 to 6 do x||(i+7) := \+ i*5e-10 end do:\np2 := plot([seq([[x||(2*i),y0],[x||(2*i),y1]],i=0..6) ],color=blue,linestyle=3):\np3 := plot([seq([[x||(2*i+1),y0],[x||(2*i+ 1),y1]],i=0..6)],\n color=COLOR(RGB,0,.7,0 ),linestyle=3):\nplots[display]([p1,p2,p3],font=[HELVETICA,9],axes=fra med,\n ytickmarks=[-2e-10=`0.9999999998`,seq(i*1e-9=`1.00000000`||`i `,i=0..5)],xtickmarks=8);\nDigits := 10:" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1 ";" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{MARK "4 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }