Question: Write a matlab function file and driver file to solve the square root of a function using the Babylonian method Given a number n, where
Write a matlab function file and driver file to solve the square root of a function using the Babylonian method
Given a number n, where n > 0, x = (x0 + a/x0)/2, where the initial x0 value is = n/2, write an m function using a while loop to implement this equation.
At each step calculate the error using the equation err = abs( (x - x0) / x )
Have the loop repeat until the error is less than or equal to 0.02, and have the program return the result and the error. If the n is less than 0, display the result as an imaginary number by finding the square root of the absolute value of n and multiplying by i.
Create a driver file where n = [ -25, -6, 0, 6, 25] and the error tolerance is = 0.02
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
