0% found this document useful (0 votes)
8 views5 pages

Practical No 3a (NC)

Uploaded by

Muhammad Daniyal
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)
8 views5 pages

Practical No 3a (NC)

Uploaded by

Muhammad Daniyal
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/ 5

GR.NO.

11 MEMOONA ARSHAD

PRACTICAL NO. 3(A)

OBJECT:
Write a program to find the root of the given equation using false position
method (using fixed iteration).

Page | 26
PRACTICAL NO# 3(A)
GR.NO.11 MEMOONA ARSHAD

ALGORITHM
STEP NO. 01: Start the program.
STEP NO. 02: Declare variables x0,x1,x2,x3,f0,f1,f2,n,c.

DEFINE function f(x:real):real;


STEP NO. 03: f:= 3x+sin(x)- e x
STEP NO. 04: Return value of the function.
STEP NO. 05: End of the function.

DEFINE MAIN PROGRAM

STEP NO. 06: n:=1.


STEP NO. 07: Read x0 and x1.
STEP NO. 08: Repeat while do loop until n<=10
STEP NO. 8(a): Call function f for x0 and assign its value to f0.
STEP NO. 8(b): Call function f for x1 and assign its value to f1.
STEP NO. 8(c):x2=x1-(f(x1)*((x0-x1)/f(x0)-f(x1))))
STEP NO. 8(d): Call function f for x2 and assign its value to f2.
STEP NO. 8(e):write n,x0,x1,x2,f2.
STEP NO. 8(f): if(f0*f2)<0 then x1=x2
Else x0=x2.
STEP NO. 8(g): n=n+1
STEP NO. 9: write x2.
STEP NO. 10: stop the program.

Page | 27
PRACTICAL NO# 3(A)
GR.NO.11 MEMOONA ARSHAD

FLOW CHART
Start A

Declare variables No
x0,x1,x2,x3,f0,f1,f2,n,c. (f0*f2)<00 X0=x1

Yes
Declare function ‘f’
X1=x2

N=1
B N=n+1

Read x0,x1

Write x2
No
B N<=10
Stop
Yes
Call function f for x0 and assign its value to f0.

Call function f for x1 and assign its value to f1. Function f(x:real):real;

x2 =x1-(f(x1)*((x0-x1)/f(x0)-f(x1))))
f:= 3x+sin(x)- e x

Call function f for x2 and assign its value to f2.


Stop

write n,x0,x1,x2,f2.

Page | 28
PRACTICAL NO# 3(A)
GR.NO.11 MEMOONA ARSHAD

SOURCE CODE

program regula_falsi;
uses crt;
var x0,x1,x2,f0,f1,f2:real;
n:integer;
c:char;
function f(x:real):real;
begin
f:=(3*x)+sin(X)-exp(x);
end;
begin
clrscr();
n:=1;
write('x0 = ');
readln(x0);
write('x1 = ');
readln(x1);
writeln;
writeln;
writeln(' -----FALSE POSITION METHOD----- ');
writeln;
writeln('n x0 x1 x2 f2');
writeln;
while n<=10 do
begin
f0:=f(x0);
f1:=f(x1);
x2:=x1-(f1*((x0-x1)/(f0-f1)));
f2:=f(x2);
writeln(n,' ',x0:7:6,' ',x1:7:6,' ',x2:7:6,' ',f2:7:6);
if(f0*f2)<0 then
x1:=x2
else
x0:=x2;
n:=n+1;
end;
writeln;
writeln('The root of the given equation is : ',x2:7:6);
readln(c);
end.

Page | 29
PRACTICAL NO# 3(A)
GR.NO.11 MEMOONA ARSHAD

OUTPUT

Page | 30
PRACTICAL NO# 3(A)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy