Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

List six general techniques that are effective in persuasion.

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago