Answered step by step
Verified Expert Solution
Question
1 Approved Answer
s Write a MATLAB program to approximate the infinite series n=1 (-1)-1 The computed approximation should be accurate to less equal to 10 decimal places
s
Write a MATLAB program to approximate the infinite series n=1 (-1)-1 The computed approximation should be accurate to less equal to 10 decimal places (i.e., the absolute value of nin+1) the sum result of current kth iteration subtract from the sum result of the previous (k-1)th iteration is less equal to 0.01). The program should display the approximation of the series and the error bound. An alternating series that converges has an error bound equal to the magnitude of the next term in the series, for example if was approximated (-1)-1 nin+1) using N = 3, (-1)-*, the error bound is (-1)" with n = 4, nin+1) . This problem should be solved using a while loop that terminates when the error bound is smaller than the Inn + 1) 4(4+1) desired accuracy. Can we solve this problem using element-by-element vector operation without using a loop (you do not implement it here, just think about it)? (134 | = 0. Assign your approximated sum, the error bound, and the number of iterations required to achieve the goal to variable names approx, errBound, and numOflterations respecitively. hint: 1. You should continute calculate the summation until the absolute value of the substraction result of the sum of current kth iteration and the sum of the previous (k-1)th iteration, i.e., abs(sum_c-sum_p), is less equal to 0.01. Assign your summation to approx. 2. At this time, the absolute value of the (k+1)th term in your infinite series is your erro bound and k is the number of iterations required to achieve the goal. Assign the results to errBound and numOfiterations respectively. 3. For you to check the correctness of your code on your own MATLAB installation, you can use the 0.001 as accuracy. Your three results should be: errBound = 8.9127e-04, numofiterations = 32, and approx = -0.3858 To pass the tests for the MATLAB grader, we will use 0.01 as your accuracy, not 0.001. 1 % Use 0.01 for MATLAB grader test 2% Calculate the required results using while loop. 3%Assign your final approximated sun, the error bound, and the number of iterations required to achieve the goal to variable names 4 approx=0; 5 errBound=0; 6 numofiterations=0 approx, errBound, 7 8 end Is approximation approx correct? Is error bound errBound correct? Is number of iteration needed numOfiterations correct? Is while loop used to calculate the resultStep 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