0% found this document useful (0 votes)
24 views

Numerical Methods and Analysis: College of Engineering Mechatronics Department

The document describes using the secant method to solve nonlinear equations numerically. It provides: 1) An algorithm for implementing the secant method in MATLAB, including defining the function, initial guesses, and stopping criteria. 2) An example of using the secant method to find the root of f(x) = cos(x) + 2sin(x) + x^2, showing the iterations, computed values of x1, and relative error. 3) A second example finding the root of x - 1/x, along with the iterations, values of x1, and stopping when the relative error is less than 0.0001.

Uploaded by

mouaz alashi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Numerical Methods and Analysis: College of Engineering Mechatronics Department

The document describes using the secant method to solve nonlinear equations numerically. It provides: 1) An algorithm for implementing the secant method in MATLAB, including defining the function, initial guesses, and stopping criteria. 2) An example of using the secant method to find the root of f(x) = cos(x) + 2sin(x) + x^2, showing the iterations, computed values of x1, and relative error. 3) A second example finding the root of x - 1/x, along with the iterations, values of x1, and stopping when the relative error is less than 0.0001.

Uploaded by

mouaz alashi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

College of Engineering

Mechatronics Department

NUMERICAL METHODS AND ANALYSIS

Report No. 2

Solution of Nonlinear Equations using Secant Method

Student Name: moath mahmoud (BH18500883)

Submitted to Dr. Diksha Gupta


1. Objective:

To illustrate how to use the Secant Method in non linear equations

2. Theory:
Write a MATLAB code for the following Secant method algorithm:
1. Start with syms x and write the function f
2. Define values of x0, x1 and es
% Here x0 and x1 are the two initial guesses
% es is the stopping criteria, absolute error or the
desired % degree of accuracy
3. while (1) % Initiate an infinite loop
 Compute x2 = x1– (f(x1) * ( x1– x0)) / (f(x1) –
f(x0))
 Compute ea = abs( (x2 – x1)/x2 )*100
 Test for accuracy of x2
if es > ea
break;
else
x0=x1;
x1=x2;
end
end % end of infinite loop
4. Display the required root as x2.
Stop
3.Experimental Procedure and apparatus

As an example of the secant method, suppose we wish to find a root of the


function f(x) = cos(x) + 2 sin(x) + x2. A closed form solution for x does not exist
so we must use a numerical technique. We will use x0 = 0 and x1 = ─ 0.1 as our
initial approximations. We will let the stopping error value ε = 0.002. Fill the
following table:

Iteratio
xi+1 ea
n
1 -0.5137
2 -0.6100 0.044
3 -0.6518 0.158
4 -0.6588 0.085
5 -0.6593 0.010
6 -0.6593 0.001

6
Exercise 2: Use secant method to find the root of x −x−1 , take x0=1 and x1=1.5.,
take eps=0.0001
Iteratio
xi+1 ea
n
1 -8.8906
2 -0.7062
3 -0.4645
4 0.1321
5 -0.0165
6 -0.0005

Conclusion:

Secant method was learned, we were able to solve a lot of different problems using mat lab
and the effect of the roots were obvious to us.

You might also like