Solution of Non Linear Equation by Using Newton Rapshon Method
Solution of Non Linear Equation by Using Newton Rapshon Method
of
Electrical & Electronic Engineering
Lab. Report on
Experiment No: 02
Exp. Name: Solution of non-linear equation by using Newton-Rapshon
Method
1. Objective
To implement the Newton-Raphson method in MATLAB and C programming to find the
root of a given nonlinear equation.
2. Theory
The Newton-Raphson method is an iterative numerical method for finding the root of a
nonlinear equation. It uses the tangent line to approximate the function at the current
guess and finds the point where the tangent line intersects the x-axis. This point becomes
the next guess, and the process is repeated until a desired accuracy is achieved.
Let 𝑥0 be the approximate root of 𝑓(𝑥) = 0 and let 𝑥1 = 𝑥0 + ℎ be the correct root. Then
𝑓(𝑥1 ) = 0
⇒ 𝑓(𝑥0 + ℎ) = 0 ……….(1)
𝑓(𝑥0 ) + ℎ𝑓 ′ (𝑥0 ) + ⋯ = 0
⇒ ℎ = −𝑓(𝑥0 )/𝑓 ′ (𝑥0 )
Therefore,
𝑥1 = 𝑥0 − 𝑓(𝑥0 )/𝑓 ′ (𝑥0 )
3.Steps:
Input Parameters:
Function Definition: The user is prompted to enter the nonlinear function in symbolic form.
Derivative Definition: The user is asked to input the derivative of the function.
Initial Guess: The user specifies the initial guess for the root.
Number of Iterations: The user defines the maximum number of iterations to be performed.
Tolerance: The user sets the desired tolerance for the root.
Iteration Loop:
For each iteration:
Calculate the next guess x1 using the Newton-Raphson formula.
Print the current iteration and the calculated value of x1.
Check for convergence:
If the absolute difference between x1 and the previous guess x0 is less than the tolerance, the
root is considered found, and the loop breaks.
Check for Zero Derivative:
If the derivative at x1 is zero, display an error message indicating that the method failed.
Update the current guess:
Set x0 to x1 for the next iteration.
5.Discussion:
The code demonstrates the Newton-Raphson method to find the root of the nonlinear equation
f(x) = x^2 + 2x - 2. We input the function, its derivative, an initial guess, the maximum number
of iterations, and the desired tolerance. The Newton-Raphson method iteratively refines the
initial guess using the tangent line approximation to converge towards the root. The output
shows the root approximations at each iteration. The final calculated root is 0.7321, which is
within the specified tolerance. The Newton-Raphson method is generally more efficient than the
bisection method, but it requires the calculation of the derivative.