<?xml version="1.0" encoding="UTF-8"?>
<Worksheet><Version major="6" minor="1"/><View-Properties><Zoom percentage="100"/></View-Properties><Styles><Layout alignment="left" name="Input"/><Layout alignment="left" name="Text"/><Layout alignment="left" bullet="none" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="Normal" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="left" name="Section" spaceabove="16.0" spacebelow="9.0"/><Layout alignment="left" name="Title"/><Layout alignment="left" name="Subsection" spaceabove="13.0" spacebelow="7.0"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="Maple Input" opaque="false" size="12"/><Font background="[0,0,0]" family="Times New Roman" name="Text" size="12"/><Font background="[0,0,0]" bold="true" family="Arial" name="Section" size="16"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="Input" size="12"/><Font background="[0,0,0]" family="Arial" name="Title" size="36"/><Font background="[0,0,0]" bold="true" family="Arial" name="Subsection" size="14"/></Styles><Group><Text-field layout="Title" style="Title">Chapter 6</Text-field></Group><Text-field spacebelow="1.0"><Font background="[0,0,0]" family="Times New Roman" size="9"> </Font></Text-field><Section><Title><Text-field layout="Section" style="Section">Maple code for exercises in section 6.1</Text-field></Title><Section><Title><Text-field layout="Subsection" style="Subsection">8.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">a := k -&gt; piecewise(k=0,1/2*int(x^2,x = -1 .. 1),<Font opaque="false">int(x^2*cos(k*Pi*x),x = -1 .. 1));</Font></Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">b := k -&gt; int(x^2*sin(k*Pi*x),x = -1 .. 1) ;</Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">11.</Text-field></Title><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">riemann := proc(x)</Text-field></Input><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">local pos::list, neg::list, negi, posi, i, l::list, sum, summands::list, j, posl::list, negl::list; negi := 1; posi := 1; posl := []; negl := []; i := 1; sum := 0; pos := []; neg := []; summands := []; l := [];</Text-field></Input><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">summands := [seq((-1)^(j-1)*cos((2*j-1)*x)/(2*j-1),j=1..100)];</Text-field></Input><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">for j from 1 to 100 do if op(j,summands) &gt;= 0 then pos := [op(pos),op(j,summands)]; posl := [op(posl),j]; else neg := [op(neg),op(j,summands)]; negl := [op(negl),j] end if; end do;</Text-field></Input><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">while i &lt;= 20 do while sum &lt; 1 do sum := sum + op(posi,pos); l := [op(l),op(posi,posl)]; posi := posi + 1; i := i + 1; end do; while sum &gt;= 1 do sum := sum + op(negi,neg); l := [op(l),op(negi,negl)]; negi := negi + 1; i := i + 1; end do; end do; print(l); print(sum);
end proc;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">riemann(.5);</Text-field></Input></Group><Group><Text-field layout="Text" style="Text">The list shows the order in which the summands have been rearranged. thus, with <Font italic="true">x</Font><Font italic="false"> = 0.5, we take the first summand, then the fourth, then the second, then the seventh, and so on.</Font></Text-field></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">13.</Text-field></Title><Group><Text-field layout="Text" style="Text">The following command will calculate a numerical approximation to the value of the integral:</Text-field></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">F := n -&gt; evalf(evalf(int(sin((2*n+1)*u)*sqrt(9+2*u)/sin(u),u = 0 .. 1/2*Pi))/Pi) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plots[listplot]([seq([5*n, F(5*n)],n = 1 .. 30)],style = POINT,symbol = POINT,view = 1.5 .. 1.51);</Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">17.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">a := k -&gt; piecewise(k=0, <Font opaque="false">1/2*int(2*x+1,x = -Pi .. 0)/Pi+int(1/3*x-2/3,x = 0 .. Pi)/Pi,</Font> int((2*x+1)*cos(k*x),x = -Pi .. 0)/Pi+int(1/3*(x-2)*cos(k*x),x = 0 .. Pi)/Pi);
b := k -&gt; int((2*x+1)*sin(k*x),x = -Pi .. 0)/Pi+int(1/3*(x-2)*sin(k*x),x = 0 .. Pi)/Pi ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">[a(k), b(k)];</Text-field></Input></Group><Group><Text-field layout="Text" style="Text">Simplify Mathematica's answer by using your knowledge that k is an integer and therefore sin(k Pi) = 0 and cos( k Pi) = (-1)^k.</Text-field></Group></Section></Section><Section><Title><Text-field layout="Section" style="Section">Maple code for exercises in section 6.2</Text-field></Title><Section><Title><Text-field layout="Subsection" style="Subsection">1.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">S1 := n -&gt; sum(j^3/n^4-2*j^2/n^3+j/n^2,j = 0 .. n-1) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">evalf(seq([n, S1(n)], n=1..20),10);</Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">2.</Text-field></Title><Group><Text-field layout="Text" style="Text">In the argument of ApproxS, enter the list of points in the partition in increasing order, starting with 0 and ending with 1.</Text-field></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">ApproxS := proc (P::list) local j ; sum((op(j,P)^3-2*<Font opaque="false">op(j,P)</Font>^2+<Font opaque="false">op(j,P)</Font>)*(<Font opaque="false">op(j+1,P)</Font>-<Font opaque="false">op(j,P)</Font>),j = 1 .. nops(P)-1) end proc;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">ApproxS([0, .25, .5, .75, 1]);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">ApproxS([0, .1, .35, .6, .85, 1]);</Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">3.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">S2 := n -&gt; sum(sin(n/j)/n,j = 1 .. n-1) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input"><Font opaque="false">evalf(seq([5*n, S2(5*n)], n=1..20),10);</Font></Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">5.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">int(cos(100*Pi*x)^2,x = 0 .. 1);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">S3 := n -&gt; sum(cos(100*Pi*j/n)^2/n,j = 0 .. n-1) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input"><Font opaque="false">evalf(seq([n, S3(n)], n=1..30),10);</Font></Text-field></Input></Group></Section></Section><Section><Title><Text-field layout="Section" style="Section">Maple code for exercises in section 6.3</Text-field></Title><Section><Title><Text-field layout="Subsection" style="Subsection">15.</Text-field></Title><Group><Text-field layout="Text" style="Text">The first command defines the numerator function ((x)).</Text-field></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">num := x -&gt; piecewise(x &lt; floor(x)+1/2,x-floor(x),x = floor(x)+1/2,0,floor(x)+1/2 &lt; x,x-floor(x)-1);</Text-field></Input></Group><Group><Text-field layout="Text" style="Text">This next command simply looks at the plot of this function.</Text-field></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(num(x),x = -4 .. 4);</Text-field></Input></Group><Group><Text-field layout="Text" style="Text">The command points[n] generates a table of the approximations to f(x) at the values x = j/1000, j = 1, 2, ..., 1000, using a summation with n summands (and thus an error that is bounded by 1/2n).</Text-field></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">points := n -&gt; [seq([1/1000*j, sum(num(1/1000*k*j)/k^2,k = 1 .. n)],j = 1 .. 1000)] ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plots[listplot](points(10),style = POINT,symbol = POINT);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plots[listplot](points(100),style = POINT,symbol = POINT);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plots[listplot](points(1000),style = POINT,symbol = POINT);</Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">19.</Text-field></Title><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">fun := (k,d)-&gt; piecewise( k mod d = 0, (-1)^d*d , 0 ) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">psi := k -&gt; sum(fun(k,d),d = 1 .. k) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">seq([k, psi(k)], k=1..100);</Text-field></Input></Group></Section></Section><Section><Title><Text-field layout="Section" style="Section">Maple code for exercises in section 6.4</Text-field></Title><Section><Title><Text-field layout="Subsection" style="Subsection">2.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">distance := x -&gt; piecewise(x &lt;= floor(x)+1/2,x-floor(x),floor(x)+1/2 &lt; x,floor(x)+1-x) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(distance(x),x = -2 .. 2);</Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">3.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plotF := n -&gt; plot(distance(4^n*x)/(4^n),x = -4^(1-n) .. 4^(1-n)) ;</Text-field></Input></Group><Group><Text-field layout="Text" style="Text">Notice what happens to the scale on both the x- and y-axes.</Text-field></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plotF(2);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plotF(3);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plotF(4);</Text-field></Input></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">4.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">S4 := (n, x) -&gt; sum(distance(4^k*x)/(4^k),k = 0 .. n) ;</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(S4(2,x),x = -2 .. 2);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(S4(3,x),x = -2 .. 2);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(S4(4,x),x = -2 .. 2);</Text-field></Input></Group><Group><Text-field layout="Text" style="Text">Why don't these look any differrent?</Text-field></Group></Section><Section><Title><Text-field layout="Subsection" style="Subsection">11.</Text-field></Title><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">S5 := (n, x) -&gt; sum((6/7)^k*cos(7^n*Pi*x),k = 0 .. n) ;</Text-field></Input></Group><Group><Text-field layout="Text" style="Text">Notice what happens to the scale on both the x- and y-axes.</Text-field></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(S5(1,x),x = -1 .. 1);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(S5(2,x),x = -1/7 .. 1/7);</Text-field></Input></Group><Group><Input><Text-field layout="Input" prompt="&gt; " style="Input">plot(S5(3,x),x = -1/49 .. 1/49);</Text-field></Input></Group></Section></Section><Text-field/><Text-field/><Text-field/><Text-field/></Worksheet>
