Professional Documents
Culture Documents
200021113_Tasnia_Nafs_Assignmnet_4
200021113_Tasnia_Nafs_Assignmnet_4
❖ Waveshapes:
The secant method is a numerical root-finding technique that differs from other methods like the
bisection method and Newton's method in several ways: In the secant method, instead of requiring an
interval with known opposite signs (as in the bisection method) or an initial guess and its derivative (as
in Newton's method), it starts with two initial guesses, often relatively close to the root. The secant
method typically converges faster than the bisection method (which is linear convergence) but slower
than Newton's method (which is quadratic convergence). It approaches the root in a more gradual,
curving manner. Unlike Newton's method, the secant method does not require the computation of
derivatives, making it applicable to functions where finding derivatives may be challenging or
impractical.
fplot(q,[0.5,0.7])
hold on
yline(0,'-g');
hold off
n=input('Enter significant digit');
Es=(0.5*10^(2-n))
Es =
0.050000000000000
ea=100;
x0=1; %represents x_0
dx=-1;
while ea>Es
a=a+1;
x1=x0-q(x0)*dx/(q(x0+dx)-q(x0));
dx=x1-x0;
ea=abs(((x1-x0)/x1)*100);
x0=x1;
end
x1
ans =
0.567143143476009
Secant method -task-3
clc
clear all
close all
format long
q=@(x) 0.95*x^3-5.9*x^2+10.9*x-6;
fplot(q,[0,5])
hold on
yline(0,'-g');
hold off
Es=(0.5*10^(2-n))
Es =
0.050000000000000
x0= 2.5; % x(i-1)
x1= 3.5; % x(i)
ea=100;
while ea>Es
x2=x1-q(x1)*(x0-x1)/(q(x0)-q(x1)); %x(i+1)
ea=abs((x2-x1)*100/x2);
x0=x1;
x1=x2;
end
double(x1)
ans =
3.344613047176974