Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called SquareRoot that takes a double as a parameter and that returns an approximation of the square root of the parameter, using

image text in transcribed

image text in transcribed

Write a function called SquareRoot that takes a double as a parameter and that returns an approximation of the square root of the parameter, using this algorithm. You may not use the sqrt() function from the math.h library.

Exercise 6.3 Let's say you are given a number, a, and you want to find its square root. One way to do that is to start with a very rough guess about the answer, xo, and then improve the guess using the following formula: 6, then For example, if we want to find the square root of 9, and we start with x0 X1 (6 + 9/6)/2-15/4 3.75, which is closer. We can repea the procedure, using Ti to calculate x2, and so on. In this case, T2 3.075 and x3 3.00091. So that is converging very quickly on the right answer (which is 3) Write a function called SquareRoot that takes a double as a parameter and that returns an approximation of the square root of the parameter, using this algorithm You may not use the sqrt() function from the math.h library

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

Step: 3

blur-text-image

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions