Answered step by step
Verified Expert Solution
Question
1 Approved Answer
= 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started