Lab 6 - Regular Falsi Method
Lab 6 - Regular Falsi Method
Class: BESE-13AB
Objectives
The purpose of this lab is to get familiar with Regular Falsi Method
Tools/Software Requirement
Matlab R2016a
Description
First of all, we need to predict a value for the roots (lower and upper guess)
xl (xlower); lower guess
xu (xupper); upper guess
For these two values of function f we will find;
For xl f(xl)
For xu f(xu)
Implement the following equation called as a false position formula:
Pseudocode
1. Start
2. Define function f(x)
3. Input
a. Lower and Upper guesses a and b
b. tolerable error e
4. If f(a)*f(b) > 0
print "Incorrect initial guesses"
goto 3
End If
5. Do
Code the above mentioned equation to find the root and store it in variable c.
6. Print root as c
7. Stop
(By using loop and understanding the algorithm, write the code and display the root. You can use
a simple while loop instead of a do while loop as well)
Lab Task
Implement Regular Falsi method as function. Take function, initial guess, tolerance and other
required parameter as input from user. find its roots.
Code:
function regulafalsi()
while true
% Setting x as symbolic variable
syms x;
% Input Section
inputFunction = input('Enter non-linear equations: ');
error = input('Tolerable error: ');
if fa * fb > 0
disp('Given initial values do not bracket the root. Please enter new guesses.');