0% found this document useful (0 votes)
25 views1 page

False Position Meth

This document outlines the false position method to approximate the real root of a polynomial equation. It defines an example polynomial function, inputs, and initial values. It then uses an iterative process of updating the lower and upper bounds based on the sign of the function at the midpoint until converging on a solution within 0.0001.

Uploaded by

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

False Position Meth

This document outlines the false position method to approximate the real root of a polynomial equation. It defines an example polynomial function, inputs, and initial values. It then uses an iterative process of updating the lower and upper bounds based on the sign of the function at the midpoint until converging on a solution within 0.0001.

Uploaded by

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

0001 clc;clear

0002 mprintf("approximate the real root of the polynomial equation using the FALSE POSITION METHOD \n
\n")
0003
0004 //define the function
0001 function y=f(x)
0002 y=a*x.^n+b*x.^(n-1)+c*x.^(n-2)+d;
0003 endfunction
0008
0009 //define the inputs
0010 a=1;
0011 b=5;
0012 c=2;
0013 d=-8;
0014
0015 //define initial values
0016 n=input("Input degree of the function: ")
0017 xa=input("Input lower limit: ");
0018 xb=input("Input upper limit: ");
0019 while(f(xa)*f(xb)>0)
0020 disp("Limits incorrect. Please input another.");
0021 xa=input("Input lower limit: ");
0022 xb=input("Input upper limit: ");
0023 end
0024 xa1=[xa:.1:xb]
0025 xm=(xa*f(xb)-xb*f(xa))/(f(xb)-f(xa));
0026 i=0;
0027 z=0;
0028 mprintf ("i\t x\t\t f(xm)\n")
0029 while (abs(f(xm))>0.0001)
0030 xm=(xa*f(xb)-xb*f(xa))/(f(xb)-f(xa));
0031 if(f(xm)*f(xb)<0)then
0032 xa=xm;
0033 else
0034 xb=xm;
0035 end
0036
0037 i=i+1;
0038 mprintf('%d:\t%f\t%f\n',i,xm,f(xm))
0039 end
0040 mprintf("\nSolution of equation is %f ",xm)

You might also like