0% found this document useful (0 votes)
128 views2 pages

Regula Falsi Method Matlab Script

This document describes the Regula Falsi method for finding the root of an equation. It provides a Matlab script that takes user input for initial values of x1 and x2, whose corresponding y-values have opposite signs. It then iteratively calculates a new x-value between x1 and x2 until the desired number of iterations is reached, converging on the root of the given function f(x)=sin(x)-x.

Uploaded by

NumanAbdullah
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)
128 views2 pages

Regula Falsi Method Matlab Script

This document describes the Regula Falsi method for finding the root of an equation. It provides a Matlab script that takes user input for initial values of x1 and x2, whose corresponding y-values have opposite signs. It then iteratively calculates a new x-value between x1 and x2 until the desired number of iterations is reached, converging on the root of the given function f(x)=sin(x)-x.

Uploaded by

NumanAbdullah
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/ 2

Regula Falsi Method

Matlab script:-
x2=input('Enter value of x2=');
x1=input('Enter value of x1=');
n=input('No of iteration');
f=inline('sin(x)-x')
y1=f(x1);
y2=f(x2);
while(y1*y2>0)
x1=input('Enter value of x1 again');
x2=input('Enter value of x2 again');
y1=f(x1);
y2=f(x2);
end
for i=1:n
x3=(x2*y1-x1*y2);
y3=f(x3);
if y1*y3<0
x2=x3;
y2=f(x2);
else
x1=x3;
y1=y3;
end
end

You might also like