Dosen Pengampu
Anif Jamaluddin
Pendidikan Fisika
Fakultas Keguruan dan Ilmu Pendidikan
Universitas Sebelas Maret
2022
Kata Pengantar
Pada modul numerik kali ini akan dibahas beberapa metode numerik yang dikelompokan menjadi
beberapa sub bab/bagian yaitu : persamaan non-linear, sistem persamaan liner dan diferensiasi
nuerik. Untuk bab persamaan Non-Linear menggunakan Metode Biseksi dan Newton-Raphson,
Bab Sistem Persamaan Linear adalah metode eliminasi gaus dan matrik sistem persamaan
linear. Pada Bab Diferensiasi numerik akan membahas tentang metode euler dan beda hingga.
Pada setiap bab akan dijelaskan secara singkat tentang materi tersebut, serta prosedur
penyelesaian numerik. Selanjutnya akan ditampilkan contoh pemrograman dengan
menggunakan octave.
Semoga modul ini dapat bermanfaat sebagai bahan pendamping perkuliahan pengantar
komputasi dan numerik.
Anif Jamaluddin
BAB I Metode Numerik
1.2 Kesalahan
Dalam analisis numerik apa pun, kesalahan akan muncul selama perhitungan. Untuk dapat
menangani masalah kesalahan, kita perlu
f ( x + h) − f ( x )
f ' ( x)
h
Contoh :
Dengan Untuk 𝑓(𝑥) = 9𝑒 0.3𝑥 dan h = 0.3 tentukan nilai f’(x) secara analitik dan numerik untuk
x=3?
Jawab :
Solusi analitik untuk x=3
𝑓(𝑥) = 9𝑒 0.3𝑥
𝑓′(3) = (2.7)(2.718)0.9
𝑓′(3) = 6.6409
Solusi numerik
f ( x + h) − f ( x )
f ' ( x)
h
𝑓(3 + 0.3) − 𝑓(3)
𝑓′(3) ≈
0.3
𝑓(3.3) − 𝑓(3)
𝑓′(3) ≈
0.3
9𝑒 0.3(3.3) − 9𝑒 0.3(3)
𝑓′(3) ≈
0.3
9𝑒 0.3(3.3) − 9𝑒 0.3(3)
𝑓′(3) ≈
0.3
′ (3)
9𝑒 (0.99) − 9𝑒 (0.9)
𝑓 ≈
0.3
9(2.6910) − 9(2.4596)
𝑓 ′ (3) ≈
0.3
24.2211 − 22.1364
𝑓 ′ (3) ≈
0.3
24.2211 − 22.1364
𝑓 ′ (3) ≈
0.3
F’(3)= 6.9487
Error = |hasil numerik - hasil analitik|
=|6.9487-6.6409|
=0.3078
x2 x4 x6
cos(x) = 1 − + − + (1)
2! 4! 6!
x3 x5 x7
sin( x) = x − + − + (2)
3! 5! 7!
x 2 x3
ex = 1+ x + + + (3)
2! 3!
Secara sederhana dapat dituliskan : f ( x )
f (x ) 2 f (x ) 3
f (x + h ) = f (x ) + f (x )h + h + h + (4)
2! 3!
f ( x ) dan continue pada x and x + h .
Contoh kasus
Tentukan nilia f (6 ) jika hasil yang diketahui untuk f (4) = 125 , f (4 ) = 74 , f (4) = 30 ,
f (4) = 6 dan turunan tertinggi dari f ( x ) pada saat x = 4 adalah 0.
Jawab:
h2 h3
f (x + h ) = f (x ) + f (x )h + f (x ) + f (x ) +
2! 3!
x=4
h = 6−4
=2
Pada saat turunan tertinggi f ( x ) adalah 0 saat x = 4 .
22 23
f (4 + 2) = f (4) + f (4)2 + f (4) + f (4)
2! 3!
2 2 23
f (6) = 125 + 74(2) + 30 + 6
2! 3!
= 125 + 148 + 60 + 8
= 341
BAB II Persamaan Non-Linear
Contoh :
Untuk range waktu dari 1,5 , tentukan iterasi kedua dari persamaan berikut ini dengan
menggunakan metode biseksi te −t − 0.3 = 0
Jawab :
f (t ) = te −t − 0.3
Dalam rentan waktu tersebut :
tu = 5
t = 1
f (t u ) = 5e −5 − 0.3
= −0.2663
f (t ) = 1e −1 − 0.3
= 0.0679
Sehingga,
f (t u ) f (t ) = f (5) f (1)
= (−0.2663)(0.0679)
= −0.0181 0
Jadi setidaknya ada satu akar di antaranya t and t u .
Iterasi 1
Estimasi
t + tu
tm =
2
1+ 5
=
2
=3
f (t m ) = 3e −3 − 0.3
= −0.1506
Sehingga,
f (t ) f (t m ) = f (1) f (3)
= (0.0679)(−0.1506)
= −0.0102 0
Jadi tebakan atas dan bawah yang baru untuk akarnya adalah, Selanjutnya t dan t m ,
t = t = 1
tu = t m = 3
Iterasi ke 2
Estimasi untuk
t + tu
tm =
2
1+ 3
=
2
=2
Langkah
The steps of the Newton-Raphson method to find the root of an equation f ( x ) = 0 are
1. Evaluate f ( x ) symbolically
2. Use an initial guess of the root, xi , to estimate the new value of the root, xi +1 , as
f (xi )
xi +1 = xi −
f (xi )
4. Compare the absolute relative approximate error with the pre-specified relative error tolerance,
s . If a > s , then go to Step 2, else stop the algorithm. Also, check if the number of
iterations has exceeded the maximum number of iterations allowed. If so, one needs to
terminate the algorithm and notify the user.
f (x)
f (xi+1)
θ
x
xi+2 xi+1 xi
f ( xi )
xi +1 = xi −
f ( xi )
Pilih i = 0,
x0 = 3
f ( x0 ) = x0 − 4
2
= 32 − 4
=5
f ( x0 ) = 2 x0
= 23
=6
Jadi,
f ( x0 )
x1 = x0 −
f ( x0 )
5
= 3−
6
= 2.166
BAB III Sistem Persamaan Linear
Salah satu metode yang sangat popular untuk menyelesaikan persamaan pada sistem liner dengan metode
numerik adalah menggunakan eliminasi gauss. Pendakatan yang dilakukan untuk menyelesaikan
persamaan adalah sebagai berikut ini dengan set n persamaan dan variabel n yang tidak diketahui.
a11x1 + a12 x2 + a13 x3 + ... + a1n xn = b1
. .
. .
Forward Elimination of Unknowns: In this step, the unknown is eliminated in each equation starting with
the first equation. This way, the equations are reduced to one equation and one unknown in each
equation.
Back Substitution: In this step, starting from the last equation, each of the unknowns is found.
In the first step of forward elimination, the first unknown, x1 is eliminated from all rows below the first row.
The first equation is selected as the pivot equation to eliminate x1 . So, to eliminate x1 in the second
equation, one divides the first equation by a11 (hence called the pivot element) and then multiplies it by
a 21 . This is the same as multiplying the first equation by a 21 / a11 to give
a 21 a a
a 21 x1 + a12 x 2 + ... + 21 a1n x n = 21 b1
a11 a11 a11
Now, this equation can be subtracted from the second equation to give
a a a
a 22 − 21 a12 x2 + ... + a 2 n − 21 a1n xn = b2 − 21 b1
a11 a11 a11
or
where
a21
= a22 −
a22 a12
a11
a21
a2 n = a2 n − a1n
a11
This procedure of eliminating x1 , is now repeated for the third equation to the n th equation to reduce the
set of equations as
x2 + a23
a22 x3 + ... + a2 n xn = b2
x2 + a33
a32 x3 + ... + a3 n xn = b3
. . .
. . .
. . .
This is the end of the first step of forward elimination. Now for the second step of forward elimination, we
start with the second equation as the pivot equation and a22 as the pivot element. So, to eliminate x 2 in
.
(the pivot element) and then multiply it by a32
the third equation, one divides the second equation by a22
This is the same as multiplying the second equation by / a22
a32 and subtracting it from the third equation.
This makes the coefficient of x 2 zero in the third equation. The same procedure is now repeated for the
fourth equation till the n th equation to give
a11 x1 + a12 x2 + a13 x3 + ... + a1n xn = b1
x2 + a23
a22 x3 + ... + a2 n xn = b2
. .
. .
. .
The next steps of forward elimination are conducted by using the third equation as a pivot equation and
so on. That is, there will be a total of n − 1 steps of forward elimination. At the end of n − 1 steps of
forward elimination, we get a set of equations that look like
. .
. .
(n −1)
a nn xn = bn(n −1)
Back Substitution:
Now the equations are solved starting from the last equation as it has only one unknown.
bn( n −1)
xn = ( n −1)
a nn
Then the second last equation, that is the (n − 1) th equation, has two unknowns: x n and xn−1 , but x n is
already known. This reduces the (n − 1) th equation also to one unknown. Back substitution hence can
be represented for all equations by the formula
j =i +1
xi = for i = n − 1, n − 2, ,1
aii(i −1)
and
bn( n −1)
x n = ( n −1)
a nn
BAB IV Differensiasi Numerik
Nilai turunan dari y dengan metode Eular didapatkan dari mengekstrapolasi garis linier diinterval
h, sehingga semakin banyak interval nilai h maka semakin besar error yang didapatkan.
Langkah-Langkah
Contoh Program :
clear all
clc
format long
%solusi y
y(1)=y0+h*(-2*x0^3+12*x0^2-20*x0+8.5);
for i=2:N
k=i-1
y(i)=y(k)+h*(-2*x(k)^3+12*x(k)^2-20*x(k)+8.5);
end
%solusi analitik
for i=1:N
w(i)=-0.5*x(i)^4+4*x(i)^3-10*x(i)^2+8.5*x(i)+1;
end
Plot (x,y,x,w);
The finite difference method is used to solve ordinary differential equations that have conditions
imposed on the boundary rather than at the initial point. These problems are called boundary-
value problems. In this chapter, we solve second-order ordinary differential equations of the
form
d2y
= f ( x, y, y ' ), a x b , (1)
dx 2
with boundary conditions
Many academics refer to boundary value problems as position-dependent and initial value
problems as time-dependent. That is not necessarily the case as illustrated by the following
examples.
The differential equation that governs the deflection y of a simply supported beam under
uniformly distributed load (Figure 1) is given by
d 2 y qx( L − x )
= (3)
dx 2 2 EI
where
x = location along the beam (in)
E = Young’s modulus of elasticity of the beam (psi)
I = second moment of area (in4)
q = uniform loading intensity (lb/in)
y ( x = 0) = 0 (4)
y ( x = L) = 0
Clearly, these are boundary values and hence the problem is considered a boundary-value
problem.
Figure 1 Simply supported beam with uniform distributed load.
Now consider the case of a cantilevered beam with a uniformly distributed load (Figure 2). The
differential equation that governs the deflection y of the beam is given by
d 2 y q( L − x ) 2
= (5)
dx 2 2 EI
where
x = location along the beam (in)
E = Young’s modulus of elasticity of the beam (psi)
I = second moment of area (in4)
q = uniform loading intensity (lb/in)
y ( x = 0) = 0 (6)
dy
( x = 0) = 0
dx
Clearly, these are initial values and hence the problem needs to be considered as an initial
value problem.
Figure 2 Cantilevered beam with a uniformly distributed load.
Example 1
The deflection y in a simply supported beam with a uniform load q and a tensile axial load T is
given by
d 2 y Ty qx( L − x)
− = (E1.1)
dx 2 EI 2 EI
where
x = location along the beam (in)
T = tension applied (lbs)
E = Young’s modulus of elasticity of the beam (psi)
I = second moment of area (in4)
q = uniform loading intensity (lb/in)
Given,
a) Find the deflection of the beam at x = 50" . Use a step size of x = 25" and approximate the
derivatives by central divided difference approximation.
Solution
a) Substituting the given values,
d2y
2
− 2 10−6 y = 7.5 10−7 x(75 − x) (E1.2)
dx
d2y
Approximating the derivative at node i by the central divided difference approximation,
dx 2
yi +1 − 2 yi + yi −1
− 2 10 −6 yi = 7.5 10 −7 xi (75 − xi ) (E1.4)
(x) 2
x0 = 0
x1 = x0 + x = 0 + 25 = 25
x 2 = x1 + x = 25 + 25 = 50
x3 = x2 + x = 50 + 25 = 75
y1 = 0 (E1.5)
y 3 − 2 y 2 + y1
2
− 2 10 −6 y 2 = 7.5 10 −7 x 2 (75 − x 2 )
(25)
y 4 − 2 y3 + y 2
2
− 2 10 −6 y3 = 7.5 10 −7 x3 (75 − x3 )
(25)
0.0016y 2 − 0.003202y3 + 0.0016y 4 = 7.5 10−7 (50)(75 − 50)
y4 = 0 (E1.8)
Equations (E1.5-E1.8) are 4 simultaneous equations with 4 unknowns and can be written in
matrix form as
1 0 0 0 y1 0
0.0016 − 0.003202 0.0016 0
y 9.375 10 − 4
2 =
0 0.0016
− 0.003202 0.0016 y 3 9.375 10 −4
0 0 0 1 y 4 0
The above equations have a coefficient matrix that is tridiagonal (we can use Thomas’ algorithm
to solve the equations) and is also strictly diagonally dominant (convergence is guaranteed if we
use iterative methods such as the Gauss-Siedel method). Solving the equations we get,
y1 0
y
2 = − 0.5852
y 3 − 0.5852
y 4 0
y (50) = y ( x 2 ) y 2 = −0.5852"
The exact solution of the ordinary differential equation is derived as follows. The homogeneous
part of the solution is given by solving the characteristic equation
m 2 − 2 10 −6 = 0
m = 0.0014142
Therefore,
y p = Ax 2 + Bx + C
d2
2
( Ax 2 + Bx + C ) − 2 10−6 ( Ax 2 + Bx + C ) = 7.5 10−7 x(75 − x)
dx
− 2 10 −6 A = −7.5 10 −7
− 2 10 −6 B = −5.625 10 −5
2 A − 2 10 −6 C = 0
Solving the above equation gives
A = 0.375
B = −28.125
C = 3.75 10 5
The particular solution then is
y ( x = 0) = 0
y ( x = 75) = 0
K1 + K 2 = −3.75 105
1 1 K1 − 3.75 105
1.1119 0.89937 K = 5
2 − 3.75 10
A number of different numerical methods may be utilized to solve this system of equations such
as the Gaussian elimination. Using any of these methods yields
K1 − 1.775656226 105
K = 5
2 − 1.974343774 10
Substituting these values back into the equation gives
y = 0.375x 2 − 28.125x + 3.75 105 − 1.775656266 105 e 0.0014142x − 1.974343774 105 e −0.0014142x
Unlike other examples in this chapter and in the book, the above expression for the deflection of
the beam is displayed with a larger number of significant digits. This is done to minimize the
round-off error because the above expression involves subtraction of large numbers that are
close to each other.
b) To calculate the relative true error, we must first calculate the value of the exact solution at
y = 50 .
Et = −0.5320 − (−0.5852)
Et = 0.05320
True Error
t = 100%
True Value
0.05320
t = 100%
− 0.5320
t = −10%
Daftar Pustaka