Você está na página 1de 7

Question 1

ASSIGNMENT MATLAB 1&2


CPB20203 - NUMERICAL METHODS IN CHEMICAL ENG.
UNIKL MICET

Lecturer: SIR ABU HASSAN BIN ABD RAHMAN

MOHAMMAD SYAFIQ BIN SAMAD


55247113722
LO4

6 APRIL 2016

QUESTION 2

% Find the root of f(x)= exp(-x)-x using fixed point iteration


% initial value: x=0, error should be less than 0.001%
% Solution:
% f(x)= exp-2x= 0
% x = exp-2
clear;clc;format('long','g')
i=1;
x(i)=0;
error(i)=999;
while error(i) >= 0.001
x(i+1)=exp(-x(i));
error(i+1)=abs((((x(i+1)-x(i))/(x(i+1)))*100));
i=i+1
end
disp('
root
disp([x',error'])

>>>>>>>>

error(%)');

i=
2
i=
3
i=
4
i=
5
i=
6
i=
7
i=
8
i=
9
i=
10
i=
11
i=
12
i=
13
i=
14
i=
15

i=
16
i=
17
i=
18
i=
19
i=
20
i=
21
i=
22
i=
23
i=
24

root

error(%)

999

100

0.367879441171442

171.828182845905

0.692200627555346

46.8536394613384

0.500473500563637

38.3091465933331

0.606243535085597

17.4467896811512

0.545395785975027

11.1566225253813

0.579612335503379

5.90335081440867

0.560115461361089

3.48086697962453

0.571143115080177

1.93080393125982

0.56487934739105
0.568428725029061

0.624419119183282

0.566414733146883

0.355568413799569

0.567556637328283

0.201196516135472

0.566908911921495

0.114255640221412

0.56727623217557

0.0647515677971472

0.567067898390788

0.0367387724419489

0.567186050099357

0.0208312084805067

0.567119040057215

0.0118158688756572

0.567157044001298

0.00670077970194647

0.567135490206278

0.00380046662417019

0.567147714260119

0.00215535627376598

0.567140781458298

0.00122241285547367

0.56714471334657

>>

1.10886824205157

0.000693277778923042

Você também pode gostar