The Maple notebook is chapter4.mw but you are warned that it may download as a text file.

Chapter 4

Mathematica code for exercises in section 4.1

4.

The first command defines Sum1[n] as the sum of the first n terms of the series. The second command generates a table of the values of the partial sums as n increases from 10 to 400 in multiples of 10.

 > Sum1 := n -> evalf(1 + sum(k!/100^k, k = 1..n - 1), 10);

 > seq([10*n, Sum1(10*n)], n=1..40);

5.

First think about how you can use Stirling's formula to identify where this smallest summand is likely to occur. The follwing command finds all values of k!/100^k for a <= k <= b.

 > TestSummand := (a,b) -> seq([k, evalf(k!/100^k, 20)], k=a..b);

 > TestSummand(10,20);

8.

After finding your candidate, you can test it with the command

 > TestBernoulliSummand := (a,b) ->  seq([k, evalf(abs(bernoulli(2*k)/((2*k - 1)*(2*k)*10^(2*k - 1))), 20)], k=a..b);

 > TestBernoulliSummand(10,20);

13.

The first command defines Sum2[n] as the sum of the first n terms of the series. The second command generates a table of the values of the partial sums as n increases from 1000 to 2000 in multiples of 100.

 > Sum2 := n ->  evalf(sum(sin(k/100)/ln(k), k=2..n + 1), 10);

 > seq([100*n, Sum2(100*n)], n=10..20);

14.

 > Sum3 := n -> evalf(sum((-1)^k/ln(k),k = 2 .. n+1), 10);

 > seq([100*n, Sum3(100*n)], n=10..20);

 > Sum4 := n ->  evalf(sum((-1)^k*ln(k)^2/k,k = 2 .. n+1), 10);

 > seq([100*n, Sum4(100*n)], n=10..20);

 > Sum5 :=  evalf(sum((-1)^k*sin(1/k), k = 2 .. n+1), 10);

 > seq([100*n, Sum5(100*n)], n=10..20);

 > Sum6 := n -> evalf(sum((-1)^k*ln(k)^ln(k)/k^2, k = 2 .. n+1), 10);

 > seq([100*n, Sum6(100*n)], n=10..20);

15.

 > Sum7 := n -> evalf(sum((-1)^(k + 1 - 3*floor((k + 1)/3))/k, k=1..n), 10);

 > seq([100*n, Sum7(100*n)], n=10..20);

 > Sum8 := n ->  evalf(sum((-1)^floor(1/2*k-1/2)/k, k = 1 .. n), 10);

 > seq([100*n, Sum8(100*n)], n=10..20);

 > Sum9 := n -> evalf(sum((-1)^floor(k^(1/2))/k, k = 1 .. n), 10);

 > seq([100*n, Sum9(100*n)], n=10..20);

Mathematica code for exercises in section 4.2

15.

 > Sum10 := n -> evalf(sum((k/(2*k-1))^k,k = 1 .. n), 20);

 > seq([20*n, Sum10(20*n)], n=1..10);

16.

 > Sum11 := n -> evalf(sum((k/(2*k-1))^k*2^k,k = 1 .. n), 20); Sum12 := n -> evalf(sum((k/(2*k-1))^k*(-2)^k,k = 1 .. n), 20);

 > seq([20*n, Sum11(20*n), Sum12(20*n)], n=1..10);

17.

 > Sum13 := n -> evalf(sum(k^k/k!,k = 1 .. n), 10);

 > seq([20*n, Sum13(20*n)], n=1..10);

18.

 > Sum14 := n -> evalf(sum(k^k*exp(-k)/k!,k = 1 .. n), 20); Sum15 := n -> evalf(sum(k^k*(-exp(1))^(-k)/k!,k = 1 .. n), 20);

 > seq([20*n, Sum14(20*n), Sum15(20*n)], n=1..15);

19.

 > Sum16 := n -> evalf(sum(2^k/k^(1/2), k = 1 .. n), 10);

 > seq([20*n, Sum16(20*n)], n=1..10);

20.

 > Sum17 := n -> evalf(sum(1/k/ln(k),k = 2 .. n), 20);

 > seq([1000*n, Sum17(1000*n)], n=1..10);

21.

 > Sum18 := n -> evalf(sum(1/k/ln(k)^(3/2),k = 2 .. n), 20);

 > seq([1000*n, Sum18(1000*n)], n=1..10);

22.

sum(1/k/ln(k)/ln(ln(k)),k = 10 .. n)

 > Sum19 := n -> evalf(sum(1/k/ln(k)/ln(ln(k)),k = 10 .. n), 20);

 > seq([1000*n, Sum19(1000*n)], n=1..10);

