Sei sulla pagina 1di 6

LAB EXPERIMENT # 3: ROOT FINDING USING NEWTON-RAPHSON

METHOD

Name: Grade (5)

ID Number:

Lab Section:

Objectives
1. To determine roots of an equation in single variable using Newton-Raphson method.
2. To understand the MATLAB implementation of the Newton-Raphson method.
3. To analyze of results using different initial values and error tolerance.

Algorithm

Figure 2: Graphical description of the Newton-Raphson method.

Assuming the function f(x) is differentiable, a tangent of the function of xi, f’(xi) is extrapolated
down to the x- axis to provide an estimate of the root xi+1 as shown by figure 2.
From the Figure, the Newton’s updating formula can be written as:

1
From the above formula, an initial value is needed. The choice of the initial value will affect the
convergence of the solution.

Termination Criteria:

Defining the approximation error as

where 𝑥𝑖+1 is the root of current (new) iteration and 𝑥𝑖 is the root of previous (old) iteration. The
notation 𝜀𝑎,𝑖+1(%) represents the error for current estimate of the root (𝑥𝑖+1).
Then the computations will be terminated if

𝜀𝑎(%) < 𝜀𝑠 𝑜𝑟 𝑚𝑎𝑥𝑖𝑚𝑢𝑚 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑖𝑡𝑒𝑟𝑎𝑡𝑖𝑜𝑛𝑠 𝑖𝑠 𝑟𝑒𝑎𝑐ℎ𝑒


Pseudocode
FUNCTION NewtRaph(x0, es, imax)
i = 1
xi = x0
eai = ∞
DO
xi+1 = xi – f(xi)/f’(xi)
IF xi+1 ≠ 0 THEN
eai+1 = ABS((xi+1 – xi)/xi+1)*100
END IF
DISPLAY i, xi, f(xi), f’(xi), eai
IF eai < es OR iter ≥ imax EXIT
i = i + 1
END DO
NewtRaph = xi
END NewtRaph

2
Practical Work

Preliminary Work (to be done before lab session)


1. Consider the function f(x) = x3 – 2x2 − 6x + 4 = 0. Plot the graph of the function in the
interval [-3, 4].
2. Find the root of the function using the initial guess x0 = 3.0. Perform 4 iterations of the
Newton-Raphson method.
3. Understand the algorithm and the corresponding pseudo-code of the Newton-Raphson
method.

Lab Work

1. Write a MATLAB function y = func2(x) which implements the equation f(x) = x3 – 2x2 −
6x + 4 = 0. It will be used by the Newton-Raphson method.

2. Write a MATLAB function y = dfunc2(x) which implements the derivative of the equation
f(x) = x3 – 2x2 − 6x + 4 = 0. It will be used by the Newton-Raphson method.

3
3. Implement the Newton-Raphson method in MATLAB using the given pseudocode.

4
4. Use the MATLAB implementation of Newton-Raphson method to find a root of the
function f(x) = x3 – 2x2 − 6x + 4 = 0. with the initial guess x0 = 3.0. Perform the
computations until percentage approximate relative error (ℇa (%)) is less than ℇs = 2%. You
are required to fill the following table.

Iteration xi f(xi) f’(xi) ℇa,i (%)


0
1
2
3

5. Repeat step 4 until percentage approximate relative error (ℇa (%)) is less than ℇs = 0.2%.

Iteration xi f(xi) f’(xi) ℇa,i (%)

0
1
2
3
4

6. Repeat step 4 using the initial guess x0 = -1.0.

Iteration xi f(xi) f’(xi) ℇa,i (%)

0
1
2
3
4
5
6
7

5
Discussion and Analysis
1. How does the choice of the initial guess affect the solution?

2. Discuss the convergence of the Newton-Raphson method.

3. How the speed of convergence and the error tolerance (s) are related?

Potrebbero piacerti anche