Question: X = The divide and average method, an old - time method for approximating the square root of any positive number a , can be
X The "divide and average" method, an oldtime method for approximating the square root of any positive number a can be formulated as x alx Write a wellstructured python function using the while loop structure to implement this algorithm. At each step estimate the approximate error in your approximation as hew xold xhew Repeat the loop until e is less than or equal to a specified error tolerance. Take x a as the initial value of x to start the while loop. Design your program so that it returns the result if a but shows an error message if a The function should be able to return when a The function should return the approximated root along with the number of iterations it takes to reach the solution and the approximate error. Test your program by evaluating a and for the error tolerance of For a calculate the true value ie X; Va and the true error e in percentage. # Q answer def squareRoota : inputs a: the number to find its square root outputs: X: the approximated square root ea: approximate error iter: number of iterations to reach the approximated square root x a ea iter #initial x value #initial approximate error #initial number of iterations return x iter, ea
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
