Root-Finding Methods: Newton-Raphson and Secant Methods: June 1, 2025
Root-Finding Methods: Newton-Raphson and Secant Methods: June 1, 2025
Secant Methods
June 1, 2025
1 Introduction
This report discusses two iterative numerical techniques used to find approxi-
mate solutions to real-valued equations: the Newton-Raphson method and the
Secant method.
2 Newton-Raphson Method
2.1 Theory
The Newton-Raphson method utilizes the concept of tangents. Starting with an
initial guess x0 , the next approximation xn+1 is calculated using the formula:
f (xn )
xn+1 = xn − (1)
f ′ (xn )
where:
• f (x) is the function for which we seek the root.
• f ′ (x) is the derivative of the function.
2.2 Algorithm
1. Choose an initial guess x0 .
2. Compute f (xn ) and f ′ (xn ).
f (xn )
xn+1 = xn − (2)
f ′ (xn )
1
2.3 Code
import numpy as np
import matplotlib.pyplot as plt
def fun(x):
return np.cos(x) - x * np.exp(x)
def derivative(x):
return -np.sin(x) - np.exp(x) - x * np.exp(x)
2.4 Results
The Newton-Raphson method converges rapidly to the root, as observed in the
plotted graph of error versus iteration. The error decreases significantly after
each iteration, indicating the method’s effectiveness.
2
Figure 1: Newton Rapson
3 Secant Method
3.1 Theory
The Secant method is similar to the Newton-Raphson method but does not
require derivatives. It uses two initial guesses, x0 and x1 , to approximate the
derivative. The formula for updating the guess is:
xn − xn−1
xn+1 = xn − f (xn ) · (3)
f (xn ) − f (xn−1 )
3.2 Algorithm
1. Choose two initial guesses x0 and x1 .
2. Compute f (x0 ) and f (x1 ).
3
3. Update the guess using:
xn − xn−1
xn+1 = xn − f (xn ) · (4)
f (xn ) − f (xn−1 )
3.3 Code
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
def fun(x):
• • return np.cos(x) - x * np.exp(x)
4
return iterations, errors
3.4 Results
The Secant method also shows convergence toward the root, although the rate
of convergence may be slower than that of the Newton-Raphson method. The
graph illustrates a gradual decrease in error with each iteration, reflecting the
effectiveness of this method.
5
Figure 2: Secant method
4 Discussion of Graphs
The graphs of the Newton-Raphson and Secant methods provide valuable in-
sights into their convergence behavior and effectiveness in finding roots.
6
• Secant Lines: Unlike the Newton-Raphson method, the Secant method
uses secant lines between two points. The slope of these lines approximates
the derivative, influencing the convergence rate.
• Convergence Rate: The convergence is generally slower than the Newton-
Raphson method, as indicated by a more gradual approach to the root in
the graph. However, the method can still be effective, particularly when
derivatives are difficult to compute.
• Initial Guesses: The choice of initial guesses significantly impacts the
graph’s trajectory. Poor initial guesses may lead to divergence or slow
convergence.
5 Conclusion
Both the Newton-Raphson and Secant methods are effective techniques for solv-
ing nonlinear equations. The choice of method depends on the specific problem
and the available information about the function.