The document presents a MATLAB program that solves algebraic and transcendental equations using the regular falsi method. It prompts the user for a function, the number of decimal places, and the lower and upper limits, then iteratively calculates the root until the desired precision is achieved. An example input and output demonstrate the program's functionality, finding a root of approximately 0.702 for the function x*exp(x)-2.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
0 views
Program 6a
The document presents a MATLAB program that solves algebraic and transcendental equations using the regular falsi method. It prompts the user for a function, the number of decimal places, and the lower and upper limits, then iteratively calculates the root until the desired precision is achieved. An example input and output demonstrate the program's functionality, finding a root of approximately 0.702 for the function x*exp(x)-2.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
PROGRAM 6A
%% solution of a algebraic and transcendental equations by regular
falsi clc; close all; clear all; syms x; f=input('enter the functions:\n'); n=input('enter the numbers of decimal places:\n'); epsilon = 10^-(n+1); x0 = input('enter the lower limit:\n'); x1 = input('enter the upper limit:\n'); for i=1:100 f0 =vpa(subs(f,x,x0)); f1 =vpa(subs(f,x,x1)); y=x1-((x1-x0)/(f1-f0))*f1; err = abs(y-x1); if err<epsilon break end f2 = vpa(subs(f,x,y)); if(f1)(f2)<0 var = double(ans) x0=y; x1=x1; else x0=x0; x1=y; end end y =y-rem(y,10^-n); fprintf('the root is :%f\n',y);
INPUT : enter the functions: x*exp(x)-2 enter the numbers of decimal places: 4 enter the lower limit: -4 enter the upper limit: 4 OUTPUT : the root is :0.702000