Use MATLAB to show that the sum of the infinite series below approaches with inc
ID: 3742728 • Letter: U
Question
Use MATLAB to show that the sum of the infinite series below approaches with increasing values of n.
N = 100
N = 10,000
N = 1,000,000
Compare each of the values obtained in parts a, b and c with the value of . Remember, this assignment is “Array Arithmetic & Functions”. Therefore, this problem should exercise use of “Array Arithmetic & Functions”. So, using your “Array Arithmetic & Functions” skills, in your head, conceptually outline the steps required to solve this problem. After you’ve outlined steps, mentally compare your steps with the suggested steps below (see bottom of page). DO NOT USE FOR LOOPS OR SIMILAR CODE STRUCTURES!
Create a vector n (“array creation”)
Calculate (each term of the infinite series) using n (“array arithmetic”)
Combine the terms of the series (“using arrays with functions”). (Use MATLAB’s built-in sum function)
Use the variable names prob4a, prob4b, and prob4c for the sums.
Explanation / Answer
Script:
clear;
clc;
% 1. create a vector n
n=0:1000000;
% 2. calculate each term
terms=4*((-1).^n./(2*n+1));
% 3. summing ans assign to variables
prob4a=sum(terms(1:100)); % first 100 terms
prob4b=sum(terms(1:10000)); % first 10000 terms
prob4c=sum(terms(1:1000000)); % first 1000000 terms
% display each sum
disp(prob4a);
disp(prob4b);
disp(prob4c);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.