assign2xxx5_a

assign2xxx5_a - i+1 by Newton's method is: where f ' is the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Purpose of exercise: To understand and implement the control structure - Looping. One method for finding an approximate solution of an equation f(x) = 0 is Newton's method. This method consists of taking an initial approximation x 1 to be the solution, and constructing the tangent line to the graph of f at point P 1 (x 1 , f(x 1 )). The point x 2 at which this tangent line crosses the x-axis is the second approximation to the solution. Another tangent line may be constructed at point P 2 (x 2 , f(x 2 )), and the point x 3 where this tangent line crosses the x-axis is the third approximation. For many functions, this sequence of approximations, x 1 , x 2 , x 3 , … converges to the solution, provided that the first approximation is sufficiently close to the solution. The following diagram illustrates Newton's method: f(x) x i+1 x i x 3 x 2 x 1 x 0 If x i is an approximation to the solution of f(x) = 0 , then the formula for obtaining the next approximation x
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i+1 by Newton's method is: where f ' is the derivative of f. Note that the method fails if f '(x) = 0 , at some approximation. Note f ' is n * x n-1 . This process terminates when the positive difference between two consecutive approximations is sufficiently small. 1 Write a class called NewtonRaphson that can be used to find an approximate solution of a using Newton's method, for any positive real number. Note: a can be expressed in functional notation as follows: f(x) = x 2 a, From which f ' (x) = 2 * x, Print the iteration sequence and the approximation for each iteration. (That is, in a tabular form). Write a driver class called TestNewton . Use the following data to test the class NewtonRaphson . The initial guess is 5.0 In this exercise, the process terminates when the difference between two consecutive approximations is less than 0.00005 2...
View Full Document

Page1 / 2

assign2xxx5_a - i+1 by Newton's method is: where f ' is the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online