Chapter 2<Text-field layout="Section" style="Section">Maple code for exercises in section 2.1</Text-field><Text-field layout="Subsection" style="Subsection">7.</Text-field>The following Maple command allows you to explore the values of the alternating harmonic series when you rearrange summands. It takes three arguments: n, r, and s, which must be positive integers. It returns a decmial approximation to the partial sum of the first n(r+s) terms of the rearranged series that alternates the next r positive summands followed by the next s negative summands.Rearrange := (n, r, s) -> sum(1/(2*k-1),k = 1 .. n*r)-sum(1/2/k,k = 1 .. n*s);To get the desired accuracy, you need to set the number of digits to at least 20. For example, in part (b) where you are asked to evaluate the partial sums of the rearranged series that alternate two positive tersm followed by a single negative term, the following command evaluates the partial sum of the first 300 terms with 20-digit accuracy.evalf(Rearrange(100,2,1),20);The exponential function can be evaluated either using E^.. or the function Exp[..].evalf(exp(2*Rearrange(1000000,2,1)),20);<Text-field layout="Subsection" style="Subsection">8.</Text-field>The following Maple command allows you to explore the values of the alternating sum of reciprocals of perfect squares when you rearrange summands. It takes three arguments: n, r,and s, which must be positive integers.It returns a decmial approximation to the partial sum of the first n(r+s) terms of the rearranged series that alternates the next r positive summands followed by the next s negative summands.Rearrange2 := (n, r, s) -> sum(1/(2*k-1)^2,k = 1 .. n*r)-sum(1/4/k^2,k = 1 .. n*s);<Text-field layout="Section" style="Section">Maple code for exercises in section 2.2</Text-field><Text-field layout="Subsection" style="Subsection">8.</Text-field>The following Maple command allows you to explore the values of the alternating geometric series of reciprocals of powers of 2 when you rearrange summands. It takes three arguments: n, r,and s, which must be positive integers.It returns a decmial approximation to the partial sum of the first n(r+s) terms of the rearranged series that alternates the next r positive summands followed by the next s negative summands.RearrangeGS := (n, r, s) -> sum(1/(2^(2*k-2)),k = 1 .. n*r)-sum(1/(2^(2*k-1)),k = 1 .. n*s);<Text-field layout="Subsection" style="Subsection">9.</Text-field>Try the commandint(x^n/(1-x),x);To find out what this answer means, you can query Maple:?LerchPhi<Text-field layout="Section" style="Section">Maple code for exercises in section 2.3</Text-field><Text-field layout="Subsection" style="Subsection">7.</Text-field>The sum of the first n terms of the power series for the arctangent function is given byArcTanPS := (n, x) -> sum((-1)^k*x^(2*k+1)/(2*k+1),k = 0 .. n-1);<Text-field layout="Subsection" style="Subsection">12.</Text-field>Partial sums of the binomial series for (1+x)^a can be calculated with the following Maple commandBinom := (a, n, x) -> 1+sum(binomial(a,m)*x^m,m = 1 .. n);map(Binom,[-2, -.4, 1/3, 3, 5.2],100,.5);<Text-field layout="Subsection" style="Subsection">13.</Text-field>f:=x->Binom(.5,100,x);map(f,[-2, -1, .9, .99, 1, 1.01, 1.1]);<Text-field layout="Subsection" style="Subsection">14.</Text-field>The following command plots each of the polynomial approximations against the graph of Sqrt[1+x] and then superimposes all of the graphs.plots[display](plot([sqrt(1+x), Binom(1/2,2,x)],x = -1 .. 2,view = 0 .. 2.5),plot([sqrt(1+x), Binom(1/2,5,x)],x = -1 .. 2,view = 0 .. 2.5),plot([sqrt(1+x), Binom(1/2,8,x)],x = -1 .. 2,view = 0 .. 2.5),plot([sqrt(1+x), Binom(1/2,11,x)],x = -1 .. 2,view = 0 .. 2.5));<Text-field layout="Section" style="Section">Maple code for exercises in section 2.4</Text-field><Text-field layout="Subsection" style="Subsection">4.</Text-field>Partial sums of the power series for ln(1+x) can be calculated with the following Maple commandLogSeries := (n, x) -> sum((-1.)^(k-1)*x^k/k,k = 1 .. n);g:= x -> LogSeries(100,x);map(g,[-.9, .9, .99, .999, 1, 1.001, 1.01, 1.1]);<Text-field layout="Subsection" style="Subsection">5.</Text-field>Partial sums of Gregory's series for ln(1+x) can be calculated with the following Maple commandGregory := (n, x) -> 2*sum((x/(x+2))^(2*k-1)/(2*k-1),k = 1 .. n);evalf(Gregory(10,4),10);evalf(Gregory(10,-4/5),10);evalf(ln(5),10);<Text-field layout="Subsection" style="Subsection">6.</Text-field>h:=x -> Gregory(100,x);evalf(map(h,[-.9, .9, 1, 1.1, 5, 20, 100]),20);<Text-field layout="Subsection" style="Subsection">7.</Text-field>The sum of the first thousand terms of this series can be calculated with the following Maple commandevalf(sum((-1)^(1/2*(k-1)*(k-2))/k,k = 1 .. 1000),20);<Text-field layout="Subsection" style="Subsection">9.</Text-field>The sum of the first thousand terms of the series for gamma can be calculated with the following Maple commandevalf(sum((-1)^k*Zeta(k)/k,k = 2 .. 1000),10);evalf(gamma,10);<Text-field layout="Subsection" style="Subsection">13.</Text-field>The sum of the first thousand terms of this series can be calculated with the following Maple commandevalf(sum(1/sqrt(k),k = 1 .. 1000),10);<Text-field layout="Subsection" style="Subsection">17.</Text-field>You can get one candidate for your answer by evaluatingevalf(floor(exp(100-gamma)),50);<Text-field layout="Section" style="Section">Maple code for exercises in section 2.5</Text-field><Text-field layout="Subsection" style="Subsection">1.</Text-field>The functions used in this exercise are tan(x), arctan(x), sec(x), ln(x), arcsec(x), and tanh(x). The command eval(diff(f(x),x$n),x=a), evaluates the nth derivative of f at x = 0. The next command creates a table of the values of the first through 10th deriviatives of tan(x) evaluated at x = 0.d := (n,f,a) -> eval(diff(f(x),x$n),x=a);map(d,[1,2,3,4,5,6,7,8,9,10],tan,0);<Text-field layout="Subsection" style="Subsection">2. </Text-field>The polynomial approximation to tan(x) using the first five non-zero terms isP5Tan := x -> x+2*x^3/3!+16*x^5/5!+272*x^7/7!+7936*x^9/9!;The following commmand plots both the tangent function and the polynomial approximation.plot([tan(x), P5Tan(x)],x = -1/2*Pi .. 1/2*Pi, y=-10..10);<Text-field layout="Subsection" style="Subsection">7.</Text-field>Partial sums of the binomial series for (1+x)^a can be calculated with the following Maple commandBinom := (a, n, x) -> 1+sum(binomial(a,m)*x^m,m = 1 .. n);The list of values of the partial sums can be generated with the following Table commandseq([100*n, Binom(-.5,100*n,200/199)],n = 1 .. 10);You can plot these values with the commandplots[listplot]([seq([100*n, Binom(-.5,100*n,200/199)],n = 1 .. 10)],style = POINT,symbol = CIRCLE);<Text-field layout="Subsection" style="Subsection">8.</Text-field>seq([100*n, Binom(-.5,100*n,1)],n = 1 .. 10);seq([100*n, Binom(-.5,100*n,-1)],n = 1 .. 10);<Text-field layout="Subsection" style="Subsection">12.</Text-field>Enter the definition of the following functionBinom := (a, n, x) -> 1+sum(binomial(a,m)*x^m,m = 1 .. n);The two values that you need to compare are[Binom(.5,299,200/199), evalf(sqrt(399/199))];Their difference isBinom(.5,299,200/199)-evalf(sqrt(399/199));The 300th derivative of sqrt(1+x) isdiff(sqrt(1+x),x$300);The error term given by Lagrange's remainder theorem isErrorBound := c ->abs( eval( diff( sqrt(1+x), x$300 ), x=c ) )*(200/199)^300 / 300!;plot(ErrorBound(c),c = 0 .. 200/199, y=0..0.00005);What is the value of c on the interval [0 , 200/199] that maximizes the error and what is the resulting bound on the error?<Text-field layout="Subsection" style="Subsection">16.</Text-field>Enter the definition of the following functionBinom := (a, n, x) -> 1+sum(binomial(a,m)*x^m,m = 1 .. n)Define a new error bound function for x = 1 that depends on the choice of a. Note that that the value of c that maximizes these errors is c = 0.ErrorBound := (a,n) -> abs( eval( diff( (1+x)^a, x$n ), x=0 ) )/ n!;map(ErrorBound,[-1, -.8, -.6, -.6, 0, .2, .4, .5],100);<Text-field layout="Subsection" style="Subsection">20.</Text-field>The following command plots the three functions. You should be able to determine which is which by their values at x = 0.plot([eval(diff(ln(1+y),y$7)/7!,y = 0), eval(diff(ln(1+y),y$7)/7!,y = x), ln(1+x)-x+1/2*x^2-1/3*x^3+1/4*x^4-1/5*x^5+1/6*x^6],x = 0 .. 1,color=[red,green,blue]);