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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started