Objective:
Lab Report 07
Solving Newton Raphson Method & Secant Method in coding form using MATLAB.
![]() |
| Newton Raphson Method in Matlab |
Theory:
In numerical
analysis, Newton's method, also known as the Newton–Raphson method, named after Isaac Newton and Joseph Raphson, is a root-finding
algorithm which produces
successively better approximations
to the roots (or
zeroes) of a real-valued function.
Newton Raphson Method:
The Newton-Raphson method (also known as Newton's method) is a way to
quickly find a good approximation for
the root of a real-valued function f(x)=0f(x) = 0f(x)=0. It uses the idea that a continuous and differentiable function
can be approximated by a straight line tangent to it.The most basic version starts with a single-variable function f defined
for a real variable x, the function's derivative f ′, and an initial
guess x0 for a root of
f. If the function satisfies
sufficient assumptions and the initial guess is close, then
![]() |
MATLAB Code:
>>clc
>>close all
>>clear all
>>n=input('Enter the number of iteration:')
>>for i=0:1:n
>> if i==0
>>syms('x')
>>y=exp(-x(i+1))-x(i+1)
>>k=diff(y(i+1))
>>x(1)=0;
>>d=vpa(subs(k,x(i+1)));
>>fv=subs(y(i+1),x(i+1));
>>x(i+2)=x(i+1)-(fv/d)
>>else
>>d=vpa(subs(k,x(:,i+1)));
>>fv=subs(y,x(:,i+1));
>>x(i+2)=x(:,i+1)-(fv/d)
>>end
>> if i>0
>> e(i)=(x(:,i+1)-x(:,i))/x(:,i+1)*100
>> if norm(e(:,1))<.01
>> break
>>end
>>end
>>end
MATLAB Work:
Input:
![]() |
Output:
Theory:
Secant Method
Secant method is an iterative tool of mathematics and numerical methods
to find the approximate root of
polynomial equations. During the course of iteration, this method assumes the function to be approximately
linear in the region of interest. Although secant
method was developed independently, it is often considered to be a finite difference approximation of Newton’s
method. But, being free from derivative, it is
generally used as an alternative to the latter method.Newton’s method
was based on using the line tangent
to the curve of y = f (x), with the point of tangency (x0, f (x0)).
When x0 ≈ r, the graph of the tangent line is approximately the same as the
graph of y = f (x) around
x = r. We then
used the root of the tangent line to approximate r.
The Secant
Method:
There are some
steps which are involved in secant method.
1. Initialization:
Two initial
guesses x0 and x1 of r are
chosen.
2. Iteration:
For n = 1; 2;
3; · · ·,
until certain
stopping criterion is satisfied (required
solution accuracy or maximal number
of iterations is reached).
Advantages of secant method:
1. It converges
at faster than a linear rate, so that it is more rapidly convergent than the bisection method.
2. It does not require
use of the derivative of the function, something that is not available in a number of applications.
3. It requires
only one function
evaluation per iteration, as compared with Newton’s method
which requires two.
Disadvantages of secant method:
1. It may not converge.
2. There is no guaranteed error bound for the computed
iterates.
3. It is likely to have difficulty if f ’(r) = 0. This means
the x-axis is tangent to the graph
of y= f (x) at x =
r.
4. Newton’s
method generalizes more easily to new methods for solving simultaneous systems
of nonlinear equations.
Input:
Output:




0 Comments