Professional Documents
Culture Documents
Interpolation
1. Πn = set of all single-variable polynomials of degree n or less.
e .
g . T1
=
(ax b/a
+
,
be (R3
ex+ 1 Te
·
x Te
1G Te To ? T T2 ...
less. 8,
=
2 x +
1
e .
g .
I 1
10
=
2
X
r2
=
A!x = !b
I- )(ii)=(]
or invertible
has exactly one solution if and only if A is non-singular.
.
1
1. Polynomial interpolation
Examples
conditions. y (1 , 3)
-
-
⑧
(a) p is of degree 0. - Po
- Pi
Po(X)
=
3 I >X
P , (X) =
ax +
(3 -
a)
Therefore 3 =
all + b
I a GIR a F
O
= b = 3 -
a ,
following conditions.
(a) q is of degree 0.
No solution .
g , (x) ax b
(b) q is of degree 1. Let
+
=
a(l) b 3 b b
[2a
a
=
a
E
3
+ + =
2 1
=
=
=
=> =>
,
a(2) 1 +
b 5
5
=
+ =
Therefore , G (x)
=
2x +
1
2
,
-
* (2 5)
(1 , 3) ,
(c) q is of degree 2.
Let & ,(x)
=
ax bx + +
c
b c 3b =
2 -
39
E
a
=
+ +
[
a(1) b() c 3
[4a
= =
+ +
c =
1 29
2b
=> +
=>
+
c =
5
a(22) +
b(z) +
c
=
5
3. Find a polynomial r through (1, 3), (2, 5), and (4, 7) satisfying
(a) r is of degree 0.
N solution
(b) r is of degree 1.
(1 , 31 , (2 , 5) (4 , 7)
solution
,
No
Let ax bx c
(c) r is of degree 2. 82(x)
= + +
b c 3 *
=
=
a + +
E 4a 2b + 5
=
r(x) x
3x+
+
= -
=
= +
169 +
4b +
c =
7 c =
3
(d) r is of degree 3.
((x)
=
ax +
(-Exa)x2 +
(3 +
14a) x +
(1 )
a =O a G IR
3 ,
Questions. Suppose there are n+1 points (x0, y0), (x1, y1), . . . , (xn, yn)
these points?
No
,
except special case .
4
Definitions.
Interpolation methods.
of distinct points .
Te
Find a polynomial in P
X3 that goes through (0, 5), (1, 1), (2, −3), (3, −1).
1. Method I. Use direct approach. Let
0 a 0 b 0 c d 5 a 1
E
=
. =
+
S
+ +
. .
7 a +
b +
c d =
1 b = -
3
I
+
C = 2
+b
-
8a +
+
22 +
d = -
3
a =
5
27a +
ab +
3c + d =
-
1
so
, Py(X)
=
x -
3x2 -
2x +
5
5
10, 5) (1 , 1) (2 -3) [3 -1)
, , , , ,
q3(x) = γ0 +γ1(x−0)+γ2(x−0)(x−1)+γ3(x−0)(x−1)(x−2).
U
-
4
W 1
= =
- 1
=
5
+
02(2 0)(2-1)
-
=
-
5 +
( -
4)(2) +
We(2)(1) = -
=>
U2 =
0
iy
Uz 1
=
=>
=>
Gz(x) =
5 +
( 4)(X 0)
-
- +
0(x 0)(X 1) - -
+
(1)(X 0)(X 1)(X 2)
-
- -
Ps .
can
by
expanding i ,
and simplify
to ge P3 .
5 +
( 4)(X 0)
-
- +
0(X 0)(X 1)
- -
+
(1)(X 0)(X 1)(X 2)
-
- -
5 -
4x
+
x(x2 -
3x +
2)
5 x3 3x2
=
4X +
2x
-
- +
x3 -
3x2 -
2x +
5
4 (4)
=
,
Points (0, 5) 11 1) (2 -3) (3 1)
-
:
, , , , , ,
(40s Y0) , <41 , 31) 33) , (X2 , %2) , (Xs ,
2 xz =
3
Consider
=
, , , ,
Yo 5 y, 3, 43 1
1 y
-
= -
, =
, =
+ . -
-
where
lo(Xo) 1
2 Xo) =
0 - 5
= ,
If we can find #0, #1, #2, #3 that satisfy the properties above,
locx) =
then we are done. X-3)
Yo 0
(o -
1)(0 -
2) (0-3)
x, 1
(i) Find #0(x) satisfying
=
xe = 2
(I) #0(0) = 1,
From (I)-(IE) we get
x= =
3 ,
3)
7
(ii)
Yo 0
(x − 0)(x − 2)(x − 3)
#1(x) = ,
x, =
1 (1 − 0)(1 − 2)(1 − 3)
(x − 0)(x − 1)(x − 3)
xe = 2 #2(x) = ,
(2 − 0)(2 − 1)(2 − 3)
x3 =
3 (x − 0)(x − 1)(x − 2)
#3(x) = .
(3 − 0)(3 − 1)(3 − 2)
P .
conclusion
8
Conclusion.
Given n+1 points (x0, y0), (x1, y1), . . . , (xn, yn) where x0, x1, . . . , xn
Write
y0 = anxn0 + an−1xn−1
0 + . . . + a1x0 + a0,
y1 = anxn1 + an−1xn−1
1 + . . . + a1x1 + a0,
...
yn = anxnn + an−1xn−1
n + . . . + a1 x n + a0 .
results.
9
2. Newton’s method (Method II).
Write pn(x) as
then solve for γ0, …, γn in that order by plugging-in (x0, y0), . . . , (xn, yn),
10
3. Lagrange’s method (Method III).
where
#n,i(xi) = 1,
#n,i(xj ) = 0, j != i.
11
-> 83
Ex Find
polynomial that
goes through
1-2 , 11 10, 3) (4 , 7) (5 , 3)
, , ,
, -
+
v(x +
2)(X -
0)(X -
4)
①(x , y) =
( -
2 1) = Vo
=
1
,
② (X , y) =
(0 3) =
0 +
U (0 +
2) =
3 =
1 +
20 =
3
, x
, ,
=>
W =
, 1
③ (X , y) =
(4 , 7) =
8 +
2 (4
,
+
2) +
82(4 2)(4 0) +
-
=
7
1(6) Uz(b)(4)
=>
1 7
+ +
= U2 =
0
④ (X, y) =
(5 3) =
Vo +
0
, (5 +
2) +
02 (5 2)(5 0)+
-
+
U3(5 2)(5 0)(5 4) 3
+
- - =
= 1 1(7) 0 Vy(7)(5)(1) 3
+ + +
=
03
2
=> -
=
Therefore
, q,(x) =
1 +
(x +
2) -
I(x +
2)(X - 0)(X -
4)
Simplify :
q,(x) =
1 +
(x +
2) -
I(x +
2)(X 0)(X
-
-
4)
1
I(x3 2x2 8x)
=
x +
2 -
-
-
x3
2x2 Ex
= - +
+
+
to find a
polynomial is that
goes through
1-2 , 11 10, 3) (4 , 7) (5 , 3)
, , ,
2
Xo x1 Y2 4 5
-
=
0
xz
=
= =
sation , , ,
r(x)
=
1 .(x) +
3-l ,"(x) +
7 -
l(x) +
3 .
l,)
(X 0)(X 4)(X 5)
lo"(X)=
- - -
where -
0)( 2 4) 2 5)
(
-
2
-
- - -
(x +
(0 +
2)(0 -
4) (0-5)
e"(x)
0)(x 5)
-
-
(4 2)(4 0)(4 5)
+
- -
e,(x) =
( )(X-4)
(5 2)(5 + -
0)(5 -
4)
=
Tz(X) =
1 . -4)(X 5) - -
( - 2 -
0)( -
2 -
4) - 2 -
5)
5)
+ 34)(X- e
(x +
2)(x - 0) (x -
5)
(0 +
2)(0-4)(0- 5) (4 2)(4 0)(4+ - -
5)
y()(X 4)
-
+
2)(5 0)(5
(5 + -
-
4)
Divided difference (40 40)
, , - .., (Xn , Yn)
Recall the Newton’s method
(1)
γ0 = f (x0),
f (x1) − f (x0)
γ1 = ,
x1 − x0
is its
... -
↑
-
E ↑
E Xz-
x1
Uz =
E -
- Xe -
Xo W
W
f(x3) f(xe)
fo
-
-
f(xa)-f(x ) ifexa)-fex
, , )
-
X
x2 x2 x +
-
- Xz x1
-
-
7
↑
X3 x1
-
------
~
xo -
Uz
=
X -
Yo
3
i 12
Define the divided difference recursively as
General case : f [x
f [x1 . . . xn] − f [x0x1 . . . xn−1]
0 x1 . . . x n ] = ,
xn − x0
γ0 = f [x0], =
f(xo)
f.
+2x)
-
γ1 = f [x0x1], - =
x, -
xo
γ2 = f [x0x1x2],
!
...
γn = f [x0x1 . . . xn].
rz
f [xxxi
=
Xc -
X
,
X
,
-
Xo
-
-
Xe -
Xo
13
Example (revisitted)
Find
polynomial &z that
goes through
1-2 , 11 10, 3) (4 , 7) (5 , 3)
, , ,
, -
+
v(x +
2)(X -
0)(X -
4)
X y 22
f2 -
0)
=
vo 2,
f(
-
0
21
Y
=
2 ,0 ,
4)
f
-
> 31 0
=
- 1
O 3 0 -( 2) I
7 ⑧ 53
-
> 73 1 4 ( - 2)
-
-
=
47
4 -
0
S 1
-
=-1
>
53 3 = -
4 5 -
0
11
↑ ( - 2 0, 4 5)
, ,
Therefore
, q (x)
,
=
1 +
(x +
2) -
I(x +
2)(X - 0)(X -
4)
Example. Find Newton polynomial for the data below.
x 3 1 5 6
f(x) 1 -3 2 4
P , (x)
- -
26
+ +
=
3)(X 1)(X 5)
Uy(x
-
-
-
+
↳-
D
x I f23] fan
vo
①
51 f 23 453
,
3 1
=
3 02
O
-
-
↳ -
2
1 3
↳
-
1
-
3
Us
I 2 3
=
2) t
+
5 2 5 -
>
,
=
2) =
6 4 20
abs
f ,, 5 ,s
40
14
Polynomial interpolation theorems.
Let x0, x1, . . . , xn be distinct points and let y0, y2, . . . , yn be asso-
Proof. We let
a0 + a1x0 + . . . + an−1xn−1
0 + anxn0 = y0
a0 + a1x1 + . . . + an−1xn−1
1 + anxn1 = y1
...
a0 + a1xn + . . . + an−1xn−1
n + anxnn = yn
Vn!a = !y
15
where
1 x0 x20 · · · xn0 a0 y0
2
x1 x1 · · · x1 n a1 y1
1
Vn = , !a = , !y =
.. ... ... . . . ... ... ...
.
1 xn x2n · · · xnn an yn
is given by
'
detVn = (xi − xj )
i>j
whenever i =j -
16
Theorem 2. (Error analysis.)
max {x0, x1, . . . , xn, x}. Let pn(x) be the interpolating polyno-
that
ωn+1(x) (n+1)
f (x) − pn(x) = f (ξx),
(n + 1)!
where ωn+1 = (x − x0)(x − x1) · . . . · (x − xn).
17
0 4741213 + 0 4785665
109
.
(3 005).
-
-
.
, 2
Example.
4748439
* 0
=
at any two consecutive points from 1.00, 1.01, 1.02, 1.03, . . . , 9.99.
Then,
Proof. f 109 , X
-
=
~ · P, x
,
18
* sooro2
Special cases.
1. Equally-spaced points.
b−a
Let xi = a + ih, i = 0, . . . , n where h = . We can
h
n!
show that, for x ∈ [a, b], |ωn+1(x)| ≤ hn+1 . Therefore, we
4
have that
hn+1
|f (x) − pn(x)| ≤ max f (n+1) (x)
4(n + 1) x∈[a,b]
The Chebyshev points (or nodes) are the zeros of Tn+1, given
( 2i+1 )
by xi = cos 2n+2 π , i = 0, . . . , n. In this case, ωn+1(x) =
1
|f (x) − pn(x)| ≤ n
max f (n+1) (x)
2 (n + 1)! x∈[a,b]
19
Interpolation using other functions.
Given three data points (x0, y0), (x1, y1), (x2, y2).
1. Rational function.
* *
* *
* y0 x0 − x (x0 − x)y0 **
*
* *
* *
* y1 x1 − x (x1 − x)y1 **
*
* *
* *
* y2 x2 − x (x2 − x)y2 *
r(x) = * *
* *
* 1 x0 − x (x0 − x)y0 **
*
* *
* *
* 1 x1 − x (x1 − x)y1 **
*
* *
* *
* 1 x2 − x (x2 − x)y2 *
2. Trigonometry function.
20
1st degree
poly nomial
* 3. Piecewise Polynomial. For example, piecewise0
linear in-
terpolation.
IM
-
piecewise
quadratic
interpolation
(1 1)
,
Can show that
!·
(3
,
-
1)
-
4x
+
5 x 21 , 2)
(
f(x) =
,
2x 7 x G 22, 3]
-
,
(2 -3)
,
Canurio)
Note The is
.
answer
unique .
21
(1 , 1)
in miknntmowogres
9 [fex)
b 23
ax x = [1 ,
=
+
⑧
13, -1) ,
f(x) =
⑧
fz(x) =
(x + d
,
x E 22 3]
,
(2 -3)
,
ve on a
,
b
,
c
,
d dist
Taiwa 2
paruwa on Pre mi
0 fe(x) =
Wo
+
U
,
(x-1)
Ing 8
=
1
, 0,
=
= = -
4
2 -
1
EN f(x) =
1
-
4(X -
1) = -
4x +
5
② F2(X) : 65 f a wa (2 ,
-3) 110 =
(3, -
1)
Penrose (ar fa(x)
3
= - +
- )(X-2)
-
(3 2)
-
· q(f2(X) =
24-7
2. Find a piecewise quadratic function that goes through (1, 1),
b E [1 , 23
[f(x)
=
ax + x +
c
,
x
f(x) =
f2(x) =
dx +
ex +
9, x G [2 , 3]
goes through 21 1)
, ,
(2 -3)
, ,
(3, -1) .
sanucrot(
Note that the answer is NOT unique .
... to
smooth graph at
the connecting ,
point
we need to choose
fo ,
f such that
,
connecting point
22
fi(2) fz'(2) =
x
=
t
isn't
(2 -3)
,
riccovogue
ax + b x E [1 , 23
[f(x)
=
+
c x
,
f(x) =
f2(x) =
dx +
ex +
9, x G [2 , 3]
stan a . + b -
1
+
c =
1
E
9 - 22 +
b .
2 +
C =
-
3
a b c 1
ingut
+ + =
4a +
2b +
c = -
croumot(
22
02 01 660 = Wind 18
a +
b + c = 1 free variable)
E 4a +
2b +
c = -
3 ↓
↳osamboU 3 as is insuwatosa
ewnwo On :
a suw free variable : a
b 1 a (I)
E
c
= -
+
eb +
c
= -
3 - 4a (#)
(I) b 4 3a
-
(1)
-
=
=>
-
6695a b = -
4 -
3d Ostr(I)
↳ C =
1 -
a -
b = 1 -
a -
( 4 -
-
3a)
5 +
2a
now fi(x) ax
= +
( -4-3a) x
+
(5 +
2a)
② en
fex) : wiwgn(2 ,
-3)
,
13
,
-1)
d 2
2 + e g 3
-
on (do z2
. +
= -
+ e -
z +
g =
-
>rouric)
4d +
2e
g =
-
jus
+
·
qd 3e 1
+
g = -
+
32
g -1 9d(IV)
+
= -
(AV) (1) e 2 5d
=
=> -
6642 e =
2 -
5d0sPr (#)
5d)
petg 3 4d 2(2
- -
= - -
=
1 +
6d
nswf(x) = dx +
(2 -
5d) x +
( 7
-
+
6d)
Islni
(& )
fi(x) =
ax +
( -
4 -
3a)x
+
(5 +
2a) 12 x 2
[
=
,
f(x) =
f2(x) = dx +
(2 -
5d)x +
( 7
-
+
6d) 22x =
3
,
Moon a d Fo .
1 d =
-1 pila"
,
fexs-(***** !I = s s
E
D
main vos I
f
I-
L -
t
-
↑
fz
Ibar (not smooth)
Mepwormoni 12
,
-3)
f(x
(f)(x) 7 1x 2
2x
-
= =
=
,
fe(x) = -
2x +
7
,
2 = X =
3
f(2)) =
f , (2) =
2(2) -
1 =
-
3
x -
2-
66=
limf(x) =
f(2+) fz(z) =
=
-
212) +
7 =
3
x- 2+
Estonis
GoProudionon (2
,
-3) Eneza smooth
Mow
+!(x) = 2ax
+
( 4
- -
3a)
more
!(2) +(2) =
E f((x) 2dx
=
+
(2 -
5d)
now Moses 20 2 + (-4 3a) 2d 2
5d)
. =
-
(2
-
+ -
=>
4a -4 -3a =
4d +
2 -
5d
=> a -
4 =
-
d +
2
2nd = 6 -
a
is i w o : mostat denmis (A)
(5 2a) 1 x 2
(f(x)
3a)
+
= ax +
( -
4 -
x +
,
=
f(x) =
f(x) =
(6 a)x2
-
+
) -
28 +
5a)x +
(29 6a) -
21 x = 3
,
M .
Ou a =
1 0 :
2
x -
xx
+
1 12 X =
2
f(x) ,
S
=
5x2 -
23 x +
23 , 2 X =3
f(x) =
3* s
f(2) = 212) -
1 = -
65 x
=
2 0 :
(f(24) =
10(2) -
23 =
-
N27864
bremrnf
in 2-spline
fr 45
·
·
I
-
quadratic
spline
3. Find a piecewise cubic function that goes through (1, 1), (2, −3),
is
fixs :
(Tc-axetDextea See
① m f:
=
Mos oddos i bordu
f, (1) b +
4 d
1 a 1
+ +
= =
=
, ,
f((z) =
3 =89
-
+
4b +
2, +
d, = -
3
,
I
Ou a ,
b
,
sw free variable
2
4 79,
-
3b ,
S
,
=
- -
1 inNn1s 0 : a
d 2b
5
= +
ba , ,
23
② unfr : O : mossounosirsordr
4b2 22 d2 3
=
fz(2)
-
3
+
89
+
+
= - =
f2(3) 9b2 32 dz = 1
+
2792
-
+
1
+
=
-
=
② free
· n de be fer free variable
, variable
See a Robe
4 Ms
enero or
↑
n x b , x2
f , (X) =
a
,
+ +
( 4 7a ,
- - -
3b , )x +
(5 +
ba , +
2b
, )
f(x) =
4 x - [ 1 , 2] S
(f(x) =
a
,
x +
bex +
(2 -
1992 -
5b2)x +
( 7 -
+
30d2 +
6b2,
x G [ 2 3]
,
(i) + ! (2) =
!(2)
"
(ii) f ,
(2) =
72" (2)
join fur free variable 6450 2 as livs
2. Spline
te
2. s(x) ∈ P#[xi, xi+1) for i = 0, 1, . . . , n − 1.
Notations.
Eas (*)
24
Examples of splines interpolating the points
(1 1) 12 , -3) , (3 -1)
,
, ,
S1(X) 4x 5 xG 21 , 2]
E
+
= -
,
S(x) =
S (x) =
2x 7 x G [2, 3]
-
, ,
Note :
Unique !
② Quadratic spline (2-Spline)
3a)x (5 +
2a) 1 = x 2
S (x) ax ( 4 -
+ =
,
+ -
six)
,
S(x) =
(6 a) x
-
+
) -
28 +
5a)x +
(29 6a) -
21 x = 3
,
where a - IR a = 0 .
Note :
Not Unique !
when a 1 we have
Example : =
,
S , (X) = x2 -
xX
+
1 12 X = 2
,
S Se(X)
S(X) =
=
5x2 -
23 x +
23 , 2 X =3
S2
Se
Se
S2
Cubic spline. If s ∈ S3(Ωn), then s satisfies
1. s ∈ C2[a, b].
xite)
Iyxi ,
2. s ∈ P3[xi, xi+1), i = 0, . . . , n − 1.
s cont at
in Sin
si(xi) = si+1(xi), i = 1, 2, . . . , n − 1; , Xi
+ +
25
End conditions.
s!(a) = f !(a),
s!(b) = f !(b).
s!(a) = 0,
s!(b) = 0.
A
#
3. Natural end conditions:
s!!(a) = 0,
s!!(b) = 0.
s!(a) = s!(b),
s!!(a) = s!!(b).
26
Example.
""=8 I
x =
-
1
,
0
,
1
Find a natural cubic spline s(x) that interpolates (−1, 1), (0, 2),
(1, −1). -
I
Se Se
-
! >X
Solution. Let I
-
⑧ 1
s1(x) = a1x3 + b1x2 + c1x + d1, x ∈ [−1, 0],
s(x) =
s2(x) = a2x3 + b2x2 + c2x + d2, x ∈ [0, 1].
We get
s!1(x) = 3a1x2 + 2b1x + c1, x ∈ [−1, 0],
!
s (x) =
s!2(x) = 3a2x2 + 2b2x + c2, x ∈ [0, 1],
and
s!!1 (x) = 6a1x + 2b1, x ∈ [−1, 0],
!!
s (x) =
s!!2 (x) = 6a2x + 2b2, x ∈ [0, 1].
interpla"Yous
The following conditions need to be satisfied.
->
(i) s (−1) = 1, s (0) = 2, s (0) = 2, s (1) = −1.
1 1 2 2
13
1
+ -
-
=
, , , =
1
S 10) =
2 = d =
2
,
S (0)
,
= 2 = d = 2
S
S2() = -1 =
92 +
be +
2z +
dz =
-
1
- a +
b -
2 = -
1
E
,
->> ⑪
az +
b +
cz
=
-
(ii) S
! 10) =
! 10)
S = c
,
=
2 ②
2b2
" "
(iii) S
,
(0) =
S (0) = 2b =
, ,
=> b, =
be
six) =
0
692
=
+
2b = 0
,
=>
9 c
O
4
From &, 4 ,
we get a
,
=-
A2
From ①, &, we get
7
529
-2 =-
, ,
=>
C =
-
7
, de = -
1
202 +
2 = -
From ⑤, ac = 1
From b, =
-
3
,
b, = -
3
From &, 22 =
-1
ans
-
x3 3x2
-
-
x +
2
, x ∈ [−1, 0],
s(x) =
x
3 - 3x2 -
x +
2 , x ∈ [0, 1].
28
3. Curve fitting (using polynomial)
Idea: Given n+1 points (x0, y0), (x1, y1), . . . , (xn, yn), find a poly-
such that
n
%
E(pm) = E(a0, . . . , am) = {pm(xr ) − yr }2
r=0
anyo
is smallest.
a0, . . . , am. One can show that its minimum occurs at the critical
29
point a0, . . . , am satisfying
∂E
= 0, j = 0, . . . , m
∂aj
∂E ∂ & 2 2 2
'
= {pm(x0) − y0} + {pm(x1) − y1} + · · · + {pm(xn) − yn}
∂aj ∂aj
(
∂pm(x0) ∂pm(x1)
= 2 {pm(x0) − y0} + {pm(x1) − y1} + ···
∂aj ∂aj
)
∂pm(xn)
+ {pm(xn) − yn}
∂aj
& '
j j j
= 2 {pm(x0) − y0} x0 + {pm(x1) − y1} x1 + · · · + {pm(xn) − yn} xn
n
%
=2 {pm(xr ) − yr } xjr
r=0
%n n
%
=2 xjr pm(xr ) −2 yr xjr
r=0 r=0
30
The normal equations above can be written as matrix-vector form:
1 1 X 1 xY 1
-
-
y 1
.
.
x
x
A
- n - n - n
m a0 - n A
1 xr ··· xr yr
r=0 r=0 r=0 " r=0
n 1 X n X X x X a
- y X
- - 2 - n - n
.
-
.
1 .
xr xr ··· xm+1 yr xr
...
r=0 r r=0
r=0 r=0 =
. ... ...
.. ...
n a m−1
- m - n - n - n
m
xr xm+1
r · · · x 2m
r y r x r
r=0 r=0 r=0 am r=0
31
x1 4
xy 5)
1 3
(o=
=
x2
=
=
, , ,
-
Example. Use least square principle to find p1(x) that best fits
x 1 3 4 5
the data want to find
y 2 4 3 1 + a X
P1(X) Go
=
,
3
Eon e) (ai] (- I
EYr
:
Yur
[iii] (ai)= ( ] ,
(9i] x 12 [ ] [i]
=
[I]= 2:
PIX) =
5
=> -
32
****
-
Example. Use least square principle to find p2(x) that best fits
x 1 3 4 5
the data Let P (X)
2
=
90 + 9 x
,
+
92 X2
y 2 4 3 1
2
Consider Eldo, an ,
&2) =
3 (P2Xr)-yr)
r =
0
Yr]2
Stt
E = ↳[190 +
9
, xr
+
924)-Yr] :
1 = O
set
· =
(190 +9
, Xr+az4)-Yr] ·
Xr = O
set
92Yr)-yr] Yr2
0
~ [19
=
· & +9
& , xr
+
·
= -
z r=
simplify to get
= (90 9 Xr+ 92Xr) 1
= r
32gen) (ai
-
+
,
r
r = 0
3
& (90 + 9
, Xr+ 92Xr) ·
Xr =
Eor Xr
r = 0
= (90 + 9
, Xr+ 92Xr) .
Y =
Dr Xr
(g)
r = 0
-
33
Example. Use least square principle to find p2(x) that best fits
x 1 3 4 5
the data Pe(x) =
90 +
a
,
x +
92x2
y 2 4 3 1
I Exercisel (eit
Egix
1 r
453 3 4227
I q
= =
=
-
a
.
,
220
27/445
- 0 .
6136
92 =
-
33
Curve fitting using Exponential.
:
We can also use f (x) = aebx to fit the data (xi, yi) according to
the least square principle. In this case, we use log to transform the
f(x) =
y = aebX
problem into finding
Take In =>
Iny Ina +
InebX
I
=
.....
e
that best fits the data set (xi, Yi) where Yi = ln yi. Line ar
-
Procedure.
where Yi = ln yi
F (x) = A1x + A0
b = A1, a = eA0 .
34
Example. Use least square principle to find the exponential func-
x 1 3 4 6 9 15
Solution. Use ln to convert the data (xi, yi) into (xi, Yi) as
x 1 3 4 6 9 15
Let P , CX)
=
Ao+ A, X
E Ex .* )(i) [ =x !
5 5
[1
:
1 3354
et = 20
.
3 8014
(9
=
.
=
=>
.
044
(-0 044x)
.
f(x) 3 8014 e
=>
=
35
Curve fitting using Hyperbolic function. -I
We can also use Hyperbota
:L
it
b
↳i
f (x) = a + ......
x
ir e
.
to fit the data (xi, yi) according to the least square principle. In
⑧
1
this case, we use the change of variable X = to change the
x
13
a
E
= +
y =
a +
bl
f (X) = a + bX
1
that best fits the data set (Xi, yi) where Xi = .
xi
Procedure.
f (X) = A1X + A0
3. We have that
b = A1, a = A0 .
36
Example. Use least square principle to find the hyperbolic func-
Ao
,
-][i] L Er
Ed
j 5
=
Er 9
↳ b
2 364
1975
+
f(x)
=
.
37
Curve fitting using Trigonometry function.
Poonov
The fitting function is in the form
m m
a0 % %
t(x) = + ak cos(kωx) + bk sin(kωx)
2
k=1 k=1
E = E(a0 , . . . , am , b1 , . . . , bm )
n
%
= {t(xr ) − yr }2
r=1
%n n
% n
%
= yr2 −2 t(xr )yr + [t(xr )]2
r=1 r=1 r=1
n n
1 m m
2
% % a0 % %
= yr2 − 2 + ak cos(kωxr ) + bk sin(kωxr ) yr
r=1 r=1
2
k=1 k=1
n
1 m m
22
% a0 % %
+ + ak cos(kωxr ) + bk sin(kωxr )
r=1
2
k=1 k=1
∂E ∂E
=0 j = 0, 1, . . . , m and =0 j = 1, . . . , m
∂aj ∂bj
for j = 1, 2, . . . , m
38
& Noonfru
Example. Use m = 1, ω = 1. Find the Trigonometry function fitting for
x 0.0 0.4 0.8 1.2 1.6 2.0 2.4 2.8 3.2 3.6 4.0 4.4
y 3.0 2.1 1.3 0.5 0 −0.2 0 0.3 1.1 2.0 2.9 3.5
Solution. We get the normal equations
12
% 12
% 12
%
6a0 + cos xr a1 + sin xr b1 = yr
r=1 r=1 r=1
12
% 12
% 12
% %12
cos xr a0 + cos2 xr a1 + cos xr sin xr b1 = yr cos xr
r=1 r=1 r=1 r=1
%12 %12 12
% %12
sin xr a0 + cos xr sin xr a1 + sin2 xr b1 = yr sin xr
r=1 r=1 r=1 r=1
We get,
Thus,
39
4. Least square and inconsistent system of linear equa-
tions
... I
"
am1x1 + am2x2 . . . + amnxn = bm -
=errorm
The system can be written as A#x = #b where
a11 · · · a1n x1 b1
. ... , #x = ...
#b = ...
A = .. ,
am1 · · · amn xn bm
mxn nx1 mx 1
When there is no solution, the system is called inconsistent. The
~b
AX
best we can do is find #x such that
m
%
Ax -
B =
(!
E(x1, . . . , xn) = [(A#x − #b)i]2
i=1
2
m
% n
%
= aij xj − bi
i=1 j=1
is smallest.
40
Normal Equations Derivation. We need to find the critical point
satisfying
m
% %n
∂E
=2 aij xj − bi aik = 0
∂xk i=1 j=1
Define
m
% m
%
ckj = aij aik , dk = aik bi
i=1 i=1
% %#
=
5
A A#x = A b
Y =
A 5
That is,
man Case man
7 8−1 -
#x = A%A A%#b AY =
B ~
7 8−1 x <(b
Note. The matrix A%A is called Pseudo inverse of A.
=
It
41
Example. Find the least square solution of
x1 + x2 = 1
x1 − x2 = 2
x1 + 2x2 = −1
A
I = i]
+ = I
b
- 3 x 2 2x1
3x1
At Asur * Atexex
I
24 3 ex ,
[23]
+
,
=
(A
~ -
x
=
(ATA) ** S
( _ ,)
2x
x
,
=
=>
* (AT A) A]5
T
=
42
Linear curve fitting (revisited). Use least square principle
x 1 3 4 5
to find p1(x) that best fits the data
y 2 4 3 1
43