Question: = 4 4/3 + 4/5 4/7 + 4/9 Write a MATLAB program with a for loop to compute (and display) an approximation A of using
= 4 4/3 + 4/5 4/7 + 4/9 Write a MATLAB program with a for loop to compute (and display) an approximation A of using a truncation of the given sum. Your program should allow the user to enter the number of terms (denoted by nterms, say) to be used for the approximation. Also in the program, compute (and display) the absolute error E = |A | (using the MATLAB function abs for the absolute value). *For this particular question the code what i have written isnt working, could you help me? could you help me to fix the error clear format long nterms=input('Enter the number of terms used for the approximation of pi:'); A=4; disp(' Approximation(A) Absolute Error (E)') n=2 If(n>=2 < nterms) A = A +(-1)^(n-1)*(4/(2*n-1)); Else E =abs (A - pi); disp([A E]) end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
