Question: 4.1 The divide and average method, an old-time method for approximating the square root of any positive number a, can be formulated as x=2x+a/x Write

 4.1 The "divide and average" method, an old-time method for approximating
the square root of any positive number a, can be formulated as

4.1 The "divide and average" method, an old-time method for approximating the square root of any positive number a, can be formulated as x=2x+a/x Write a well-structured function to implement this algorithm based on the algorithm outlined in Fig. 4.2. function [fx, ea, iter ]=I termeth (x,es,maxit) 8. Maclaurin series of exponential function 8. [fx, ea, iter ]=I termeth (x,es, maxit ) 8 x= value at which series evaluated \& es = stopping criterion (default =0.0001 ) 8 input: \% maxit = maximum iterations (default =50 ) \% output: * fx= estimated value \% ea = approximate relative error (%) * iter = number of iterations if nargin=0.0001; end \% defaults: if nargin=1; sol =1; ea =100; \% iterative calculation while (1) solold = sol; sol = sol +x iter / factorial(iter); iter =i ter +1 ; if sol =0 ea =abs(( sol - solold )/ sol )100; end if eas=es || iter >= maxit, break, end end fx= sol end FIGURE 4.2 An M-file to solve an iterative calculation. This example is set up to e series expansion for ex as described in Example 4.1

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!