Nama Kelompok :
Amelia Virgiyani Sofyan
(1215041006)
(1215041018)
(1215041022)
Sakha Abdussalam
(1215041043)
(1215041058)
TEKNIK KIMIA
FAKULTAS TEKNIK
UNIVERSITAS LAMPUNG
2016
)=
)= ( )+( )+(
) ( )
untuk menentukan nilai yang mendekati akar sejati dari sistem persamaan nonlinier agar
memudahkan proses iterasi.
%
%
%
%
%
%
input:
func = name of function that returns f and J
x0 = initial guess
es = desired percent relative error (default = 0.0001%)
maxit = maximum allowable iterations (default = 50)
p1,p2,... = additional parameters used by function
output:
x = vector of roots
f = vector of functions evaluated at roots
ea = approximate percent relative error (%)
iter = number of iterations
iter = 0;
x=x0;
iterasi awal yaitu 0
x sama dengan x0
while (1)
[J,f]=func(x,varargin{:});
Matriks [J,f] berisikan x dan opsi fungsi-fungsi
Kasus 12.3
Persamaan sistem nonlinear sering ditemukan dalam kasus-kasus perhitungan reaksi kimia,
sebagai contoh Reaksi kimia berikut terjadi dalam sistem tertutup:
2 +
+
.( )
..( )
.( )
.( )
K2=3.7x10-2
ca,0=50
cb,0=20
cc,0=5
cd,0=10
Gunakan Metode Newton Raphson untuk mencari solusi dari kasus di atas.
Jawab:
1. Gunakan stoikiometri dari reaksi a dan b untuk mencari konsentrasi dari masing
masing zat dengan memberikan x1 dan x2
=
=
(
(
)(
3. Persamaan di atas memiliki dua variabel yang tidak diketahi yaitu x1 dan x2 sehingga
digunakanlah single-equation Newton Raphson dan juga untuk menentukan akar
sejati
( ,
( ,
)=
)=
) (
)(
(4 10 )
(3.7 10 )
=
=
=
=
(
(
,
,
(
(
,
,
x =
3.3366e+000
2.6772e+000
f =
5.1816e-015
1.8277e-014
ea =
2.2168e-009
iter =
5
Berdasarkan perhitungan tersebut, diperoleh x1 dan x2 yaitu:
x1 = 3.3366
x2 =2.6772
Kemudian nilai tersebut dapat disubstitusikan ke dalam persamaan konsentrasi dari
masing-masing zat.
=
= 20 3,3366 = 16,663
= 10 2,6772 = 73,228
CONTOH SOAL
KASUS I
You have a spherical storage tank containing oil. The tank has a diameter of 6 ft. You are
asked to calculate the height h to which a dipstick 8 ft long would be wet with oil when
immersed in the tank when it contains 6 ft3 of oil.
dipstick
Spherical storage tank
1.
Menghitung Dari persamaan diatas diketahui bahwa nilai f(h) = 0 . dan kita asumsikan untuk
tebakan nilai awal iterasi adalah 1, sehingga h0 atau hold = 1
Jika persamaan tersebut dimasukkan ke dalam matlab, hasilnya adalah sebagai berikut:
Memasukkan nilai h0 dalam aplikasi matlab:
>> hold=1
hold =
1
2.
Untuk f(h) di simbolkan dengan fh dan untuk f(h) disimbolkan dengan gh.
()
()
Untuk iterasi 1 :
( )
( )
Perhitungan yang dilakukan dalam matlab adalah sebagai berikut :
=
>> fh0=hold^3-9*hold^2+3.8197
fh0 =
-4.1803
>> gh0=3*hold^2-18*h0
gh0 =
-15
>> h1=h0-(fh0/gh0)
h1 =
0.7213
Dari perhitungan diatas didapat nilai hnew atau (h1) sebesar 0.7213, sehingga dapat dihitung
nilai error nya dengan rumus sebagai berikut :
| | =
100
Nilai eror masih sangat besar yaitu 38.636% sehingga perlu dilakukan iterasi yang ke-2
Iterasi ke-2
Nilai hold yang digunakan adalah nilai h(1) yang telah didapat dan dimasukkan kedalam
persamaan untuk menemukan nilai hnew atau h(2) dengan cara yang sama seperti iterasi
sebelumnya.
>> hold=h1
hold =
0.7213
Iterasi dilakukan dengan menggunakan rumus:
( )
( )
Sehingga perhitungan pada matlabnya adalah sebagai beikut:
=
>> fh1=hold^3-9*hold^2+3.8197
fh1 =
-0.4876
>> gh1=3*hold^2-18*hold
gh1 =
-11.4228
>> h2=hold-(fh1/gh1)
h2 =
0.6786
Dari perhitungan diatas didapat nilai hnew atau (h2) sebesar 0.6786, sehingga dapat dihitung
nilai error nya dengan rumus sebagai berikut :
| | =
100
>> e2=abs((h2-hold)/h2)*100
e2 =
6.2907
Nilai eror masih sangat besar yaitu 6.2907 % sehingga perlu dilakukan iterasi yang ke-3
Iterasi ke-3
Nilai hold yang digunakan adalah nilai h(2) yang telah didapat dan dimasukkan kedalam
persamaan untuk menemukan nilai hnew atau h(3) dengan cara yang sama seperti iterasi
sebelumnya.
>> hold=h2
hold =
0.7213
Iterasi dilakukan dengan menggunakan rumus:
( )
( )
Sehingga perhitungan pada matlabnya adalah sebagai beikut:
=
>> fh2=hold^3-9*hold^2+3.8197
fh2 =
-0.0125
>> gh2=3*hold^2-18*hold
gh2 =
-10.8336
>> h3=hold-(fh2/gh2)
h3 =
0.6775
Dari perhitungan diatas didapat nilai hnew atau (h3) sebesar 0.6775, sehingga dapat dihitung
nilai error nya dengan rumus sebagai berikut :
| | =
100
>> e3=abs((h3-hold)/h3)*100
e3 =
0.1708
Nilai eror masih cukup besar yaitu 0.1708 % sehingga perlu dilakukan iterasi yang ke-4
Iterasi ke-4
Nilai hold yang digunakan adalah nilai h(3) yang telah didapat dan dimasukkan kedalam
persamaan untuk menemukan nilai hnew atau h(4) dengan cara yang sama seperti iterasi
sebelumnya
>> hold=h2
hold =
0.7213
Iterasi dilakukan dengan menggunakan rumus:
=
>> fh3=hold^3-9*hold^2+3.8197
fh3 =
-9.3268e-006
( )
( )
>> gh3=3*hold^2-18*hold
gh3 =
-10.8175
>> h4=hold-(fh3/gh3)
h4 =
0.6775
Dari perhitungan diatas didapat nilai hnew atau (h4) sebesar 0.6775, nilai eror nya adalah:
| | =
100
>> e4=abs((h4-hold)/h4)*100
e4 =
1.2727e-004
Nilai hnew yang didapat suma dengan nilai hold yang sebelumnya, serta nilai eror nyapun
sudah sangat kecil yaitu 0.00012727 %. Sehingga proses iterasi ini dapat dihentikan.
1 of 3
0.6775
>> e3=abs((h3-hold)/h3)*100
e3 =
0.1708
>> hold=h3
hold =
0.6775
>> fh3=hold^3-9*hold^2+3.8197
fh3 =
-9.3268e-006
>> gh3=3*hold^2-18*hold
gh3 =
-10.8175
>> h4=hold-(fh3/gh3)
h4 =
0.6775
>> e4=abs((h4-hold)/h4)*100
e4 =
1.2727e-004
KASUS 2
Finding a Root of an nth-Degree Polynomial by Newton-raphson. Method Applied to the
Soave-Redlich-Kwong Equation of State.
Develop a MATLAB function to calculate a root of a polynomial equation by Newton-Raphson
method. Calculate the specific volume of a pure gas, at a given temperature and pressure, by
using the Soave- Redlich-Kwong equation of state:
=
( + )
0.4278
0.0867
where TC and PC are critical temperature and pressure, respectively. The variable is an
empirical function of temperature:
= 1+
Pc = 3797 kPa,
= 0.1931
Method of Solution: Case 2 is used for Newton-Raphson evaluation of the root. For finding
the gas specific volume from the Soave-Redlich-Kwong equation of state, Case 2,
which is a third-degree polynomial in compressibility factor, is solved. Starting value for the
iterative method is Z = 1, which is the compressibility factor of the ideal gas.
x = x0;
x0 = x + .1;
maxiter = 100;
% Solving the polynomial by Newton-Raphson method
while abs(x0 - x) > tol & iter < maxiter
iter = iter + 1;
x0 = x;
fnkp = polyval(polyder(c),x0); % Derivative
if fnkp ~= 0
x = x0 - fnk / fnkp; % Next approximation
else
x = x0 + .01;
end
fnk = polyval(c,x); % Function
% Show the results of calculation
if trace
disp([sprintf('%5.0f
%13.6g %13.6g ',iter, [x fnk])])
if trace == 2
xpath = [xpath x x];
ypath = [ypath 0 fnk];
end
end
end
if trace == 2
% Plot the function and path to the root
xmin = min(xpath);
xmax = max(xpath);
dx = xmax - xmin;
xi = xmin - dx/10;
xf = xmax + dx/10;
yc = [];
for xc = xi : (xf - xi)/99 : xf
yc = [yc polyval(c,xc)];
end
xc = linspace(xi,xf,100);
ax = linspace(0,0,100);
plot(xc,yc,xpath,ypath,xc,ax,xpath(1),ypath(2),'*',x,fnk,'o')
axis([xi xf min(yc) max(yc)])
xlabel('x')
ylabel('f(x)')
title('Newton-Raphson : The function and path to the root (* :
initial guess ; o : root)')
end
if iter == maxiter
disp('Warning : Maximum iterations reached.')
end
Setelah dibuat mfile seperti diatas, mfile dijalankan sehingga hasilnya akan muncul
seperti berikut ini :
Input and Results
>>Example1_2
Input the vector of pressure range (Pa) : [1:40]*101325
Input temperature (K) : 500
Critical temperature (K) : 425.2
Critical pressure (Pa) : 3797e3
Acentric factor : 0.1931
Pres. = 101325.00 Ideal gas vol. =41.0264 Real gas vol.
Pres. = 1013250.00 Ideal gas vol. = 4.1026 Real gas vol.
Pres. = 2026500.00 Ideal gas vol. = 2.0513 Real gas vol.
Pres. = 3039750.00 Ideal gas vol. = 1.3675 Real gas vol.
Pres. = 4053000.00 Ideal gas vol. = 1.0257 Real gas vol.
KASUS 3 :
=40.8111
= 3.8838
= 1.8284
= 1.1407
= 0.7954