Question: Programming Language: MATLAB From problem 1 in order to do Problem 2 Write a function with the header: function [piEstimate, piError] = myForPi(nIterations) which uses

Programming Language: MATLAB

From problem 1 in order to do Problem 2

Write a function with the header:

 function [piEstimate, piError] = myForPi(nIterations) 

which uses a for-loop and the Archimedes method below to estimate the value of pi (you must use this approach).

1. LetA=1andN=6 2. RepeatthefollowingnIterationstimes

Replace N by 2N

Replace A by [2 sqrt(4 A^2) ]^(1/2)

Let L = NA/2

Let U = L/sqrt(1 A^2/2)

Let piEstimate = (U + L)/2

Let piError = (U-L)/2

3. Return

Programming Language: MATLAB From problem 1 in order to do Problem 2

Problem 2: (5 Points) Redo Problem 1 with a while-loop with the header function [piEstimate, nlterations] = myWhilePi(tol) which takes a user-specified tolerance (tol) and uses a while loop with the Archimedes algorithm to iterate until the estimate of pi converges to within tol. Test Functions: >> [piEst, nlter) = myWhilePi ( . 1) piEst = 3.160015969288298 n1ter = 3 nlter) = myWhilePi (.01) >> [piEst, piEst = 3.146107988481835 nIter- >> [piEst, nlter] = myWhilePi ( .0001) piEst = 3.141610176935181

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!