Use Matlab to show that the sum below converges to 3, i.e. lim_k rightarrow infi
ID: 3406500 • Letter: U
Question
Use Matlab to show that the sum below converges to 3, i.e. lim_k rightarrow infinity = 3: sigma^infinity_k = 0 (2/3)^k = (2/3)^0 + (2/3)^1 + (2/3)^2 + ... Show this by computing the values of the partial sums S_n = sigma^infinity_n = 0 (2/3)^k, where n = 10, 20, 30. You may choose one of two different ways to calculate the partial sums: Vectorizer. Define a vector with first element 0 that increments by 1 up to 10 (and 20 and 30) and use element-by-element calculations to determine the sum. You may want to consider the built-in function cumdump. Loop. Obtain the partial sums using a for loop. Note that the infinite sum begins at n = 0 but for loops cannot begin incrementing with 0, therefore you would need to initialize the loop with the value (2/3)degree.Explanation / Answer
% MATLAB script starts here
n_1 = 10;
sum_1 = 0;
for ii = 1:n_1+1
sum_1 = sum_1+(2/3)^(ii-1);
end
n_2 = 20;
sum_2 = 0;
for ii = 1:n_2+1
sum_2 = sum_2 + (2/3)^(ii-1);
end
n_3 = 20;
sum_3 = 0;
for ii = 1:n_3+1
sum_3 = sum_3 + (2/3)^(ii-1);
end
sprintf('For n = %d sum is %f', n_1,sum_1)
sprintf('For n = %d sum is %f', n_2,sum_2)
sprintf('For n = %d sum is %f', n_3,sum_3)
% MATLAB script ends here
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.