Professional Documents
Culture Documents
x5
x1 x3 x4 x2
Example:
f(x) = tg x – x – 1 = 0
Solution:
Dihitung nilai f(x) pada interval antara dua titik: x1
= 1 dan x2 = 1.5
xt=(1+1.5)/2=1.25
f(1.25)= tg (1.25*/180)-1.25-1= 0.75957
Y
FX = 0 ?
N N ABS (FXT)
< 0.001
xt = (x1+x2)/2
FX = F(xt) . F(x1)
Y Y
FX > 0 ? Selesai
N x1 = xt
FXT = F(x1)
A
! metode setengah interval x1=0
f(x)=tan(x)-x-1. x2=x1+dx goto 5
open (5,file='setint.has') 10 x1=x2
i=0 x2=x1+dx
dx=0.5 5 write(*,3)x1,x2 fx=f(x1)*f(x2)
if(fx.gt.0.)goto 10 30 xt=(x1+x2)/2
i=i+1
fx=f(xt)*f(x1
)
write(5,2)i,x1,x2,xt,f(x1),f(x2),f(xt)
if(fx.gt.0)goto 15
x2=xt
fxt=f(x2)
goto 20
15 x1=xt
fxt=f(x1)
20 if(abs(fxt).lt.0.0001)goto 25
goto 30
2 format(i2,6f10.5)
3 format(2f5.2)
25 stop
end
2. Metode Interpolasi Linear
• Asumsi awal x1 dan x2 f(x)
• f(x1)*f(x2) < 0
f(x2
)
f(x2) – f(x1)
X1
X2
X
*
X2 – X*
x2 x* X2 – X1
x* x2
f (x2 )
(x 2 x1 )
f (x 2 ) f (x1 )
f (x2 )
x2 f (x2 ) f (x1)
x1
Example:
f(x)= x3+x2-3x-3=0
Solution:
Asumsi dua titik awal:
x1=1 f(1)= 13+12-3*1-3 = -4
x2=2 f(2)= 23+22-3*2-3 = 3
f (x2 )
x* x2 (x 2 x1 )
f (x 2 ) f (x1 )
x* 2 3
(2 1.57142
3 1)
(4)
f(1.57142)= (1.57142)3+(1.57142)2-3*(1.57142)-3 = -1.36449
Interval berikutnya adalah: x2= 2 dan x3= 1.57142
! proggam 2.2 xb=x2-(f(x2)*(x2-x1))/(f(x2)-f(x1))
! program metode interpolasi linier write(5,2)i,x1,x2,xb,f(x1),f(x2),f(xb)
f(x)=x**3+x**2-3.*x-3. fx=f(xb)*f(x1)
open(5,file='interlin.has') if(fx.gt.0.)goto 15
i=0 x2=xb
dx=1 fxb=f(x2)
x2=x1+dx goto 20
goto 5 15 x1=xb
10 x1=x2 fxb=f(x1)
x2=x1+dx 20if(abs(fxb).lt.0.0001)goto 25
5 write(*,3)x1,x2 goto 30
fx=f(x1)*f(x2) 2 format(i2,6f10.5)
if(fx.gt.0.)goto 10 3 format(2f5.2)
30 i=i+1 25 stop
end
1 1.00000 2.00000 1.57143 -4.00000 3.00000 -1.36443
2 1.57143 2.00000 1.70541 -1.36443 3.00000 -.24774
3 1.70541 2.00000 1.72788 -.24774 3.00000 -.03934
4 1.72788 2.00000 1.73140 -.03934 3.00000 -.00611
5 1.73140 2.00000 1.73195 -.00611 3.00000 -.00095
6 1.73195 2.00000 1.73204 -.00095 3.00000 -.00015
7 1.73204 2.00000 1.73205 -.00015 3.00000 -.00002
3. Metode Newton Rhapson
• Asumsi awal xi
• Ditarik garis singgung pada xi
•Titik potong garis singgung
f(xi
dengan sb x adalah perkiraan A
)
nilai akar f(x)
f(xi) - 0
B
xi+1 xi
f(x)
Xi – Xi+1
• INGAT! Garis singgung pada titik xi adalah
turunan pertama f(xi) f’(xi) y2 y
f '( xi ) m 1
f (xi ) 0 x x
f '( xi )
2 1
xi x i 1 x x 1
y1
2
m
f ( xi )
x i 1 x i x1m y1
f '(x i) x2 m
f(xi) A
f(xi) - 0
B
xi+1 xi
f(x)
Xi – Xi+1
Example:
f(x)= x3+x2-3x-3=0
Solution:
Turunan pertama:
f’(x)= 3x2+2x-3
Pada hitungan awal ditentukan sembarang nilai xi,
misal xi=1 f(1) = -4; f’(1) = 2
4
f (xi ) x 1 3
x i1 xi
f '(x i ) 2
2
Langkah berikutnya nilai x2=3, digunakan untuk hitungan
iterasi berikutnya.
! Program metode Newton Rhapson
f(x)=x**3.+x**2-3.*x-3.
fx(x)=3*x**2+2*x-3
open(5,file='repson.doc')
i=0
x1=1
! x2=x1+1
30 i=i+1
! fx=(f(x2)-f(x1))/(x2-x1)
xt=x1-f(x1)/fx(x1)
! i=i+1
5 write(5,2)i, x1, xt, f(x1), f(xt)
x1=xt
if (abs(f(xt)).lt.0.0001)goto 25
goto 30
2 format (i2, 6f10.5)
3 format (2f5.2)
25 stop
end
1 1.00000 3.00000 -4.00000 24.00000
2 3.00000 2.20000 24.00000 5.88800
3 2.20000 1.83015 5.88800 .98900
4 1.83015 1.73780 .98900 .05457
5 1.73780 1.73207 .05457 .00020
6 1.73207 1.73205 .00020 .00000
4. Metode Secant
• Asumsi awal x1 dan x2
• Ditarik garis singgung pada yang menghubungkan x1 dan
x2
•Titik potong garis singgung dengan sb x adalah
f(xi perkiraan nilai akar f(x)
) A
f(xi) - f(xi-1)
f(xi-1) B
xi-1 xi
f(x)
Xi – Xi-1
Kemiringan garis singgung atau f’(xi) dapat dituliskan sebagai
f (xi ) f (x) x f (
f '(xi ) i1
Substitusi ke x i1
xi xi1
f (xi )(x
Didapat xi1 xi
f(xi
) A
f(xi) - f(xi-1)
f(xi-1) B
xi-1 xi
f(x)
Xi – Xi-1
Example:
f(x)= x3+x2-3x-3=0
Solution:
Asumsi dua titik awal:
x1=1 f(1)= 13+12-3*1-3 = -4
x2=2 f(2)= 23+22-3*2-3 = 3
f (x i )(xi xi1) 3(2
xi1 xi x3 2 1)
f (x i ) f (xi1)
1,57142
3
(4)
Langkah berikutnya nilai xi=1.57142 dan xi-1=2 digunakan
untuk hitungan iterasi berikutnya.
! program 2.4
! program metoda secant
f(x)=x**3+x**2-3.*x-3.
open(5,file='secant.has')
i=0
x1=1.
x2=x1+1
30 i=i+1
fx=(f(x2)-f(x1))/(x2-x1)
xt=x2-f(x2)/fx
! i=i+1
write(5,2)i,x1,x2,xt,f(x1),f(x2),f(xt)
x1=x2
x2=xt
if(abs(f(xt)).lt.0.0001)goto 25
goto 30
2 format(i2,6f10.5)
! format(2f5.2)
25 stop
end
1 1.00000 2.00000 1.57143 -4.00000 3.00000 -1.36443
2 2.00000 1.57143 1.70541 3.00000 -1.36443 -.24774
3 1.57143 1.70541 1.73514 -1.36443 -.24774 .02926
4 1.70541 1.73514 1.73200 -.24774 .02926 -.00051
5 1.73514 1.73200 1.73205 .02926 -.00051 .00000
5. Metode Iterasi
• Digunakan suatu persamaan x = g(x) yang
dikembangkan dari fungsi f(x)=0, untuk
memperkirakan nilai akar. Ex: f(x) = x3+x2-3x-3=0
ditulis menjadi x = 1/3(x3+x2-3)
• xi+1 = g(xi)
xi1 x
a i
Example:
f(x) = x3+x2-3x-3=0
Solution:
x3= -x2+3x+3
x = (-x2+3x+3)1/3 xi+1 = (-xi2+3xi +3)1/3
Asumsi nilai awal x1=2, maka:
x2 = (-22+3*2 +3)1/3 = 1.70998
• Upload Quis:
• A4:https://drive.google.com/drive/folders/19lOe0QUt5-
2w4Y1PeiMULWdbJOZJmiMl?usp=sharing
• A5:https://drive.google.com/drive/folders/1xEu0qqWROlbLApbPgWEQsYZ5
cvdnEqKx?usp=sharing
Midtest 26 Oktober