You are on page 1of 12

REGULAR FALSI METHOD

B.S. (SE) Semester Project Report

Submitted by:
Name: RESHMA Seat number: 1822146
Name: HUZAIKA MATLOOB Seat number:
Name: MAHAM IMRANI Seat number

July 15th 2021

DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING


JINNAH UNIVERSITY FOR WOMEN
5-C NAZIMABAD, KARACHI 74600
Contents
Problem Statement:...........................................................................................................3
Project Introduction...........................................................................................................4
Project Summary...............................................................................................................5
GitHub Link......................................................................................................................6
Algorithm..........................................................................................................................7
Project Flow......................................................................................................................8
Code Explanation..............................................................................................................9
Screenshots......................................................................................................................10
References.......................................................................................................................11
Problem Statement:
In this MATLAB program for false position method, “y” is nonlinear function, “a” &
” b “are two initial guesses and “e” is tolerable error.
Project Introduction
The Regula–Falsi Method is a numerical method for estimating the roots of a
polynomial f(x). A value x replaces the midpoint in the Bisection Method and
serves as the new approximation of a root of f(x). The objective is to make
convergence faster.
Project Summary
Regula Falsi method or the method of false position is a numerical method for
solving an equation in one unknown. It is quite similar to bisection method
algorithm and is one of the oldest approaches. It was developed because the
bisection method converges at a fairly slow speed. In simple terms, the method is
the trial and error technique of using test ("false") values for the variable and
then adjusting the test value according to the outcome.
GitHub Link
Provide GitHub link here
Algorithm
1. Start
2. Define function f(x)
3. Choose initial guesses x0 and x1 such that f(x0) f(x1) < 0
4. Chose pre-specified tolerable error “e”
5. Calculate new approximated root as:
x2 = x0 – ( (x0-x1) * f(x0) / f(ox0)p – f(x1) )
6. Calculate f(x0) f(x2)
a. if f(x0) f(x2) < 0 then x0 = x0 and x1 = x2
b. if f(x0) f(x2) > 0 then x0 = x2 and x1 = x1
c. if f(x0) f(x2) = 0 then goto (8)
7. If [ f(x2) ]>e then goto (5) otherwise goto (8)
8. Display x2 as root
9. Stop
Project Flow
.
Code Explanation
% Clearing Screen
clc

% Setting x as symbolic variable


syms x;

% Input Section
y = input('Enter non-linear equations: ');
a = input('Enter first guess: ');
b = input('Enter second guess: ');
e = input('Tolerable error: ');

% Finding Functional Value


fa = eval(subs(y,x,a));
fb = eval(subs(y,x,b));

if fa*fb > 0
disp('Given initial values do not bracket the root.');
else
c = a - (a-b) * fa/(fa-fb);
fc = eval(subs(y,x,c));
fprintf('\n\na\t\t\tb\t\t\tc\t\t\tf(c)\n');
while abs(fc)>e
fprintf('%f\t%f\t%f\t%f\n',a,b,c,fc);
if fa*fc< 0
b =c;
fb = eval(subs(y,x,b));
else
a =c;
fa = eval(subs(y,x,a));
end
c = a - (a-b) * fa/(fa-fb);
fc = eval(subs(y,x,c));
end
Screenshots
References
https://www.codesansar.com/numerical-methods/regula-falsi-or-false-position-method-using-matlab-
output.htm

https://matlab.mathworks.com/
.

You might also like