Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Resolve using the Haskell coding language Task: Compute the square root of the input using Newton's method. newtonssqrt::(Floatinga,Orda)axasquarerootofx Newton's method is an ingenious algorithm that

Resolve using the Haskell coding language

image text in transcribed

Task: Compute the square root of the input using Newton's method. newtonssqrt::(Floatinga,Orda)axasquarerootofx Newton's method is an ingenious algorithm that generates successively better approximations to the solutions of an equation. It is an instance of a more general technique we'll discuss later on known as fixed-point iteration. Applied to the problem of finding the square root of some number x, it works as follows: 1. Start with some guess g 2. Check if our guess is the solution we want -- i.e., if g2=x. If so, we are done. 3. If not, improve our guess and repeat step 2. To do this, we need a formula to compute a new guess g where g2 is closer to x then g2. We can use the formula: g=2g+gx E.g., say we want to compute the square root of 2 . We can start with the guess 1.12=2, so we compute a new guess: 21+12=1.5 1.52=2.25=2, so we compute a new guess: 21.5+1.52=1.41666 (1.41666..)2=2.069444=2, so we compute a new guess: 21.41666+1.416662=1.41421 (1.41421...)2=2.0000... If we want to get a more accurate root, we can keep going, but we'll stop here. For a given input x, your solution should find a root r with error tolerance =0.0001; i.e., xr2

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions