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

Ctr NAME: PERSON #: LAB Consider the following infinite sum: 8 (4n + 1)(4m + 3)

ID: 3712313 • Letter: C

Question

Ctr NAME: PERSON #: LAB Consider the following infinite sum: 8 (4n + 1)(4m + 3) Write a MATLAB script which computes the partial sum: NE The value of ? can be computed as 8SN. You may assume that the MATLAB variable pi is the exact value of Ir and you can determine the error in your computed value as the absolute difference in between your calculated ? and that of the MATLAB vari u need to create a vector tol = 10-1, 10-2, 10-3-10-7. 10-8 and use a for loop to access each element in this vector. The value of t as 8Sy can be determine with a while loop that continues as long as the error is less than the tolerance tol. Create a counter to determine the number of iterations (the number of passes) required to reach each tolerance and store it as an element of a vector N. Plot the number of terms N (same as the number of iterations) as a function of the tolerance. You must use logarithmic scale for both vertical AND horizontal axes. You must use a solid black line in the plot. You must label the axes: x-axis with "Tolerance/Error" and y-axis with "Number of Terms Required". Use good programming practices and smart indent your script to get full credit.

Explanation / Answer

n=[0:1:100]

tol=[0.1, 0.01, 0.001, 0.0001,0.00001, 0.000001, 0.0000001, 0.00000001]

for i= 1:n

a=(4*i)+1

b=(4*i)+3

S=(a*b)

Sn=(1/S) \ Sn is calculated

e= pi- (8*Sn) \calculate the numbers of errors

for k=1:8 \ as the toi has 8 elements so loop compares all the elements with this

while e< tol(k)

count= count + 1

end

end

N(i)= count

end

plot(tol, N);

xlabel("Tolerance/ error");

ylabel("Number of Terms required");

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote