100% found this document useful (1 vote)
23 views16 pages

Week9 Taylor and Lagrange

The document discusses techniques for curve fitting including regression and interpolation/extrapolation. It provides examples of polynomial forms used for interpolation and extrapolation, such as Taylor polynomials, Maclaurin polynomials, and calculating coefficients from derivatives evaluated at specific points. Examples are given of generating Taylor polynomials to approximate functions and evaluating them at different points for comparison.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
23 views16 pages

Week9 Taylor and Lagrange

The document discusses techniques for curve fitting including regression and interpolation/extrapolation. It provides examples of polynomial forms used for interpolation and extrapolation, such as Taylor polynomials, Maclaurin polynomials, and calculating coefficients from derivatives evaluated at specific points. Examples are given of generating Taylor polynomials to approximate functions and evaluating them at different points for comparison.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Pencocokan curva (curve fitting)

Teknik pecocokan kurva


1. Regresi
2. Interpolasi dan ekstrapolasi

1
Interpolasi dan ekstrapolasi

2
Interpolasi dan ekstrapolasi

3
Interpolasi dan ekstrapolasi

1. Polinom Taylor
2. Polinom Lagrange
3. Interpolasi Newton
4. Interpolasi kubik

4
Taylor and Maclaurin polynomials
Taylor series for a general function f(x) expanded around x=a:

p( x ) = f (a ) +
( x − a)
f ′(a ) +
( x − a)
2
f ′′(a ).... +
( x − a)
n
f (n ) (a ) + ....
1! 2! n!

f (k ) (a )
=∑ ( x − a) k
k =0 k!

Note it is not necessary to choose x=0 as the point around which


the expansion is done.
Maclaurin series for a general function f(x):

x x2 x n (n ) ∞
f (k ) (0 ) k
p (x ) = f (0 ) + f ′(0 ) + f ′′(0 ).... + f (0) + .... = ∑ x
1! 2! n! k =0 k!
x x2 x n (n ) ∞
f (k ) (0 ) k
Maclaurin: p(x ) = f (0) + 1 ! f ′(0) + 2 ! f ′′(0).... + n ! f (0) + .... = ∑ k! x
k =0

To generate a Maclaurin or Taylor polynomial of degree n:


- Differentiate f(x) up to the nth derivative
- Evaluate each derivative at x=a (Taylor) or x=0 (Maclaurin)
n
- Coefficient of xn is f (a ) (Taylor) or f (0) (Maclaurin)
n

n! n!
For a Taylor series do not expand the (x-a)n factors
Example: fifth order Maclaurin polynomial for f ( x ) = sin x
f ( x ) = sin x f (0) = sin 0 = 0 ∞
(−1) k 2 k +1
f ′( x ) = cos x f ′(0 ) = cos 0 = 1 sin( x) = ∑ x
f ′′( x ) = − sin x f ′′(0 ) = − sin 0 = 0 k = 0 ( 2k + 1)!

f (3) ( x ) = − cos x f (3) (0) = − cos 0 = −1


f ( 4 ) ( x ) = sin x f ( 4 ) (0) = sin 0 = 0
f (5) ( x ) = cos x f (5) (0) = cos 0 = 1
x3 x5
Substitute into general form (top of slide) p5 ( x ) = x − +
3! 5! 6
Third degree Taylor ( x − a) ( x − a )2 ( x − a )n (n )
p ( x ) = f (a ) + f ′(a ) + f ′′(a ).... + f (a ) + ....
1! 2! n!
polynomial for
f ( x ) = x + 5 near x=4. Evaluate at x=5 and compare with f(5)

f (x) = x + 5 f (4 ) = 4 + 5 = 3
f ′( x ) = 12 ( x + 5)−1 2 f ′(4) = 12 (9)−1 2 = 21.3 = 16

f ′′( x ) = − 14 ( x + 5)−3 2 f ′′(4) = − 14 (9)−3 2 = − 4.133 = − 108


1

f (3) ( x ) = 83 ( x + 5)
−5 2
f (3) ( x ) = 83 (9)
−5 2
= 8.335 = 1
648

1 ( x − 4 )2 + 1 ( x − 4 )3
p3 ( x ) = 3 + 16 ( x − 4 ) − 2×108 6×648

1 ( x − 4 )2 + 1 ( x − 4 )3
= 3 + 16 ( x − 4 ) − 216 3888

1 (5 − 4 )2 + 1 (5 − 4 )3
Evaluate at x=5: p3 (5) = 3 + 16 (5 − 4 ) − 216 3888
= 3 + 16 − 216
1 + 1 = 3.1623
3888

(compare with f (5) = 5 + 5 = 10 = 3.1622 )


7
( x − a) ( x − a )2 ( x − a )n (n )
Fourth order Taylor p( x ) = f (a ) + 1! f ′(a ) + 2 ! f ′′(a ).... + n ! f (a ) + ....
polynomial for
f ( x ) = ln x near x=1.

f ( x ) = ln x f (1) = ln 1 = 0

f ′( x ) = 1x f ′(1) = 11 = 1
f ′′( x ) = − x12 f ′′(1) = − 11 = −1

f ( 3) ( x ) = 2
x3
f (3) (1) = 12 = 2
f ( 4)
(x ) = −6 f ( 4 ) (1) = −6
1 = −6
x4
p4 ( x ) = 0 + 11! ( x − 1) − 21! ( x − 1)2 + 32! ( x − 1)3 − 46! ( x − 1) 4

p4 ( x ) = ( x − 1) − 12 ( x − 1)2 + 13 ( x − 1)3 − 14 ( x − 1) 4

(−1) k −1
ln x = ∑ ( x − 1) k
k =1 k 8
Third order Taylor ( x − a) ( x − a )2 ( x − a )n (n )
p ( x ) = f (a ) + f ′(a ) + f ′′(a ).... + f (a ) + ....
polynomial for 1! 2! n!
πx
f ( x ) = sin at x=3.
12
πx 3π π 1
f ( x ) = sin f (3) = sin = sin =
12 12 4 2
π πx π π π
f ′( x ) = cos f ′(3) = cos =
12 12 12 4 12 2
π2 πx π2 π π2
f ′′( x ) = − sin f ′′(3) = − sin =−
144 12 144 4 144 2

π3 πx π3 π π3
f ( 3)
(x ) = − cos f ( 3)
(3) = − cos = −
1728 12 1728 4 1728 2
1 π π2 2 π3
p3 ( x ) = + ( x − 3) − ( x − 3) + ( x − 3)3
2 12 2 288 2 10368 2

9
2 n
Taylor polynomial of p( x ) = f (a ) + ( x − a ) ( x − a ) ( x − a )
f ′(a ) + f ′′(a ).... + f (n ) (a ) + ....
degree four for 1! 2! n!

1
( )
f x = at x=1 and evaluate at x= ½ .
x
1 1
f (x) = f (1) = = 1
x 1
1 1
f ′( x ) = − 2 f ′(1) = − = −1
x 1
2
f ′′( x ) = 3 f ′′(1) = 2
x
6 f (3) (1) = −6
f ( 3) ( x ) = −
x4

f ( 4) 24
(x ) = 5 f ( 4 ) (1) = 24
x
2
p4 ( x ) = 1 − ( x − 1) + ( x − 1)2 − 6 ( x − 1)3 + 24 ( x − 1) 4
2! 3! 4!
p4 ( x ) = 1 − ( x − 1) + ( x − 1)2 − ( x − 1)3 + ( x − 1) 4

When x = ½ p4 (2 ) = 1 + 2 + 4 + 8 + 16 = 116 = 1.9375


1 1 1 1 1 15
10
Polinom Lagrange

11
Polinom Lagrange

12
Polinom Lagrange
Polinom Lagrange
Polinom Lagrange
Polinom Lagrange

Cari sendiri L3(x)

You might also like