{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 "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 "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1
257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0
0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0
0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }
{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1
262 "" 0 1 0 0 0 0 0 1 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 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }
{PSTYLE "Heading 2" -1 4 1 {CSTYLE "" -1 -1 "Times" 1 14 0 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 "Maple Output" -1 12 1 {CSTYLE ""
-1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 3 0 0 0 0 1 0 1 0 2
2 0 1 }}
{SECT 0 {EXCHG {PARA 4 "" 0 "" {TEXT -1 23 "Problem Statement 1.5.7" }
}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 80 "Think of a way to make Maple com
pute the thousandth decimal place of the number " }{XPPEDIT 18 0 "pi;
" "6#%#piG" }{TEXT -1 131 ". Please do not count off the decimal place
s as they would appear on the screen after you have given the obvious
Maple instruction" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalf
(Pi,1002);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 205 "Instead, you shoul
d try to find a Maple instruction (or a short sequence of Maple instru
ctions) to print the one required decimal place on the screen and no o
thers. Observe that the first decimal place of " }{XPPEDIT 18 0 "pi;"
"6#%#piG" }{TEXT -1 59 " is its second digit. It may help to use the M
aple command " }{TEXT 256 4 "frac" }{TEXT -1 81 ". Use Maple's help fa
cility to learn about the properties of this Maple function." }}}
{SECT 1 {PARA 3 "" 0 "" {TEXT -1 31 "commentless, inelegant approach"
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalf(Pi,1002);" }}{PARA
12 "" 1 "" {XPPMATH 20 "6#$\"ein%*)>?k@4f>6m(y#>+8m!oAr@`!yd=yd>v$f(y`
B)Q'Gcf6toavG/\\`#)f.t9pw<<1U\"Q3K`(e')GvQy8.+,r\")=J>EN]oWLD3B_UEI3pM
b%fW-&f=j4;GtJ(f5&*\\!yHP)*****\\8@2(=0'*48xu(HO\")f\"=W.k3'>-H@6c*>?a
B*e#*ozAz]5P&e\\l9IM&\\A,4Wo9syrjt\"4'*ydFMrdyF3cj_9F\"o0+K^SpwY=[n%Q_
n<$Hwr@R0x-P%4')z@q!>PZA&RY\\R@g3VmlSCOtO$)H\"\\>,$=QzA\"*[s_d)=Nn&\\F
'*zBYu![&=^5$z6E$>QffdOqs0L%4;^T>&p9%Q@lY?)[0`I8,g.f#*yOk`r\"4a
#HG'4#4_\")[<)e:jg1qeCPFT\"\\-E2OR8#[mKa/h[.YBpc[c94>?r_;$y'yL#[cZGhWL
fmv4\")GW'>QI\\&*[HiW'fb5@&Q>q-TG]u6\"[G\"3%f`sJAe]&4Y%Q4ZmI#G8l3[@)z1
<@MD[.G')**3iG1k\"yI#fW\\(4#e5v$*Rpr>%)G]zKQVEYQKz*e`EfTJ!%,5" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalf(Pi,6);" }}{PARA 11 ""
1 "" {XPPMATH 20 "6#$\"'fTJ!\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 7 "%*10^3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"*+!fTJ!\"&" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "frac(%);" }}{PARA 11 "" 1 ""
{XPPMATH 20 "6#$\"&+!f!\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
5 "%*10;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"'++f!\"&" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "floor(%);" }}{PARA 11 "" 1 ""
{XPPMATH 20 "6#\"\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "eva
lf(Pi,1002):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "%*10^999:" }
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "frac(%):" }}}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 5 "%*10:" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 9 "floor(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalf(Pi,1002):" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "evalf(%*10^999,1002):" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "frac(%):" }}}{EXCHG {PARA 0 "> " 0 "
" {MPLTEXT 1 0 5 "%*10:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "f
loor(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"*" }}}}{SECT 1 {PARA
3 "" 0 "" {TEXT -1 28 "the writing enriched version" }}{EXCHG {PARA 0
"" 0 "" {TEXT -1 134 "The idea is to get rid of the leading and traili
ng digits around the decimal place digit that we are interested in. Th
e Maple command " }{TEXT 258 5 "floor" }{TEXT -1 162 " is a way of get
ting rid of trailing digits after the decimal point, but multiplicatio
n by powers of 10 can move the decimal point to where we want it. Simi
larly " }{TEXT 259 4 "frac" }{TEXT -1 112 " is a way of getting rid of
the leading digits before the decimal point. We have to remember to c
ontinue to use " }{TEXT 260 5 "evalf" }{TEXT -1 903 " keeping enough d
igits for evaluating our quantities since without it Maple reverts to \+
10 digits and we lose the remaining ones. Also it makes sense to do a \+
procedure so we can evaluate any particular decimal place that we wish
, so that we achieve a much more powerful result. And by working first
with a small number of digits we can see how to put together the Mapl
e commands to achieve our goal. And of course we need to check that ou
r answer is right, which the problem tells us how to do by telling us \+
the obvious quick and dirty approach is not the desired way of getting
the result, which indeed would not work very well for getting the res
ult for a really big number of digits, provided MAPLE can still handle
it, not only because it is inelegant, but because it cannot pass on t
he result to a successive MAPLE calculation, should we want to include
this in a larger problem about the digits of " }{XPPEDIT 18 0 "pi;" "
6#%#piG" }{TEXT -1 79 ", since it requires someone to look at the outp
ut and read off the right digit." }}{PARA 0 "" 0 "" {TEXT -1 64 " \nTo
get the 4th decimal place digit, we need 2 extra digits in " }{TEXT
257 5 "evalf" }{TEXT -1 120 " (one for the leading 3, one for the extr
a trailing digit) so roundoff error on the last digit does affect our \+
4th digit" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalf(Pi,6);"
}}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"'fTJ!\"&" }}}{EXCHG {PARA 0 "" 0
"" {TEXT -1 76 "To get rid of the leading digits we multiply by one le
ss power of 10 than 4:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "%*
10^3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"*+!fTJ!\"&" }}}{EXCHG
{PARA 0 "" 0 "" {TEXT -1 35 "Now we remove those leading digits:" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "frac(%);" }}{PARA 11 "" 1 ""
{XPPMATH 20 "6#$\"&+!f!\"&" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 83 "and
promote the first remaining digit to the first place to the left of t
he decimal" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "%*10;" }}
{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"'++f!\"&" }}}{EXCHG {PARA 0 "" 0 "
" {TEXT -1 50 "and get rid of the extra roundoff sensitive digit:" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 " floor(%);" }}{PARA 11 "" 1
"" {XPPMATH 20 "6#\"\"&" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 123 "Now w
e create a procedure doing this for any (positive) integer. We combine
the first multiplication by a power of 10 with " }{XPPEDIT 18 0 "Pi;
" "6#%#PiG" }{TEXT -1 12 " before the " }{TEXT 262 5 "evalf" }{TEXT
-1 159 " to the extra number of digits to avoid the reversion to 10 di
gits. We could have done this outside the evalf but then it would have
to be enclosed in another " }{TEXT 261 5 "evalf" }{TEXT -1 24 " for t
he multiplication." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 103 "pidi
gits:=proc(n::integer)\n floor(frac(\n evalf(Pi*10^(n-1
),n+2)\n )*10) end;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%
)pidigitsGf*6#'%\"nG%(integerG6\"F*F*-%&floorG6#,$*&\"#5\"\"\"-%%fracG
6#-%&evalfG6$*&%#PiGF1)F0,&9$F1F1!\"\"F1,&F " 0 ""
{MPLTEXT 1 0 13 "evalf(Pi,14);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"/
)*e`EfTJ!#8" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "for i from 1
to 12 do\npidigits(i); od;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"\"
" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"%" }}{PARA 11 "" 1 ""
{XPPMATH 20 "6#\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"&" }}
{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"*" }}{PARA 11 "" 1 "" {XPPMATH 20
"6#\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"'" }}{PARA 11 "" 1 ""
{XPPMATH 20 "6#\"\"&" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}
{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"&" }}{PARA 11 "" 1 "" {XPPMATH 20
"6#\"\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"*" }}}{EXCHG {PARA 0 "
> " 0 "" {MPLTEXT 1 0 13 "pidigits(11);" }}{PARA 11 "" 1 "" {XPPMATH
20 "6#\"\"*" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 116 "But this is incor
rect! It should be 8, but roundoff error in this case (89 goes to 90) \+
affected the last two digits:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1
0 27 "evalf(Pi,14);\nevalf(Pi,13);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#
$\"/)*e`EfTJ!#8" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\".!f`EfTJ!#7" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "evalf(%*10^10,13);" }}{PARA
11 "" 1 "" {XPPMATH 20 "6#$\".!f`EfTJ!\"#" }}}{EXCHG {PARA 0 "> " 0 "
" {MPLTEXT 1 0 8 "frac(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"#!*!
\"#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "%*10;" }}{PARA 11 ""
1 "" {XPPMATH 20 "6#$\"$+*!\"#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 9 "floor(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"*" }}}{EXCHG
{PARA 0 "" 0 "" {TEXT -1 352 "We can compensate by increasing the numb
er of digits carried by evalf, but then we would need to analyze wheth
er this will work for every case, in other words, we must be sure of h
ow many digits roundoff error can effect and then include a little rou
tine to take care of this if necessary. For now we just use our existi
ng procedure with an extra digit" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 103 "pidigits:=proc(n::integer)\n floor(frac(\n \+
evalf(Pi*10^(n-1),n+3)\n )*10) end;" }}{PARA 11 ""
1 "" {XPPMATH 20 "6#>%)pidigitsGf*6#'%\"nG%(integerG6\"F*F*-%&floorG6#
,$*&\"#5\"\"\"-%%fracG6#-%&evalfG6$*&%#PiGF1)F0,&9$F1F1!\"\"F1,&F " 0 "" {MPLTEXT 1 0 13 "pidigits
(11);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\")" }}}{EXCHG {PARA 0 ""
0 "" {TEXT -1 24 "The thousandth digit of " }{XPPEDIT 18 0 "pi;" "6#%#
piG" }{TEXT -1 8 " is then" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
15 "pidigits(1000);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"*" }}}
{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "and it is right. But our procedure
still requires some more thought." }}}}}{MARK "0 0 0" 22 }{VIEWOPTS
1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }