chapter 3 interpolation and polynomial approximation11/8/2012 1 chapter 3 interpolation and...

36
11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ้ามีข้อมูลจากการวัด ซึ่งแทนความสัมพันธ์ของตัวแปรต้นและตัวแปรตาม แล้ว ต้องการทราบค่าตัวแปรตาม ณ จุดอื่นๆ ในช่วงของการวัด ต้องการทราบพฤติกรรมของฟังก์ชันที่แทนข้อมูล Weierstrass , ε >0 , < ,

Upload: others

Post on 05-Mar-2021

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

1

Chapter 3 Interpolation

and Polynomial Approximation

Numerical Analysis

Problem type

ถ้ามีข้อมูลจากการวัด ซึ่งแทนความสัมพันธ์ของตัวแปรต้นและตัวแปรตาม

แล้ว

◦ ต้องการทราบค่าตัวแปรตาม ณ จุดอ่ืนๆ ในช่วงของการวัด

◦ ต้องการทราบพฤติกรรมของฟังก์ชันที่แทนข้อมูล

Weierstrass 𝑓 𝑎, 𝑏 ε > 0 𝑃 𝑎, 𝑏 𝑓 𝑥 − 𝑃 𝑥 < 𝜀 𝑥 ∈ 𝑎, 𝑏

Page 2: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

2

Theory of Weierstrass

O x

y

nx 1x 0x

xf x

xPn x

2x

Interpolation: Overview

𝑓 𝑥 = 𝑒𝑥 𝑃𝑖 𝑥 𝑖

𝑥0 = 0

𝑃0 𝑥 = 1

𝑃1 𝑥 = 1 + 𝑥

𝑃2 𝑥 = 1 + 𝑥 +𝑥2

2

𝑃3 𝑥 = 1 + 𝑥 +𝑥2

2+

𝑥3

6

𝑃4 𝑥 = 1 + 𝑥 +𝑥2

2+

𝑥3

6+

𝑥4

24

𝑃5 𝑥 = 1 + 𝑥 +𝑥2

2+

𝑥3

6+

𝑥4

24+

𝑥5

120

Page 3: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

3

Interpolation: Overview

𝑥 𝑓 𝑥 = 𝑒𝑥 𝑃1 𝑥 𝑃2 𝑥 𝑃3 𝑥 𝑃4 𝑥 𝑃5 𝑥

-2.0 0.13533528 -1.00000000 1.00000000 -0.33333333 0.33333333 0.06666667

-1.5 0.22313016 -0.50000000 0.62500000 0.06250000 0.27343750 0.21015625

-1.0 0.36787944 0.00000000 0.50000000 0.33333333 0.37500000 0.36666667

-0.5 0.60653066 0.50000000 0.62500000 0.60416667 0.60677083 0.60651042

0.0 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000

0.5 1.64872127 1.50000000 1.62500000 1.64583333 1.64843750 1.64869792

1.0 2.71828183 2.00000000 2.50000000 2.66666667 2.70833333 2.71666667

1.5 4.48168907 2.50000000 3.62500000 4.18750000 4.39843750 4.46171875

2.0 7.38905610 3.00000000 5.00000000 6.33333333 7.00000000 7.26666667

Interpolation: Overview

𝑥0 = 1 𝑓 𝑥 =1

𝑥 𝑛

𝑃𝑛 𝑥 = 𝑓 𝑘 1

𝑘 ! 𝑥 − 1 𝑘𝑛

𝑖=0 = −1 𝑘 𝑥 − 1 𝑘𝑛𝑖=0

𝑓 3 𝑃𝑛 𝑥

𝑃𝑛 3 𝑛 0 1 2 3 4 5 6 7

𝑃𝑛 3 1 -1 3 -5 11 -21 43 -85

Page 4: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

4

Lagrange Polynomial

O

y

𝑥

Lagrange Polynomial

2 𝑥0 , 𝑓 𝑥0 𝑥1 , 𝑓 𝑥1 ( )

𝑃 𝑥 =𝑥 − 𝑥1

𝑥0 − 𝑥1𝑓 𝑥0 +

𝑥 − 𝑥0

𝑥1 − 𝑥0𝑓 𝑥1

𝑥 = 𝑥0 𝑃1 𝑥0 =𝑥0−𝑥1

𝑥0−𝑥1𝑓 𝑥0 +

𝑥0−𝑥0

𝑥1−𝑥0𝑓 𝑥1 = 1 ∙ 𝑓 𝑥0

+0 ∙ 𝑓 𝑥1 = 𝑓 𝑥0 𝑥 = 𝑥1 𝑃1 𝑥1 =

𝑥1−𝑥1

𝑥0−𝑥1𝑓 𝑥0 +

𝑥1−𝑥0

𝑥1−𝑥0𝑓 𝑥1 = 0 ∙ 𝑓 𝑥0

+1 ∙ 𝑓 𝑥1 = 𝑓 𝑥1 𝑃1 𝑥

Page 5: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

5

Lagrange Polynomial

𝑥0, 𝑓 𝑥0 𝑥1, 𝑓 𝑥1

𝐿1,0 𝑥 =𝑥−𝑥1

𝑥0−𝑥1 𝐿1,1 𝑥 =

𝑥−𝑥0

𝑥1−𝑥0

𝑥 = 𝑥0 , 𝐿1,0 𝑥0 = 1, 𝐿1,1 𝑥0 = 0 𝑃1 𝑥0 = 𝑓 𝑥0

𝑥 = 𝑥1 , 𝐿1,0 𝑥1 = 0, 𝐿1,1 𝑥1 = 1 𝑃1 𝑥1 = 𝑓 𝑥1

𝐿𝑛 ,𝑘 𝑥

𝐿𝑛 ,𝑘 𝑥𝑖 = 0, 𝑖 ≠ 𝑘1, 𝑖 = 𝑘

𝑘 = 0,1,2, … , 𝑛

Lagrange Polynomial

𝐿𝑛 ,𝑘 𝑥

𝐿𝑛 ,𝑘 𝑥 = 𝑥 − 𝑥0 𝑥 − 𝑥1 … 𝑥 − 𝑥𝑘−1 𝑥 − 𝑥𝑘+1 … 𝑥 − 𝑥𝑛

𝑥𝑘 − 𝑥0 𝑥𝑘 − 𝑥1 … 𝑥𝑘 − 𝑥𝑘−1 𝑥𝑘 − 𝑥𝑘+1 … 𝑥𝑘 − 𝑥𝑛

𝐿𝑘 𝑥 𝐿𝑛 ,𝑘 𝑥 𝑛

𝑛

𝑃𝑛 𝑥 = 𝐿0 𝑥 𝑓 𝑥0 + ⋯ + 𝐿𝑛 𝑥 𝑓 𝑥𝑛 𝑃𝑛 𝑥 = 𝐿𝑘 𝑥 𝑓 𝑥𝑘

𝑛𝑘=0

Page 6: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

6

Lagrange Polynomial: Example

𝑓 𝑥 =1

𝑥 𝑥0 = 2, 𝑥1 = 2.5 𝑥2 = 4

𝑥 2 2.5 4

𝑓 𝑥 0.5 0.4 0.25

𝑓 3 𝐿0, 𝐿1, 𝐿2

𝐿0 𝑥 = 𝑥 − 𝑥1 𝑥 − 𝑥2

𝑥0 − 𝑥1 𝑥0 − 𝑥2 =

𝑥 − 2.5 𝑥 − 4

2 − 2.5 2 − 4 = 𝑥2 − 6.5𝑥 + 10

𝐿1 𝑥 = 𝑥 − 𝑥0 𝑥 − 𝑥2

𝑥1 − 𝑥0 𝑥1 − 𝑥2 =

𝑥 − 2 𝑥 − 4

2.5 − 2 2.5 − 4 =

−4𝑥2 + 24𝑥 − 32

3

𝐿2 𝑥 = 𝑥 − 𝑥0 𝑥 − 𝑥1

𝑥2 − 𝑥0 𝑥2 − 𝑥1 =

𝑥 − 2 𝑥 − 2.5

4 − 2 4 − 2.5 =

𝑥2 − 4.5𝑥 + 5

3

Lagrange Polynomial: Example

𝑃2 𝑥 = 𝐿𝑛 𝑥 𝑓 𝑥𝑘 2𝑘=0

= 0.5 𝑥2 − 6.5𝑥 + 10 + 0.4 −4𝑥2+24𝑥−32

3 + 0.25

𝑥2−4.5𝑥+5

3

= 0.05𝑥2 − 0.425𝑥 + 1.15 𝑓 3 =

1

3= 0.333∙ 𝑃2 3 = 0.325

Page 7: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

7

Lagrange Polynomial: Example

𝑓 𝑛+1 𝜉 𝑥−𝑥0 𝑛+1

𝑛+1 ! 𝜉 𝑥 𝑥0

𝑛 𝑥0 , 𝑥1 , … , 𝑥𝑛

𝑓 𝑥 = 𝑃𝑛 𝑥 +𝑓 𝑛+1 𝜉

𝑛 + 1 ! 𝑥 − 𝑥0 𝑥 − 𝑥1 … 𝑥 − 𝑥𝑛

𝜉 𝑥 𝑥0 , 𝑥1 , … , 𝑥𝑛

Divided Difference

𝑓 𝑥𝑖 𝑓 𝑥𝑖 = 𝑓 𝑥𝑖 (recursive) 𝑓 𝑥𝑖 𝑥𝑖+1

𝑓 𝑥𝑖 , 𝑥𝑖+1 =𝑓 𝑥𝑖+1 − 𝑓 𝑥𝑖

𝑥𝑖+1 − 𝑥𝑖

𝑘 𝑥𝑖 , 𝑥𝑖+1, … , 𝑥𝑖+𝑘

𝑓 𝑥𝑖 , 𝑥𝑖+1, …𝑥𝑖+𝑘 =𝑓 𝑥𝑖+1, … , 𝑥𝑖+𝑘 − 𝑓 𝑥𝑖 , … , 𝑥𝑖+𝑘−1

𝑥𝑖+𝑘 − 𝑥𝑖

Page 8: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

8

Divided Difference

( )

𝑃𝑛 𝑥 = 𝑓 𝑥0 + 𝑓 𝑥0, 𝑥1 𝑥 − 𝑥0 + 𝑓 𝑥0, 𝑥1, 𝑥2 𝑥 − 𝑥0 𝑥 − 𝑥1 + ⋯+ 𝑓 𝑥0, 𝑥1, … , 𝑥𝑛 𝑥 − 𝑥0 𝑥 − 𝑥1 … 𝑥 − 𝑥𝑛−1

( )

𝑃𝑛 𝑥 = 𝑓 𝑥𝑛 + 𝑓 𝑥𝑛−1, 𝑥𝑛 𝑥 − 𝑥𝑛 + 𝑓 𝑥𝑛−2, 𝑥𝑛−1, 𝑥𝑛 𝑥 − 𝑥𝑛 𝑥 − 𝑥𝑛−1 + ⋯+ 𝑓 𝑥0, 𝑥1 , … , 𝑥𝑛 𝑥 − 𝑥𝑛 𝑥 − 𝑥𝑛−1 … 𝑥 − 𝑥1

Divided Difference

𝒙 𝒇 𝒙 First divided difference Second divided difference 𝑥0 𝑓 𝑥0

𝑓 𝑥0, 𝑥1 =𝑓 𝑥1 − 𝑓 𝑥0

𝑥1 − 𝑥0

𝑥1 𝑓 𝑥1 𝑓 𝑥0, 𝑥1 , 𝑥2 =𝑓 𝑥1, 𝑥2 − 𝑓 𝑥0, 𝑥1

𝑥2 − 𝑥0

𝑓 𝑥1, 𝑥2 =𝑓 𝑥2 − 𝑓 𝑥1

𝑥2 − 𝑥1

𝑥2 𝑓 𝑥2 𝑓 𝑥1, 𝑥2, 𝑥3 =𝑓 𝑥2, 𝑥3 − 𝑓 𝑥1, 𝑥2

𝑥3 − 𝑥1

𝑓 𝑥2, 𝑥3 =𝑓 𝑥3 − 𝑓 𝑥2

𝑥3 − 𝑥2

𝑥3 𝑓 𝑥3

Page 9: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

9

Newton Divided Difference: Example

𝑥 1.0 1.3 1.6 1.9 2.2

𝑓 𝑥 0.7651977 0.6200860 0.4554022 0.2818186 0.1103623

𝒇 𝟏. 𝟓

Newton Divided Difference: Example

xi f(xi)=f[xi] 1st Divided Diff 2nd Divided Diff 3rd Divided Diff 4th Divided Diff

1.0 0.7651977 -0.4837057

1.3 0.6200860 -0.1087339 -0.5489460 0.0658784

1.6 0.4554022 -0.0494433 0.0018251 -0.5786120 0.0680685

1.9 0.2818186 0.0118183 -0.5715210

2.2 0.1103623

Page 10: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

10

Newton Divided Difference: Example

( ) Newton 𝑃4 𝑥 = 0.7651977 − 0.483705 𝑥 − 1 − 0.1087339 𝑥 − 1 𝑥 − 1.3

+ ⋯ + 0.0658784 𝑥 − 1 𝑥 − 1.3 𝑥 − 1.6 + 0.0018251 𝑥 − 1 𝑥 − 1.3 𝑥 − 1.6 𝑥 − 1.9

𝑃4 1.5 = 0.511820

( ) Newton

ค่าประมาณที่ x=1.8 มีค่าเท่าไร

Forward Divided Difference

𝑥0 , 𝑥1 , … , 𝑥𝑛 ℎ = 𝑥𝑖+1 − 𝑥𝑖 𝑖 = 0,1,2, … , 𝑛 𝑥 = 𝑥0 + 𝑠ℎ 𝑥 − 𝑥𝑖 = 𝑠 − 𝑖 ℎ

( ) 𝑃𝑛 𝑥 = 𝑃𝑛 𝑥0 + 𝑠ℎ

= 𝑓 𝑥0 + 𝑠ℎ𝑓 𝑥0 , 𝑥1 + 𝑠 𝑠 − 1 ℎ2𝑓 𝑥0 , 𝑥1 , 𝑥2 + ⋯ +𝑠 𝑠 − 1 𝑠 − 2 … 𝑠 − 𝑛 + 1 ℎ𝑛𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑛

= 𝑠 𝑠 − 1 𝑠 − 2 … 𝑠 − 𝑘 + 1 ℎ𝑘𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑘

𝑘=𝑛

𝑘=0

𝑃𝑛 𝑥 = 𝑃𝑛 𝑥0 + 𝑠ℎ = 𝑠𝑘 𝑘! ℎ𝑘𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑘

𝑘=𝑛𝑘=0

Page 11: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

11

Forward Divided Difference

𝑃𝑛 𝑛=0∞

∆𝑃𝑛 = 𝑃𝑛+1 − 𝑃𝑛 𝑛 ≥ 0

∆𝑘𝑃𝑛 = ∆ ∆𝑘−1 𝑃𝑛 𝑘 ≥ 2

𝑓 𝑥0, 𝑥1 =𝑓 𝑥1 − 𝑓 𝑥0

𝑥1 − 𝑥0=

1

ℎ∆𝑓 𝑥0

𝑓 𝑥0, 𝑥1, 𝑥2 =1

2ℎ ∆𝑓 𝑥1 − ∆𝑓 𝑥0

ℎ =

1

2ℎ2∆2𝑓 𝑥0

𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑘 =1

𝑘 !ℎ𝑘 ∆𝑘𝑓 𝑥0

Forward Divided Difference

𝑃𝑛 𝑥0 + 𝑠ℎ = 𝑠𝑘 𝑘! ℎ𝑘𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑘

𝑘=𝑛𝑘=0

𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑘 =1

𝑘 !ℎ𝑘 ∆𝑘𝑓 𝑥0

Newton

𝑃𝑛 𝑥 = 𝑠𝑘 ∆𝑘𝑓 𝑥0

𝑘=𝑛

𝑘=0

Page 12: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

12

Backward Divided Difference

( ) 𝑃𝑛 𝑥 = 𝑓 𝑥𝑛 + 𝑓 𝑥𝑛−1 , 𝑥𝑛 𝑥 − 𝑥𝑛

+ 𝑓 𝑥𝑛−2 , 𝑥𝑛−1 , 𝑥𝑛 𝑥 − 𝑥𝑛 𝑥 − 𝑥𝑛−1 + ⋯+ 𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑛 𝑥 − 𝑥𝑛 𝑥 − 𝑥𝑛−1 … 𝑥 − 𝑥1

𝑥 = 𝑥𝑛 + 𝑠ℎ, 𝑥𝑖 = 𝑥𝑛 − (𝑛 − 𝑖)ℎ 𝑥 − 𝑥𝑖 = 𝑠 + 𝑛 − 𝑖 ℎ 𝑃𝑛 𝑥 = 𝑃𝑛 𝑥𝑛 + 𝑠ℎ

= 𝑓 𝑥𝑛 + 𝑠ℎ𝑓 𝑥𝑛−1 , 𝑥𝑛 + 𝑠 𝑠 + 1 ℎ2𝑓 𝑥𝑛−2 , 𝑥𝑛−1 , 𝑥𝑛 + ⋯ + 𝑠 𝑠 + 1 𝑠 + 2 … 𝑠 + 𝑛 − 1 ℎ𝑛𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑛

Backward Divided Difference

𝑃𝑛 𝑥0 + 𝑠ℎ = −𝑠𝑘

𝑘! ℎ𝑘𝑓 𝑥𝑛−𝑘 , … , , 𝑥𝑛−1 , 𝑥𝑛 𝑘=𝑛𝑘=0

𝑃𝑛 𝑛=0∞

∇𝑃𝑛 = 𝑃𝑛 − 𝑃𝑛−1 𝑛 ≥ 1

∇𝑘𝑃𝑛 = ∇ ∇𝑘−1 𝑃𝑛 𝑘 ≥ 2

𝑓 𝑥𝑛−1, 𝑥𝑛 =1

ℎ∇𝑓 𝑥𝑛 , 𝑓 𝑥𝑛−2, 𝑥𝑛−1, 𝑥𝑛 =

1

2ℎ2 ∇2𝑓 𝑥𝑛

𝑓 𝑥𝑛−𝑘 , … , 𝑥𝑛−1, 𝑥𝑛 =1

𝑘!ℎ𝑘 ∇k𝑓 𝑥𝑛

Page 13: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

13

Backward Divided Difference

𝑃𝑛 𝑥0 + 𝑠ℎ = −𝑠𝑘

𝑘! ℎ𝑘𝑓 𝑥𝑛−𝑘 , … , , 𝑥𝑛−1 , 𝑥𝑛 𝑘=𝑛𝑘=0

𝑓 𝑥𝑛−𝑘 , … , 𝑥𝑛−1, 𝑥𝑛 =1

𝑘!ℎ𝑘 ∇k𝑓 𝑥𝑛

– 𝑆𝑘

= −−𝑠 −𝑠−1 … −𝑠−𝑘+1

𝑘 !=

−1 𝑘𝑠 𝑠+1 … 𝑠+𝑘−1

𝑘 !

“ Newton”

𝑃𝑛 𝑥 = −1 𝑘 𝑠𝑘 ∇𝑘𝑓 𝑥𝑛

𝑘=𝑛𝑘=0

Newton Divided Difference: Example

𝑥 1.0 1.3 1.6 1.9 2.2

𝑓 𝑥 0.7651977 0.6200860 0.4554022 0.2818186 0.1103623

𝑓 1.1 𝑓 2.0

𝑓 1.1 𝑥 = 1.1 𝑥0 = 1.0

ℎ = 0.3, 𝑠 =1

3 𝑃4 1.1 = 𝑃4 1.0 +

1

3 0.3

𝑓 2.0 𝑥 = 2.0 𝑥4 = 2.2

ℎ = 0.3, 𝑠 = −2

3 𝑃4 2.0 = 𝑃4 2.2 + −

2

3 0.3

Page 14: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

14

Example (Newton Divided Difference)

xi f(xi)=f[xi] 1st Divided Diff 2nd Divided Diff 3rd Divided Diff 4th Divided Diff

1.0 0.7651977 -0.4837057

1.3 0.6200860 -0.1087339 -0.5489460 0.0658784

1.6 0.4554022 -0.0494433 0.0018251 -0.5786120 0.0680685

1.9 0.2818186 0.0118183 -0.5715210

2.2 0.1103623

Newton Divided Difference: Example

𝑃4 1.1 = 𝑃4 1.0 +1

3 0.3

= 0.7651977 +1

3 0.3 −0.483705

+1

3 −

2

3 0.3 2 −0.1087339

+1

3 −

2

3 −

5

3 0.3 3 0.0658784

+1

3 −

2

3 −

5

3 −

8

3 0.3 4 0.0018251 = 0.7196480

Page 15: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

15

Newton Divided Difference: Example

xi f(xi)=f[xi] 1st Divided Diff 2nd Divided Diff 3rd Divided Diff 4th Divided Diff

1.0 0.7651977 -0.4837057

1.3 0.6200860 -0.1087339 -0.5489460 0.0658784

1.6 0.4554022 -0.0494433 0.0018251 -0.5786120 0.0680685

1.9 0.2818186 0.0118183 -0.5715210

2.2 0.1103623

Newton Divided Difference: Example

𝑃4 2.0 = 𝑃4 2.2 + −2

3 0.3

= 0.1103623 −2

3 0.3 −0.5715210 −

2

3

1

3 0.3 2 0.0118183

−2

3

1

3

4

3 0.3 3 0.0680685

−2

3

1

3

4

3

7

3 0.3 4 0.0018251 = 0.2238754

Page 16: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

16

Hermite Interpolation

การที่พหุนามมีดีกรีสูงข้ึนจะท าให้ค่าประมาณดีข้ึน การประมาณค่าในช่วง

ของ Hermite นอกจากจะใช้ค่าฟังก์ชัน ณ จุดที่ก าหนดแล้ว ยังใช้ค่า

อนุพันธ์อันดับหนึ่ง ณ จุดที่ก าหนดนั้นด้วย ส าหรบัข้อมูลจ านวน n+1 ตัว พหุนาม Hermite จะมีดีกร ี2n+1

Hermite Interpolation

Hermite

𝑓 ∈ 𝐶1 𝑎, 𝑏 𝑥0 , 𝑥1 , … , 𝑥𝑛 ∈ 𝑎, 𝑏 𝑓 𝑓 ′ 𝑥0 , 𝑥1 , … , 𝑥𝑛 2𝑛 + 1

𝐻2𝑛+1 𝑥 = 𝑓 𝑥𝑗 𝐻𝑛 ,𝑗 𝑥 𝑛𝑗=0 + 𝑓 ′ 𝑥𝑗 𝐻 𝑛 ,𝑗 𝑥

𝑛𝑗=0

𝐻𝑛 ,𝑗 𝑥 = 1 − 2 𝑥 − 𝑥𝑗 𝐿𝑛 ,𝑗′ 𝑥𝑗 𝐿𝑛 ,𝑗

2 𝑥

𝐻 𝑛 ,𝑗 𝑥 = 𝑥 − 𝑥𝑗 𝐿𝑛 ,𝑗2 𝑥

𝐿𝑛 ,𝑗 𝑥 𝑗 Langrange 𝑛

Page 17: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

17

Hermite Interpolation

Hermite

𝑓 ∈ 𝐶 2𝑛+2 𝑎, 𝑏

𝑓 𝑥 = 𝐻2𝑛+1 𝑥 +𝑓 2𝑛+2 𝜉 𝑥

2𝑛+2 ! 𝑥 − 𝑥0

2 … 𝑥 − 𝑥𝑛 2

𝜉 𝑥 ∈ 𝑎, 𝑏

𝑓 ∈ 𝐶𝑛 𝑎, 𝑏 𝑥0 , … , 𝑥𝑛 ∈ 𝑎, 𝑏 𝜉 𝑥 ∈ 𝑎, 𝑏

𝑓 𝑥0 , 𝑥1 , … , 𝑥𝑛 =𝑓𝑛 𝜉

𝑛 !

Hermite Interpolation

Hermite 𝑧𝑘 𝑘=02𝑛+1

𝑧2𝑖 = 𝑧2𝑖+1 = 𝑥𝑖 𝑖 = 0,1, … , 𝑛 𝑧0, 𝑧1, … , 𝑧2𝑛+1 𝑧2𝑖 = 𝑧2𝑖+1 = 𝑥𝑖 𝑖

𝑓 𝑧2𝑖 , 𝑧2𝑖+1 =𝑓 𝑧2𝑖+1 −𝑓 𝑧2𝑖

𝑧2𝑖+1−𝑧2𝑖

𝑓 𝑥0, 𝑥1, … , 𝑥𝑛 =𝑓𝑛 𝜉

𝑛 ! 𝑓 𝑥0, 𝑥1 = 𝑓 ′ 𝜉

𝜉 ∈ 𝑥0, 𝑥1

lim𝑥1→𝑥0𝑓 𝑥0, 𝑥1 = 𝑓 ′ 𝑥0

𝑓 𝑧2𝑖 , 𝑧2𝑖+1 = 𝑓 ′ 𝑥𝑖

Page 18: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

18

Hermite Interpolation

Hermite

𝑓 ∈ 𝐶1 𝑎, 𝑏 𝑥0 , 𝑥1 , … , 𝑥𝑛 ∈ 𝑎, 𝑏

𝐻2𝑛+1 𝑥 = 𝑓 𝑥0 + 𝑓 𝑧0, 𝑧1, … , 𝑧𝑘 𝑥 − 𝑧0 𝑥 − 𝑧1 … 𝑥 − 𝑧𝑘−1

2𝑛+1

𝑘=1

𝑧2𝑘 = 𝑧2𝑘+1 = 𝑥𝑘 𝑓 𝑧2𝑖 , 𝑧2𝑖+1 = 𝑓 ′ 𝑥𝑘 𝑖 =

0,1, … , 𝑛

Hermite Interpolation

𝑧 𝑓 𝑧 First divided difference Second divided difference

𝑧0 = 𝑥0 𝑓 𝑧0 = 𝑓 𝑥0 𝑓 𝑧0, 𝑧1 = 𝑓 ′ 𝑥0

𝑧1 = 𝑥0 𝑓 𝑧1 = 𝑓 𝑥0 𝑓 𝑧0, 𝑧1, 𝑧2 =

𝑓 𝑧1, 𝑧2 − 𝑓 𝑧0, 𝑧1

𝑧2 − 𝑧0

𝑓 𝑧1, 𝑧2 =

𝑓 𝑧2 − 𝑓 𝑧1

𝑧2 − 𝑧1

𝑧2 = 𝑥1 𝑓 𝑧2 = 𝑓 𝑥1 𝑓 𝑧1, 𝑧2, 𝑧3 =

𝑓 𝑧2, 𝑧3 − 𝑓 𝑧1, 𝑧2

𝑧3 − 𝑧1

𝑓 𝑧2, 𝑧3 = 𝑓 ′ 𝑥1 𝑧3 = 𝑥1 𝑓 𝑧3 = 𝑓 𝑥1

𝑓 𝑧2, 𝑧3, 𝑧4 =𝑓 𝑧3, 𝑧4 − 𝑓 𝑧2, 𝑧3

𝑧4 − 𝑧2

𝑓 𝑧3, 𝑧4 =

𝑓 𝑧4 − 𝑓 𝑧3

𝑧4 − 𝑧3

𝑧4 = 𝑥2 𝑓 𝑧4 = 𝑓 𝑥2 𝑓 𝑧3, 𝑧4, 𝑧5 =

𝑓 𝑧4, 𝑧5 − 𝑓 𝑧3, 𝑧4

𝑧5 − 𝑧3

𝑓 𝑧4, 𝑧5 = 𝑓 ′ 𝑥2 𝑧5 = 𝑥2 𝑓 𝑧5 = 𝑓 𝑥2

Page 19: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

19

Hermite Interpolation: Example

Hermite 𝑓 1.5

𝑥 𝑓 𝑥 𝑓 ′ 𝑥 1.3 0.6200860 -0.5220232 1.6 0.4554022 -0.5698959 1.9 0.2818186 -0.5811571

Hermite Interpolation: Example

𝑧 𝑓 𝑧 1st D Diff. 2nd D Diff. 3rd D Diff. 4th D Diff. 5th D Diff. 1.3 0.6200860

-0.5220232 1.3 0.6200860 -0.08977427

-0.5489460 0.0663657 1.6 0.4554022 -0.0698330 0.0026663

-0.5698959 0.0679655 -0.0027738 1.6 0.4554022 -0.0290537 0.0010020

-0.5786120 0.0685667 1.9 0.2818186 -0.0084837

-0.5811571 1.9 0.2818186

Page 20: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

20

Hermite Interpolation: Example

𝐻2𝑛+1 𝑥 = 𝑓 𝑥0 + 𝑓 𝑧0, 𝑧1, … , 𝑧𝑘 𝑥 − 𝑧0 𝑥 − 𝑧1 … 𝑥 − 𝑧𝑘−1 2𝑛+1𝑘=1

𝐻5 1.5 = 0.6200860 + 1.5 − 1.3 −0.5220232

+ 1.5 − 1.3 2 −0.0897427 + 1.5 − 1.3 2 1.5 − 1.6 0.0663657 + 1.5 − 1.3 2 1.5 − 1.6 2 0.0026663 + 1.5 − 1.3 2 1.5 − 1.6 2 1.5 − 1.9 −0.0027738 = 0.5118277

Cubic Spline Interpolation

ความแม่นย าในการประมาณอาจสูงขึ้น เม่ือใช้พหุนามที่มีดีกรีสูง แต่เมื่อ

ดีกรีที่สูงข้ึนมากอาจจะมีการกวัดแกว่งของเส้นโค้งสูงข้ึนด้วย ซึ่งจะส่งผลให้

ค่าประมาณมีความคลาดเคลือ่นมากข้ึนก็ได้ วิธีหนึ่งที่ใช้แก้ปญัหาคือ แบ่ง

ช่วงทั้งหมดออกเป็นช่วงย่อยๆ แล้วสร้างพหุนามประจ าแตล่ะช่วงย่อย

เรียกว่า “การประมาณโดยพหุนามเป็นช่วงๆ””

ถ้าให้ทุกสองคู่ของจุดแทนช่วงหนึ่งช่วง การเช่ือมจุดของข้อมูลด้วยเส้นตรงก็

คือวิธีที่ง่ายที่สุด แต่ก็จะท าใหเ้ส้นโค้งไม่เรียบ

แนวทางอ่ืนคือ การใช้พหุนาม Hermite แต่ก็ต้องมีข้อมูลของอนุพันธ์อันดับหนึ่งของทุกจุด

Page 21: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

21

Cubic Spline Interpolation

การประมาณโดยพหุนามเป็นส่วนๆ ที่พบบ่อยท่ีสุดคือ การใช้พหุนามก าลัง

สามระหวา่งคู่ของจุด ที่เรียกว่า Cubic Spline

พหุนามก าลังสาม มีค่าคงตัว 4 ค่า โดยท่ัวไปแล้วอนุพันธ์ของ Cubic

Spline ไม่จ าเป็นต้องเท่ากับอนุพันธ์ของฟังก์ชันจริง แม้ที่จุดนิยาม

Cubic Spline Interpolation

𝑓 𝑎, 𝑏 𝑎 = 𝑥0 < 𝑥1 < ⋯ < 𝑥𝑛 = 𝑏 𝑆 𝑓

1. 𝑆 𝑆𝑗 𝑥𝑗 , 𝑥𝑗+1 , 𝑗 =

0,1, … , 𝑛 − 1 2. 𝑆 𝑥𝑗 = 𝑓 𝑥𝑗 ( 𝑗 = 0,1, … , 𝑛 )

3. 𝑆𝑗+1 𝑥𝑗 +1 = 𝑆𝑗 𝑥𝑗+1 ( 𝑗 = 0,1, … , 𝑛 − 2 )

4. 𝑆𝑗+1′ 𝑥𝑗 +1 = 𝑆𝑗

′ 𝑥𝑗+1 ( 𝑗 = 0,1, … , 𝑛 − 2 )

5. 𝑆𝑗+1′′ 𝑥𝑗 +1 = 𝑆𝑗

′′ 𝑥𝑗 +1 ( 𝑗 = 0,1, … , 𝑛 − 2 )

6.

a. 𝑆′′ 𝑥0 = 𝑆′′ 𝑥𝑛 = 0 ( )

b. 𝑆′ 𝑥0 = 𝑓 ′ 𝑥0 𝑆′ 𝑥𝑛 = 𝑓 ′ 𝑥𝑛 ( )

Page 22: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

22

Cubic Spline Interpolation

𝑆 𝑥𝑗 = 𝑓 𝑥𝑗 𝑗 = 0,1, … , 𝑛

𝑆𝑗+1 𝑥𝑗+1 = 𝑆𝑗 𝑥𝑗+1 𝑗 = 0,1, … , 𝑛 − 2

𝑆𝑗+1′ 𝑥𝑗+1 = 𝑆𝑗

′ 𝑥𝑗+1 𝑗 = 0,1, … , 𝑛 − 2 𝑆𝑗+1

′′ 𝑥𝑗+1 = 𝑆𝑗′′ 𝑥𝑗+1 𝑗 = 0,1, … , 𝑛 − 2

𝑥0 𝑥1 𝑥𝑗 𝑥𝑗+2 𝑥𝑗+1 𝑥𝑛

𝑆𝑗 𝑆𝑗 +1

Cubic Spline Interpolation

𝑆𝑗 𝑥 = 𝑎𝑗 + 𝑏𝑗 𝑥 − 𝑥𝑗 + 𝑐𝑗 𝑥 − 𝑥𝑗 2

+ 𝑑𝑗 𝑥 − 𝑥𝑗 3 𝑗 = 0,1, … , 𝑛 − 1

2 𝑆𝑗 𝑥𝑗 = 𝑎𝑗 = 𝑓 𝑥𝑗

3 𝑎𝑗+1 = 𝑆𝑗+1 𝑥𝑗+1 = 𝑆𝑗 𝑥𝑗+1

= 𝑎𝑗 + 𝑏𝑗 𝑥𝑗+1 − 𝑥𝑗 + 𝑐𝑗 𝑥𝑗+1 − 𝑥𝑗 2

+ 𝑑𝑗 𝑥𝑗+1 − 𝑥𝑗 3 𝑗 = 0,1, … , 𝑛 − 2

ℎ𝑗 = 𝑥𝑗+1 − 𝑥𝑗 𝑗 = 0,1, … , 𝑛 − 1

𝑎𝑛 = 𝑓 𝑥𝑛

1 𝑎𝑗+1 = 𝑎𝑗 + 𝑏𝑗ℎ𝑗 + 𝑐𝑗ℎ𝑗2 + 𝑑𝑗ℎ𝑗

3

Page 23: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

23

Cubic Spline Interpolation

𝑆𝑗′ 𝑥 = 𝑏𝑗 + 2𝑐𝑗 𝑥 − 𝑥𝑗 + 3𝑑𝑗 𝑥 − 𝑥𝑗

2

𝑆𝑗′ 𝑥𝑗 = 𝑏𝑗 𝑗 = 0,1, … , 𝑛 − 1

𝑏𝑛 = 𝑆′ 𝑥𝑛 4. 𝑆𝑗+1′ 𝑥𝑗+1 = 𝑆𝑗

′ 𝑥𝑗+1 𝑥 = 𝑥𝑗+1

𝑆𝑗+1′ 𝑥𝑗+1 = 𝑆𝑗

′ 𝑥𝑗+1 = 𝑏𝑗 + 2𝑐𝑗 𝑥𝑗+1 − 𝑥𝑗 + 3𝑑𝑗 𝑥𝑗+1 − 𝑥𝑗 2

2 𝑏𝑗+1 = 𝑏𝑗 + 2𝑐𝑗ℎ𝑗 + 3𝑑𝑗ℎ𝑗2

Cubic Spline Interpolation

𝑆𝑗′ ′ 𝑥 = 2𝑐𝑗 + 6𝑑𝑗 𝑥 − 𝑥𝑗

𝑥 = 𝑥𝑗 𝑆𝑗′′ 𝑥𝑗 = 2𝑐𝑗

𝑐𝑛 =1

2𝑆′′ 𝑥𝑛 5.

3 𝑐𝑗+1 = 𝑐𝑗 + 3𝑑𝑗ℎ𝑗 𝑗 = 0,1, … , 𝑛 − 1

3 𝑑𝑗

𝑑𝑗 = 𝑐𝑗+1−𝑐𝑗

3ℎ𝑗

Page 24: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

24

Cubic Spline Interpolation

𝑑𝑗 1 2

4 𝑎𝑗+1 = 𝑎𝑗 + 𝑏𝑗ℎ𝑗 +1

3ℎ𝑗

2 2𝑐𝑗 + 𝑐𝑗+1

5 𝑏𝑗+1 = 𝑏𝑗 + ℎ𝑗 𝑐𝑗 + 𝑐𝑗+1 𝑗 = 0,1, … , 𝑛 − 1

4 𝑏𝑗

6 𝑏𝑗 =1

ℎ𝑗 𝑎𝑗+1 − 𝑎𝑗 −

ℎ𝑗

3 2𝑐𝑗 + 𝑐𝑗+1

𝑏𝑗−1 =1

ℎ𝑗−1 𝑎𝑗 − 𝑎𝑗−1 −

ℎ𝑗−1

3 2𝑐𝑗−1 + 𝑐𝑗

Cubic Spline Interpolation

𝑏𝑗 𝑏𝑗−1 5

7 ℎ𝑗−1𝑐𝑗−1 + 2 ℎ𝑗−1 + ℎ𝑗 𝑐𝑗 + ℎ𝑗 𝑐𝑗+1 =3

ℎ𝑗 𝑎𝑗+1 − 𝑎𝑗 −

3

ℎ𝑗−1 𝑎𝑗 − 𝑎𝑗−1 𝑗 = 1, … , 𝑛 − 1

𝑐𝑗 𝑗=0

𝑛 ℎ𝑗 𝑗=0

𝑛−1 𝑎𝑗 𝑗=0

𝑛

𝑐𝑗 𝑗=0

𝑛 𝑏𝑗 𝑗=0

𝑛−1 6 𝑑𝑗 𝑗=0

𝑛−1

3 𝑆𝑗 𝑗=0

𝑛−1

Page 25: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

25

Cubic Spline: Example

𝑥 1 2 3 4 5

𝑓 𝑥 0 1 0 1 0

Spline 1,2 , 2,3 , 3,4 4,5

𝑆𝑗 𝑥 = 𝑎𝑗 + 𝑏𝑗 𝑥 − 𝑥𝑗 + 𝑐𝑗 𝑥 − 𝑥𝑗 2

+ 𝑑𝑗 𝑥 − 𝑥𝑗 3 ( 𝑗 = 0,1,2,3)

𝑆 = 𝑆0 ∪ 𝑆1 ∪ 𝑆2 ∪ 𝑆3

𝑆0 𝑥 = 𝑎0 + 𝑏0 𝑥 − 1 + 𝑐0 𝑥 − 1 2 + 𝑑0 𝑥 − 1 3 1,2

𝑆1 𝑥 = 𝑎1 + 𝑏1 𝑥 − 2 + 𝑐1 𝑥 − 2 2 + 𝑑1 𝑥 − 2 3 2,3

𝑆2 𝑥 = 𝑎2 + 𝑏2 𝑥 − 3 + 𝑐2 𝑥 − 3 2 + 𝑑2 𝑥 − 3 3 3,4

𝑆3 𝑥 = 𝑎3 + 𝑏3 𝑥 − 4 + 𝑐3 𝑥 − 4 2 + 𝑑3 𝑥 − 4 3 4,5

Cubic Spline: Example

2. 𝑆𝑗 𝑥𝑗 = 𝑎𝑗 = 𝑓 𝑥𝑗 𝑗 = 0,1,2,3,4

𝑎0 = 0, 𝑎1 = 1, 𝑎2 = 0, 𝑎3 = 1, 𝑎4 = 0

ℎ𝑗 = 𝑥𝑗+1 − 𝑥𝑗 𝑗 = 0,1,2,3 ℎ0 = ℎ1 = ℎ2 = ℎ3 = 1

, 𝑐0 =1

2𝑆′′ 𝑥0 = 0, 𝑐𝑛 =

1

2𝑆′′ 𝑥𝑛 = 0

Page 26: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

26

Cubic Spline: Example

7 𝑖 = 1,2,3

ℎ0𝑐0 + 2 ℎ0 + ℎ1 𝑐1 + ℎ1𝑐2 =3

ℎ1 𝑎2 − 𝑎1 −

3

ℎ0 𝑎1 − 𝑎0

ℎ1𝑐1 + 2 ℎ1 + ℎ2 𝑐2 + ℎ2𝑐3 =3

ℎ2 𝑎3 − 𝑎2 −

3

ℎ1 𝑎2 − 𝑎1

ℎ2𝑐2 + 2 ℎ2 + ℎ3 𝑐3 + ℎ3𝑐4 =3

ℎ3 𝑎4 − 𝑎3 −

3

ℎ2 𝑎3 − 𝑎2

𝑎𝑗 , ℎ𝑗

4𝑐1 + 𝑐2 = 3 0 − 1 − 3 1 − 0 = −6 𝑐1 + 4𝑐2 + 𝑐3 = 3 1 − 0 − 3 0 − 1 = 6 𝑐2 + 4𝑐3 = 3 0 − 1 − 3 1 − 0 = −6

𝑐1 = −15

7, 𝑐2 =

18

7, 𝑐3 = −

15

7

Cubic Spline: Example

6 𝑏𝑗 =1

ℎ𝑗 𝑎𝑗+1 − 𝑎𝑗 −

ℎ𝑗

3 2𝑐𝑗 + 𝑐𝑗+1

𝑏0 =1

ℎ0 𝑎1 − 𝑎0 −

ℎ0

3 2𝑐0 + 𝑐1 = 1 − 0 −

1

3 0 −

15

7 =

12

7

𝑏1 =1

ℎ1 𝑎2 − 𝑎1 −

ℎ1

3 2𝑐1 + 𝑐2 = 0 − 1 −

1

3 −

30

7+

18

7 = −

3

7

𝑏2 =1

ℎ2 𝑎3 − 𝑎2 −

ℎ2

3 2𝑐2 + 𝑐3 = 1 − 0 −

1

3

36

7−

15

7 = 0

𝑏3 =1

ℎ3 𝑎4 − 𝑎3 −

ℎ3

3 2𝑐3 + 𝑐4 = 0 − 1 −

1

3 −

30

7+ 0 =

3

7

Page 27: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

27

Cubic Spline: Example

3 𝑑𝑗 = 𝑐𝑗+1−𝑐𝑗

3ℎ𝑗

𝑑0 =1

3ℎ0 𝑐1 − 𝑐0 =

1

3 −

15

7− 0 = −

5

7

𝑑1 =1

3ℎ1 𝑐2 − 𝑐1 =

1

3

18

7+

15

7 =

11

7

𝑑2 =1

3ℎ2 𝑐3 − 𝑐2 =

1

3 −

15

7−

18

7 = −

11

7

𝑑3 =1

3ℎ3 𝑐4 − 𝑐3 =

1

3 0 +

15

7 =

5

7

Cubic Spline: Example

Spline

𝑆0 𝑥 = 0 +12

7 𝑥 − 1 + 0 −

5

7 𝑥 − 1 3

𝑆1 𝑥 = 1 −3

7 𝑥 − 2 −

15

7 𝑥 − 2 2 +

11

7 𝑥 − 2 3

𝑆2 𝑥 = 0 + 0 +18

7 𝑥 − 3 2 −

11

7 𝑥 − 3 3

𝑆3 𝑥 = 1 +3

7 𝑥 − 4 −

15

7 𝑥 − 4 2 +

5

7 𝑥 − 4 3

Page 28: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

28

Cubic Spline: Example

Spline 𝑓 𝑥 = 3𝑥𝑒𝑥 − 𝑒2𝑥 . 𝑥 = 1.03

𝑥 1.0 1.02 1.04 1.06

𝑓 𝑥 0.765789386 0.795366779 0.822688170 0.847522258

𝑓 ′ 𝑥 1.5315787 1.1754977

𝑛 = 3

𝑆𝑗 𝑥 = 𝑎𝑗 + 𝑏𝑗 𝑥 − 𝑥𝑗 + 𝑐𝑗 𝑥 − 𝑥𝑗 2

+ 𝑑𝑗 𝑥 − 𝑥𝑗 3

𝑥0 = 1.0, 𝑥1 = 1.02, 𝑥2 = 1.04, 𝑥3 = 1.06

ℎ = 𝑥𝑗+1 − 𝑥𝑗 = 0.02 ( 𝑗 = 0,1,2) 𝑆 = 𝑆0 ∪ 𝑆1 ∪ 𝑆2

Cubic Spline: Example

2. 𝑆𝑗 𝑥𝑗 = 𝑎𝑗 = 𝑓 𝑥𝑗 𝑗 = 0,1,2,3 𝑎0 = 𝑓 𝑥0 = 0.7657894 𝑎1 = 𝑓 𝑥1 = 0.7953668 𝑎2 = 𝑓 𝑥2 = 0.8226882 𝑎3 = 𝑓 𝑥3 = 0.8475223 𝑆′ 𝑥0 = 𝑓 ′ 𝑥0 𝑆 ′ 𝑥𝑛 = 𝑓 ′ 𝑥𝑛 𝑏0 = 1.5315787 𝑏3 = 1.1754977

Page 29: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

29

Cubic Spline: Example

6 𝑏𝑗 =1

ℎ𝑗 𝑎𝑗+1 − 𝑎𝑗 −

ℎ𝑗

3 2𝑐𝑗 + 𝑐𝑗+1

𝑗 = 0,1,2 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 𝑏0 , 𝑏3 (1) 1.5315787 = 𝑏0 = 1.47887 − 0.01333𝑐0 − 0.006667𝑐1 𝑏1 = 1.36607 − 0.01333𝑐1 − 0.006667𝑐2 𝑏2 = 1.241722 − 0.01333𝑐2 − 0.006667𝑐3 5 𝑏𝑗+1 = 𝑏𝑗 + ℎ𝑗 𝑐𝑗 + 𝑐𝑗+1 𝑗 = 0,1,2 𝑏0 , 𝑏3 (2) 𝑏1 = 1.5315787 + 0.02𝑐0 + 0.02𝑐1 𝑏2 = 𝑏1 + 0.02𝑐1 + 0.02𝑐2 1.1754977 = 𝑏3 = 𝑏2 + 0.02𝑐2 + 0.02𝑐3

Cubic Spline: Example

(1) (2) 3 𝑐0 + 0.5𝑐1 = −4.2687857 𝑐0 + 0.33333𝑐1 − 0.33333𝑐2 = 8.275435 𝑐2 − 𝑐3 = 9.9305985 𝑐0 − 2𝑐2 − 𝑐3 = 17.80405 (3) 𝑐0 = 46.109654, 𝑐1 = 100.75688

𝑐2 = 12.745401, 𝑐3 = 2.814803

Page 30: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

30

Cubic Spline: Example

(2)

𝑏0 = 1.5315787, 𝑏1 = 2.6245232

𝑏2 = 0.8642936, 𝑏3 = 1.1754977

3 𝑗 = 0,1,2

𝑑0 = −2447.7756 , 𝑑1 = 1891.7047, 𝑑2 = −165.50997

Cubic Spline: Example

𝑆 = 𝑆0 ∪ 𝑆1 ∪ 𝑆2

𝑆0 𝑥 = 0.7657894 + 1.5315787 𝑥 − 1 + 46.109654 𝑥 − 1 2

− 2447.7756 𝑥 − 1 3

𝑆1 𝑥 = 0.7953668 + 2.6245232 𝑥 − 1.02 + 100.75688 𝑥 − 1.02 2 + 1891.7047 𝑥 − 1.02 3

𝑆2 𝑥 = 0.8226882 + 0.8642936 𝑥 − 1.04 + 12.745401 𝑥 − 1.04 2 − 165.50997 𝑥 − 1.04 3

𝑓 1.03 𝑆1 1.03

= 0.7953668 + 2.6245232 1.03 − 1.02 + 100.75688 1.03 − 1.02 2 + 1891.7047 1.03 − 1.02 3

Page 31: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

31

Least Square Method

ฟั ภ ฟั ็

n+1 ็ n ภ ฐ ( )

Least Square Method

Page 32: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

32

Least Square Method

1

𝑎𝑥𝑖 + 𝑏 𝑖 𝑦𝑖 𝐸 𝑎, 𝑏 𝑎, 𝑏

𝐸 𝑎, 𝑏

(Minimax Error Function) 𝐸∞ 𝑎, 𝑏 = max𝑖=1,2,…,10 𝑦𝑖 − 𝑎𝑥𝑖 + 𝑏 (Absolute derivation Error Function) 𝐸𝑙 𝑎, 𝑏 = 𝑦𝑖 − 𝑎𝑥𝑖 + 𝑏 10

𝑖=1

Least Square Method

ฟั (Total Square Error)

𝐸2 𝑎, 𝑏 = 𝑦𝑖 − 𝑎𝑥𝑖 + 𝑏 210

𝑖=1

0 =𝜕

𝜕𝑎 𝑦𝑖 − 𝑎𝑥𝑖 + 𝑏

210𝑖=1 = 2 𝑦𝑖 − 𝑎𝑥𝑖 − 𝑏 −𝑥𝑖

10𝑖=1

0 =𝜕

𝜕𝑏 𝑦𝑖 − 𝑎𝑥𝑖 + 𝑏

210𝑖=1 = 2 𝑦𝑖 − 𝑎𝑥𝑖 − 𝑏 −1 10

𝑖=1

𝑎 𝑥𝑖

2𝑚𝑖=1 + 𝑏 𝑥𝑖

𝑚𝑖=1 = 𝑥𝑖𝑦𝑖

𝑚𝑖=1

𝑎 𝑥𝑖𝑚𝑖=1 + 𝑏𝑚 = 𝑦𝑖

𝑚𝑖=1

Page 33: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

33

Least Square Method

𝑎 𝑏

𝑎 =𝑚 𝑥𝑖𝑦𝑖

𝑚𝑖=1 − 𝑥𝑖

𝑚𝑖=1 𝑦𝑖

𝑚𝑖=1

𝑚 𝑥𝑖2𝑚

𝑖=1 − 𝑥𝑖𝑚𝑖=1

2

𝑏 = 𝑥𝑖

2𝑚𝑖=1 𝑦𝑖

𝑚𝑖=1 − 𝑥𝑖𝑦𝑖

𝑚𝑖=1 𝑥𝑖

𝑚𝑖=1

𝑚 𝑥𝑖2𝑚

𝑖=1 − 𝑥𝑖𝑚𝑖=1

2

ฟั 𝑃1 𝑥 = 𝑦 = 𝑎𝑥 + 𝑏

Least Square Method: Example

𝑥𝑖 1 2 3 4 5 6 7 8 9 10

𝑦𝑖 1.3 3.5 4.2 5.0 7.0 8.8 10.1 12.5 13.0 15.6

𝑎 =𝑚 𝑥𝑖𝑦𝑖

𝑚𝑖=1 − 𝑥𝑖

𝑚𝑖=1 𝑦𝑖

𝑚𝑖=1

𝑚 𝑥𝑖2𝑚

𝑖=1 − 𝑥𝑖𝑚𝑖=1

2

𝑏 = 𝑥𝑖

2𝑚𝑖=1 𝑦𝑖

𝑚𝑖=1 − 𝑥𝑖𝑦𝑖

𝑚𝑖=1 𝑥𝑖

𝑚𝑖=1

𝑚 𝑥𝑖2𝑚

𝑖=1 − 𝑥𝑖𝑚𝑖=1

2

𝑥𝑖𝑚𝑖=1 , 𝑦𝑖

𝑚𝑖=1 , 𝑥𝑖

2𝑚𝑖=1 , 𝑥𝑖𝑦𝑖

𝑚𝑖=1

Page 34: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

34

Least Square Method: Example

𝑥𝑖 𝑦𝑖 𝑥𝑖2 𝑥𝑖𝑦𝑖

1 1.3 1 1.3 2 3.5 4 7.0 3 4.2 9 12.6 4 5.0 16 20.0 5 7.0 25 35.5 6 8.8 36 52.8 7 10.1 49 70.7 8 12.5 64 100.0 9 13.0 81 117.0 10 15.6 100 156.0 55 81.0 385 572.4

𝑎 =𝑚 𝑥𝑖𝑦𝑖

𝑚𝑖=1 − 𝑥𝑖

𝑚𝑖=1 𝑦𝑖

𝑚𝑖=1

𝑚 𝑥𝑖2𝑚

𝑖=1 − 𝑥𝑖𝑚𝑖=1

2

𝑏 = 𝑥𝑖

2𝑚𝑖=1 𝑦𝑖

𝑚𝑖=1 − 𝑥𝑖𝑦𝑖

𝑚𝑖=1 𝑥𝑖

𝑚𝑖=1

𝑚 𝑥𝑖2𝑚

𝑖=1 − 𝑥𝑖𝑚𝑖=1

2

𝑎 =10 572.4 −55 81

10 385 − 55 2 = 1.538

𝑏 =385 81 −55 572.4

10 385 − 55 2 = −0.360

𝑃 𝑥𝑖 = 1.538𝑥𝑖 − 0.360

1.18 2.72 4.25 5.79 7.33 8.87 10.41 11.94 13.48 15.02

𝐸 = 𝑦𝑖 − 𝑃 𝑥𝑖 2

10

𝑖=1

≈ 2.34

Least Square Method: Example

0 1 2 3 4 5 6 7 8 9 10-2

0

2

4

6

8

10

12

14

16

Page 35: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

35

Least Square Method

𝑃𝑛 𝑥 = 𝑎𝑘𝑥𝑘𝑛

𝑘=0 𝑛 < 𝑚 − 1 𝑎0, … , 𝑎𝑛

𝐸 = 𝑦𝑖 − 𝑃𝑛 𝑥𝑖 2𝑛

𝑖=1

𝜕𝐸

𝜕𝑎𝑗= 0 𝑖 = 0,1,2, … , 𝑛 𝑛 + 1

𝑎𝑗

𝑎0 𝑥𝑖0

𝑚

𝑖=1

+ 𝑎1 𝑥𝑖1

𝑚

𝑖=1

+ 𝑎2 𝑥𝑖2

𝑚

𝑖=1

+ ⋯ + 𝑎𝑛 𝑥𝑖𝑛

𝑚

𝑖=1

= 𝑦𝑖𝑥𝑖0

𝑚

𝑖=1

𝑎0 𝑥𝑖1

𝑚

𝑖=1

+ 𝑎1 𝑥𝑖2

𝑚

𝑖=1

+ 𝑎2 𝑥𝑖3

𝑚

𝑖=1

+ ⋯ + 𝑎𝑛 𝑥𝑖𝑛+1

𝑚

𝑖=1

= 𝑦𝑖𝑥𝑖1

𝑚

𝑖=1

𝑎0 𝑥𝑖𝑛

𝑚

𝑖=1

+ 𝑎1 𝑥𝑖𝑛+1

𝑚

𝑖=1

+ 𝑎2 𝑥𝑖𝑛+2

𝑚

𝑖=1

+ ⋯ + 𝑎𝑛 𝑥𝑖2𝑛

𝑚

𝑖=1

= 𝑦𝑖𝑥𝑖𝑛

𝑚

𝑖=1

Least Square Method: Example

ฟั ็

𝑥𝑖 0 0.25 0.50 0.75 1.00

𝑦𝑖 1.0000 1.2840 1.6487 2.1170 2.7183

𝑛 = 2, 𝑚 = 5

5𝑎0 + 2.5𝑎1 + 1.875𝑎2 = 8.7680 2.5𝑎0 + 1.875𝑎1 + 1.5625𝑎2 = 5.4514 1.875𝑎0 + 1.5625𝑎1 + 1.3828𝑎2 = 4.4015

Page 36: Chapter 3 Interpolation and Polynomial Approximation11/8/2012 1 Chapter 3 Interpolation and Polynomial Approximation Numerical Analysis Problem type ถ าม ข อม ลจากการว

11/8/2012

36

Least Square Method: Example

𝑎0 = 1.0052, 𝑎1 = 0.8641, 𝑎2 = 0.8437

𝑃2 𝑥 = 1.0052 + 0.8641𝑥 + 0.84370.8437𝑥2

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

2.5