Mathematica code for exercises in section 4.3

6.

sum((k/(2*k-1))^k*x^k,k = 1 .. n)

 > FSum1 := (n,x) -> sum((k/(2*k-1))^k*x^k,k = 1 .. n);

 > plots[display](plot(FSum1(3,x),x = -2.1 .. 2.1),plot(FSum1(6,x),x = -2.1 .. 2.1),plot(FSum1(9,x),x = -2.1 .. 2.1),plot(FSum1(12,x),x = -2.1 .. 2.1));

8.

 > FSum2 := (n,x) -> sum(k^k/k!*x^k, k=1..n);

 > plots[display](plot(FSum2(3,x),x = -.7 .. .7),plot(FSum2(6,x),x = -.7 .. .7),plot(FSum2(9,x),x = -.7 .. .7),plot(FSum2(12,x),x = -.7 .. .7));

10.

 > FSum3 := (n,x) -> sum(2^k/Sqrt[k]*x^k, k=1..n);

 > plots[display](plot(FSum3(3,x),x = -.7 .. .7),plot(FSum3(6,x),x = -.7 .. .7),plot(FSum3(9,x),x = -.7 .. .7),plot(FSum3(12,x),x = -.7 .. .7));

11.

These summands can be simplified by realizing that product(2*i,i=1..n)/product(2*i+1,i=1..n) = 4^n (n!)^2\/(2*n + 1)!

 > FSum4 := (n,x) -> sum(4^k*k!^2*x^k/(2*k+1)!,k = 1 .. n);

 > plots[display](plot(FSum4(3,x),x = -.7 .. .7),plot(FSum4(6,x),x = -.7 .. .7),plot(FSum4(9,x),x = -.7 .. .7),plot(FSum4(12,x),x = -.7 .. .7));

14.

 > FSum5 := (n,x) -> sum(2^k*k!*k^k*x^k/(2*k)!,k = 1 .. n);

 > plots[display](plot(FSum5(3,x),x = -2 .. 2),plot(FSum5(6,x),x = -2 .. 2),plot(FSum5(9,x),x = -2 .. 2),plot(FSum5(12,x),x = -2 .. 2));

15.

 > FSum6 := (n,x) -> sum(x^k/k^2,k = 1.. n);

 > plots[display](plot(FSum6(3,x),x = -1.1 .. 1.1),plot(FSum6(6,x),x = -1.1 .. 1.1),plot(FSum6(9,x),x = -1.1 .. 1.1),plot(FSum6(12,x),x = -1.1 .. 1.1));

 > FSum7 := (n,x) -> 1+sum((2*k)!*x^k/k!^2,k = 1 .. n);

 > plots[display](plot(FSum7(3,x),x = -.4 .. .4),plot(FSum7(6,x),x = -.4 .. .4),plot(FSum7(9,x),x = -.4 .. .4),plot(FSum7(12,x),x = -.4 .. .4));

 > FSum8 := (n,x) -> 1+sum(k!^3*x^k/(3*k)!,k = 1 .. n);

 > plots[display](plot(FSum8(3,x),x = -30 .. 30),plot(FSum8(6,x),x = -30 .. 30),plot(FSum8(9,x),x = -30 .. 30),plot(FSum8(12,x),x = -30 .. 30));

 > FSum9 := (n,x) -> 1+sum((2*k+1)!*x^k/(2^k)/k!^2,k = 1 .. n);

 > plots[display](plot(FSum9(3,x),x = -.7 .. .7),plot(FSum9(6,x),x = -.7 .. .7),plot(FSum9(9,x),x = -.7 .. .7),plot(FSum9(12,x),x = -.7 .. .7));

 > FSum10 := (n,x) -> sum(product(i^2-1,i = 2 .. k)*x^k/product(i^2,i = 2 .. k),k = 2 .. n);

 > plots[display](plot(FSum10(3,x),x = -1.2 .. 1.2),plot(FSum10(6,x),x = -1.2 .. 1.2),plot(FSum10(9,x),x = -1.2 .. 1.2),plot(FSum10(12,x),x = -1.2 .. 1.2));

 > FSum11 := (n,x) -> 1+sum((2*k)!^2*x^k/(4^k)/k!^4,k = 1 .. n);

 > plots[display](plot(FSum11(3,x),x = -.3 .. .3),plot(FSum11(6,x),x = -.3 .. .3),plot(FSum11(9,x),x = -.3 .. .3),plot(FSum11(12,x),x = -.3 .. .3));

 > FSum12 := (n,x) -> 1+sum((3*k)!*x^k/k!/(2*k)!,k = 1 .. n);

 > plots[display](plot(FSum12(3,x),x = -.2 .. .2),plot(FSum12(6,x),x = -.2 .. .2),plot(FSum12(9,x),x = -.2 .. .2),plot(FSum12(12,x),x = -.2 .. .2));

