Deret dan Aproksimasi
Deret MacLaurin Deret Taylor
Tujuan
• Kenapa perlu perkiraan?
– Perkiraan dibentuk dari fungsi paling sederhana – polynomial.
– Kita bisa mengintegrasikan dan mendiferensiasi dengan – Kita bisa mengintegrasikan dan mendiferensiasi dengan
mudah.
– Kita bisa gunakan saat kita tidak tahu fungsi sebenarnya.
Polynomial Approximations
• Misalkan kita ingin membuat perkiraan untuk sebuah fungsi yang kompleks pada sekitar x = 0;
• Perkiraan paling simple adalah menentukan sebuah konstanta, sehingga:
0 0
( x ) a
p =
• Catatan: perkiraan di atas disebut sebagai zero’th order polynomial approximation;
• Lalu, nilai berapa yang harus kita berikan pada konstanta itu?
0 0
( x ) a
p =
Polynomial Approximations
• Kita inginkan angka paling akurat pada x = 0.
• Sehingga: ( ) (0)
0 x f
p =
2 f(x)
-1 -0.5 0 0.5
0.5 1 1.5
x y
p(x)
Polynomial Approximations
• Contoh
x x
f = −
1 ) 1
(
1 )
( 1 1
) 1 0
( = = ⇒ p
0x =
f
Polynomial Approximations
1 . 5
2 f(x)
Kurang akurat Tidak akurat
-1 -0 . 5 0 0 . 5
0 . 5 1
x y
p0(x)
Sangat akurat
Polynomial Approximations
• Sekarang kita tingkatkan dengan perkiraan dengan menggunakan aproksimasi linier (1st order approximation);
x a
a x
p
1( ) =
0+
1• Sekarang kita pilih nilai sehingga perpotongan dan garis nya semirip mungkin dengan fungsi sebenarnya.
Polynomial Approximations
• Menyamakan perpotongan:
• Menyamakan slope:
) 0 (
) 0 ( 0
) 0 ( )
0 (
0
1 0
1
f a
f a
a f
p
=
⇒
=
× +
⇒
=
• Menyamakan slope:
• Sehingga polinom nya:
) 0 ( )
0 ( )
0
( 1
1 f a f
p′ = ′ ⇒ = ′
x f
f
p1(0) = (0) + ′(0)
Polynomial Approximations
• Contoh
x x
f = −
1 ) 1
(
x a a
x
p1( ) = 0 + 1
1 1 (0) 1
0 1
) 1 0
( = ⇒ 0 = =
= − a f
f
(
1)
1 (0) 1) 1 0
( 2 = ⇒ 1 = ′ =
= −
′ a f
f x
x x
p = +
⇒ 1( ) 1
Ingat, Metode Newton Raphson
( ) ( )
tangent = =
= −
dy
dx f f x f xi
'
' 0
f(xi)
tangent
( ) ( ) ( ) ( )
= −
−
= −
+
+
f x f x
x x rearrange
x x f x
f x
i
i
i i
i i
i i
'
'
0
1
1
xi xi+1
1.5
2 f(x)
Polynomial Approximations
1.5
2 f(x)
p1(x)
Masih ‘lumayan’ sampai disini
-1 -0.5 0 0.5
0.5 1
x y
p0(x)
-1 -0.5 0 0.5
0.5 1
x y
p0(x)
Polynomial Approximations
• Sekarang coba dengan perkiraan kuadratik:
• Kita inginkan perpotongan, gradient dan kurva
2 2
1 0
2
( x ) a a x a x
p = + +
• Kita inginkan perpotongan, gradient dan kurva (turunan kedua) dari perkiraan kita dapat match dengan fungsi sebenarnya pada x = 0.
Polynomial Approximations
• Menyamakan perpotongan:
• Menyamakan kemiringan:
) 0 (
) 0 ( 0
0 )
0 ( )
0 (
0
2 2
1 0
2
f a
f a
a a
f p
=
⇒
=
× +
× +
⇒
=
• Menyamakan kemiringan:
) 0 ( 0
2 )
0 ( )
0
( 1 2
2 f a a f
p′ = ′ ⇒ + × = ′
Polynomial Approximations
• Mencocokkan kurva (turunan ke 2):
• Memberikan polinom
) 0 2 (
1
) 0 ( 2
) 0 ( )
0 (
2 2 2
f a
f a
f p
= ′′
⇒
= ′′
′′ ⇒
′′ =
• Memberikan polinom
2
2 (0)
2 ) 1
0 ( )
0 ( )
(x f f x f x
p = + ′ + ′′
Polynomial Approximations
• Contoh
• Dari sebelumnya:
x x
f = −
1 ) 1
(
2 2 1
0
2 (x) a a x a x
p = + +
1 ,
1 =
= a
• Dari sebelumnya: aa0 = a1, 1 = 1
( )
1
2 )
0 ( 1 2
) 2 (
2
3 2
=
⇒
′ =
=
− ⇒
′′ = a
f x a
x f
2
2 (x) 1 x x
p = + +
⇒
Polynomial Approximations
1.5
2 f(x)
p1(x) 1.5
2
y
f(x)
p1(x) p2(x)
Lebih ‘lumayan’ lagi ya..
-1 -0.5 0 0.5
0.5 1
x y
p0(x)
-1 -0.5 0 0.5
0.5 1
x y
p0(x)
Polynomial Approximations
• Kita bisa teruskan penaksiran secara polinom hingga n derajad.
• Kalau kita teruskan, kita akan mendapatkan rumus:
) 0 ( )
0 ( )
( )
( x p x f f x
f ≈ = + ′
) ! 0
! ( ) 2
0 (
) 0 ( )
0 ( )
( )
(
) ( 2
n f x
f x
x f
f x
p x
f
n n
n
+
′′ + +
+ ′
=
≈
K
Polynomial Approximations
• Akurasi perkiraan akan bertambah seiring dengan penambahan polinom;
• Kita lihat polinom derajad 0, 1, 2 dan 6 (warna hijau), dibanding fungsi asli nya f(x) (warna biru).
Polynomial Approximations
1.5 2
y
f(x)
p1(x) p2(x) p6(x)
-1 -0.5 0 0.5
0.5 1
x
p0(x)
Maclaurin (Power) Series
• Deret Maclaurin adalah penaksiran polinom derajad tak hingga
K
K + +
′′ + +
+ ′
=
) ! 0
! ( ) 2 0 (
) 0 ( )
0 ( )
(
) ( 2
n f x
f x
x f
f x
f
n n
• Notice: Deret infinite (tak hingga) menyatakan bahwa
akhirnya deret ini sama dengan fungsi sebenarnya, bukan penaksiran lagi!
!
!
2 n
Taylor Series
• Sesungguhnya, kita bisa membuat deret polinom yang berasal dari titik
• Dari awal kita selalu memulai perkiraan pada nilai x = 0
deret polinom yang berasal dari titik manapun. x = x0
• Ini disebut Taylor Series.
• Jadi, Deret MacLaurin merupakan Deret Taylor yang berpusat pada x0=0
Taylor Series
• Rumus umum Deret Taylor:
−
′′ − +
′ − +
=
) (
! 2
) ) (
( )
)(
( )
( )
(
2 0 0
0 0
0
x x
x x x
f x
x x
f x
f x
f
n
K
K − +
+
+ !
) ) (
( 0 0
) (
n x x x
f
n n
∑
∞=
= −
0
0 0
) (
! ) ) (
(
n
n n
n x x x
f
Taylor Series
• Approximate function? Copy derivatives!
0.0 0.5 1.0
f(x)=sin(2πx) What is f(x) near x=0.35?
0.00 0.25 0.50 0.75 1.00
-1.0 -0.5 0.0
X
f(x)=sin(2
0.0 0.5 1.0
f(x)=sin(2πx)
Taylor Series
• Approximate function? Copy derivatives!
What is f(x) near x=0.35?
0
( ) (0.35) T x = f
0.00 0.25 0.50 0.75 1.00
-1.0 -0.5 0.0
X
f(x)=sin(2
0
0.0 0.5 1.0
f(x)=sin(2πx)
Taylor Series
• Approximate function? Copy derivatives!
( )
1
( ) (0.35) T x = f
What is f(x) near x=0.35?
0.00 0.25 0.50 0.75 1.00
-1.0 -0.5 0.0
X
f(x)=sin(2
( )
'(0.35) 0.35
f x
+ −
0.0 0.5 1.0
f(x)=sin(2πx)
Taylor Series
• Approximate function? Copy derivatives!
( )
2
( ) (0.35) T x = f
What is f(x) near x=0.35?
0.00 0.25 0.50 0.75 1.00
-1.0 -0.5 0.0
X
f(x)=sin(2
( )
( )
21 2
'(0.35) 0.35 ''(0.35) 0.35
f x
f x
+ −
+ −
0.0 0.5 1.0
f(x)=sin(2πx)
Taylor Series
• Approximate function? Copy derivatives!
10
( ) T x
( )
2
( ) (0.35) T x = f
What is f(x) near x=0.35?
0.00 0.25 0.50 0.75 1.00
-1.0 -0.5 0.0
X
f(x)=sin(2
( )( )
( )
0
( ) !
i i N
N
i
f a x a
T x
=
i
= ∑ −
( )
( )
21 2
'(0.35) 0.35 ''(0.35) 0.35
f x
f x
+ −
+ − K
0.0 0.5 1.0
f(x)=sin(2πx)
Taylor Series
• Approximate function? Copy derivatives!
( )
1
( ) ( )
T x = f a +
Most Common: 1st Order
0.00 0.25 0.50 0.75 1.00
-1.0 -0.5 0.0
X
f(x)=sin(2
• Look out for “approximate” or “when x is small” or
“small angle” or “close to” %
( )
'( )
f a x − a
Contoh – Taylor Series
• Bentuklah Deret Taylor untuk:
1 ),
ln(
)
(x = x x0 = f
• Cari nilai fungsi dan turunannya untuk fungsi pada x0=1
Contoh – Taylor Series
0 )
1 ln(
) ( )
ln(
)
(x = x ⇒ f x0 = =
f
1 1 ) 1
1 ( )
( = ⇒ ′ 0 = =
′ f x
x x f
1 1 ) 1
1 ( )
( = − 2 ⇒ ′′ 0 = − 2 = −
′′ f x
x x f
1 1
0 ) (
1 )
(
) 1 ( )!
1 1 (
) 1 ( )!
1 ) (
(
) 1 ( )!
1 ) (
(
− −
−
−
−
− =
= −
⇒
−
= −
n n
n n
n
n n
n n x
f
x x n
f M
1 2 ) 2
2 ( )
( = 3 ⇒ ′′′ 0 = 3 =
′′′ f x
x x f
Contoh – Taylor Series
• Gunakan Rumus Umum Deret Taylor:
−
−1) 2!( 1)
(x 2 x 3
K
K − +
+ +
′′ − +
′ − +
=
! ) ) (
(
! 2
) ) (
( )
)(
( )
( )
(
0 0
) (
2 0 0
0 0
0
n x x x
f
x x x
f x
x x
f x
f x
f
n n
K
K − +
−
− +
+
+ −
− −
− +
=
⇒
−
! ) 1 ) (
1 ( )!
1 (
! 3
) 1 (
! 2
! 2
) 1 ) (
1 (
0 )
ln(
1
3 2
n n x
x x x
x
n n
K
K − +
− + +
+ −
− −
−
=
⇒
−
n x
x x x
x
n
n ( 1)
) 1 (
3 ) 1 (
2 ) 1 ) (
1 (
) ln(
1
3 2
Truncated Taylor Series
• We cannot evaluate a Taylor series – it is infinite!
• Kita bisa memutuskan untuk membuat perkiraan dari sebuah fungsi hingga n (derajat) tertentu yang tidak tak terhingga;
• Kita sebut sebagai Truncated Taylor Series.
• Kita sebut sebagai Truncated Taylor Series.
Truncated Taylor Series
• To find an nth order truncated Taylor series
• Note: This is the same concept as the polynomial
! ) ) (
(
! 2
) ) (
( )
)(
( )
( )
(
0 0
) (
2 0 0
0 0
0
n x x x
f
x x x
f x
x x
f x
f x
f
n
n −
+ +
′′ − +
′ − +
≈
K
• Note: This is the same concept as the polynomial approximations we introduced earlier.
Example – Truncated Taylor Series
• Find a cubic (degree 3) truncated Taylor series for the function:
) 2 cos(
)
(x x
f =
centered at:
4
= π
x
Example – Truncated Taylor Series
• For a degree 3 approximation:
! 3
) ) (
! ( 2
) ) (
(
) )(
( )
( )
(
3 0 0
2 0 0
0 0
0
x x x
x f x x
f
x x
x f
x f
x f
′′′ −
− + + ′′
′ − +
≈
• So we need to evaluate the function and its first three derivatives at the center.
! ) 3
! ( ) 2
(x0 f x0
f ′′ + ′′′
+
Example – Truncated Taylor Series
• Evaluating these:
2 2 sin 4 2
) 2 sin(
2 )
(
2 0 4 cos
) 2 cos(
) (
−
=
−
=
′
⇒
−
′ =
=
=
⇒
=
π π
π π
f x
x f
f x
x f
2 8 sin 4 8
) 2 sin(
8 )
(
2 0 cos 4 4
) 2 cos(
4 )
(
2 2 sin 4 2
) 2 sin(
2 )
(
=
=
′′′
⇒
′′′ =
=
−
=
′′
⇒
−
′′ =
−
=
−
=
′
⇒
−
′ =
π π
π π
f x
x f
f x
x f
f x
x f
Example – Truncated Taylor Series
• % which gives:
2 0
) (
! 3
) ) (
! ( 2
) ) (
(
) )(
( )
( )
(
3 0 0
2 0 0
0 0
0
−
×
−
≈
⇒
′′′ −
− + + ′′
′ − +
≈
x π x
f
x x x
x f x x
f
x x
x f x
f x
f
! 3 8 4
! 2 0 4
2 4 0
) (
3 2
−
× +
−
× +
−
×
−
≈
⇒
π
π x
x
x x
f
3
4 3
4 2 4
)
(
−
+
−
−
≈
⇒ π π
x x
x f
Example – Truncated Taylor Series
0.2 0.4 0.6 0.8
1 f(x)
t3(x) ππππ/4
) 2
cos( x p3 (x)
-3 -2 -1 0 1 2 3
-1 -0.8 -0.6 -0.4 -0.2 0 0.2
x y
0 4
= π
x
Series Accuracy
• Kenapa mesti pakai Deret Taylor kalau bisa pakai Maclaurin?
• Perkiraan kita akan makin jauh dari akurat jika semakin jauh dari titik awal x0;
• Kita harus selalu memakai titik awal yang dekat dengan titik yang akan diperkirakan dan juga mudah untuk melakukan yang akan diperkirakan dan juga mudah untuk melakukan perkiraan.