Professional Documents
Culture Documents
Leastsq E
Leastsq E
URL: http://www.maths.lth.se/na/
Examples:
• Fit straight line to measurement data
• Find continuous function that agrees with discrete
data (“digital-to-analogue conversion”)
Table of data:
x 1 2 3
y 1 2 2
2.5
1.5
0.5
0 0.5 1 1.5 2 2.5 3 3.5 4
Wishful thinking:
y ∗(1) = y(1) ⇒ c0 + c1 =1
y ∗(2) = y(2) ⇒ c0 + 2c1 =2
y ∗(3) = y(3) ⇒ c0 + 3c1 =2
2.5
1.5
0.5
0 0.5 1 1.5 2 2.5 3 3.5 4
2c0 + 3c1 = 3
2c1 = 1 ⇒ c1 = 1/2, c0 = 3/4
3
Best (minimax) approximation: y ∗ (x) = 4 + 12 x
Note only for three points; otherwise Remes’ algorithm
minimax 2
1.5
Solid line:
1
least squares
0.5
0 0.5 1 1.5 2 2.5 3 3.5 4
Data
x 1 2 3
y 1 2 2
Minimax solution
y∗ 5/4 7/4 9/4
e 1/4 −1/4 1/4 kek∞ = 1/4 kek22 = 3/16
Ax ≈ b ; A ∈ Rm×n ; m>n
Problem:
min kAx − bk2
x
r = Ax − b ⇒ r T r = kAx − bk22
Quadratic form:
AT (Ax − b) = 0 ⇔ AT r = 0
Normal equations: AT Ax = AT b
• det AT A 6= 0
• AT A > 0 (positive definite)
• normal equations give the minimum solution
• (AT A)−1AT is called the pseudo inverse of A.
Overdetermined system Ac ≈ y:
1 1 1
1 2 c 0
≈ 2
c1
1 3 2
1 1
T 1 1 1
A= 1 2 ⇒ A = .
1 2 3
1 3
Normal equations AT Ac = AT y:
3 6 c0 5
=
6 14 c1 11
Solution: c0 = 23 ; c1 = 1
2 ⇒ y ∗(x) = 2
3 + 21 x.
Important examples:
• Orthogonal polynomials
• Fourier analysis
• the Finite Element Method
Pythagorean theorem:
Proof:
Discrete case:
m
X m
X
hf, gi = f (xi)g(xi); kf k22 = f (xi)2
i=1 i=1
T
kf k22 fi2.
P P
Compare f g = figi and =
Continuous case:
Z 1 Z 1
hf, gi = f (x)g(x) dx; kf k22 = f (x)2 dx
0 0
Orthogonal systems:
A set of functions Φ = {ϕj } is an orthogonal system
with respect to h·, ·i if
hϕi, ϕj i = 0 i 6= j.
f ∗ − f ⊥ ϕj ∀j.
Normal equations:
hϕi, f ∗ − f i =0 ∀i ⇒
P
hϕi, j cj ϕj i = hϕi, f i ⇒
P
j hϕi, ϕj icj = hϕi, f i
hϕi, f i
ci =
hϕi, ϕii
kf ∗ − f k22 ≤ kg − f k22
for any g = Σj cj ϕj .