27.

 > HyperSum1 := (n,m) -> evalf(sum((product(3*i-1,i = 1 .. k)/product(3*i,i = 1 .. k))^m,k = 1 .. n), 10);

 > seq([100*n, HyperSum1(100*n, 1)], n=1..10);

 > seq([100*n, HyperSum1(100*n, 2)], n=1..10);

 > seq([100*n, HyperSum1(100*n, 3)], n=1..10);

 > seq([100*n, HyperSum1(100*n, 4)], n=1..10);

28.

 > HyperSum2 := (n,m) -> evalf(sum((product(3*i-2,i = 1 .. k)/product(3*i,i = 1 .. k))^m,k = 1 .. n), 10);

 > seq([100*n, HyperSum2(100*n, 1)], n=1..10);

 > seq([100*n, HyperSum2(100*n, 2)], n=1..10);

 > seq([100*n, HyperSum2(100*n, 3)], n=1..10);

 > seq([100*n, HyperSum2(100*n, 4)], n=1..10);

Mathematica code for exercises in section 4.4

1.

 > FSum13 := (n,x) -> evalf(sum((-1)^(k-1)*cos(1/2*(2*k-1)*Pi*x),k = 1 .. n),10);

The first command plots the partial sums; the second lists them.

 > plots[listplot]([seq([n, FSum13(n,1/2)],n = 1 .. 20)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum13(n, 1/2)], n=1..20);

 > plots[listplot]([seq([n, FSum13(n,2/3)],n = 1 .. 20)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum13(n, 2/3)], n=1..20);

 > plots[listplot]([seq([n, FSum13(n,3/5)],n = 1 .. 20)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum13(n, 3/5)], n=1..20);

 > plots[listplot]([seq([n, FSum13(n,5/18)],n = 1 .. 20)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum13(n, 5/18)], n=1..20);

3.

 > FSum14 := (n,x) -> evalf(sum((-1)^(k-1)*cos(1/2*(2*k-1)*Pi*x)/(2*k-1),k = 1 .. n), 10);

The first command plots the partial sums for 1 <= n <= 200; the second lists the last 20 values.

 > plots[listplot]([seq([n, FSum14(n,1/2)],n = 1 .. 200)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum14(n, 1/2)], n=181..202);

 > plots[listplot]([seq([n, FSum14(n,2/3)],n = 1 .. 200)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum14(n, 2/3)], n=181..202);

 > plots[listplot]([seq([n, FSum14(n,9/10)],n = 1 .. 200)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum14(n, 9/10)], n=181..202);

 > plots[listplot]([seq([n, FSum14(n,99/100)],n = 1 .. 200)],style = POINT,symbol = CIRCLE);

 > seq([n, FSum14(n, 99/100)], n=181..202);

6.

 > FSum15 := (n,x) -> sum((-1)^(k-1)*sin(1/2*(2*k-1)*Pi*x)/(2*k-1),k = 1 .. n);

 > plots[display](plot(FSum15(3,x),x = -2 .. 2),plot(FSum15(6,x),x = -2 .. 2),plot(FSum15(9,x),x = -2 .. 2),plot(FSum15(12,x),x = -2 .. 2));

7.

 > FSum16 := (n,x) -> sin(x)*(1-cos(n*x))/(2-2*cos(x))+1/2*sin(n*x);

 > plots[display](plot(FSum16(10,x),x = -Pi .. Pi,view = 0 .. 20),plot(FSum16(20,x),x = -Pi .. Pi,view = 0 .. 20),plot(FSum16(100,x),x = -Pi .. Pi,view = 0 .. 20),plot(FSum16(1000,x),x = -Pi .. Pi,view = 0 .. 20));

11.

 > FSum17 := (n,x) -> sum((-1)^(k-1)*sin(1/2*k*Pi*x)/k,k = 1 .. n);

 > plots[display](plot(FSum17(3,x),x = -2 .. 2),plot(FSum17(6,x),x = -2 .. 2),plot(FSum17(9,x),x = -2 .. 2),plot(FSum17(12,x),x = -2 .. 2));