Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

sum function: The infinite series 2n-l n2-12-T 22 32 has been shown to converge

ID: 3348479 • Letter: S

Question

sum function: The infinite series 2n-l n2-12-T 22 32 has been shown to converge to t 6. Since each new term that gets added to the partial sum gets progressively smaller, we don't need to add together an infinite number of terms to see that the solution approaches / 6 Calculate the series summation for n = 100. To do this, create a vector n of the numbers 1 to 100. Then calculate the individual terms in the series using an (1/n2). Finally, use the sum function to then add the individual an terms together. Repeat the problem for n 1,000 and n-10,000. You should notice that as the number of terms included in the sum increases, so too does the sum become closer to the convergence point. Compare your results to the true value of ? 6. Create logic variable, close_enough, that returns true if the absolute difference between your summation and n / 6 is less than o.0001. (If you did it right, close_ enough should return false for n-100 and 1,000 but true for 10,000.)

Explanation / Answer

MATLAB Code:

%%%function [y, close_enough] = sumSeries(N)
%Input: N = Length of the series
%
%Output: y = Summation of the series 1/n^2
% close_enough = logical check for absolute difference
% between the summation and
% convergence point pi^2/6
%
function [y, close_enough] = sumSeries(N)
n = 1:1:N; % Vector n of length N
an = 1./n.^2; % Elements of the series
y = sum(an); % Summation of the series
true = (pi^2)/6; % Convergence point of the series
close_enough = logical(abs(y - true) < 0.0001);
end

RESULT:

>> [y, close_enough] = sumSeries(100)

y =

1.6350


close_enough =

0

>>

>> [y, close_enough] = sumSeries(1000)

y =

1.6439


close_enough =

0

>> [y, close_enough] = sumSeries(10000)

y =

1.6448


close_enough =

1

>>