Constrained Least Squares - Slides
Constrained Least Squares - Slides
Stephen Boyd
EE103
Stanford University
November 9, 2017
Outline
p(x) = θ1 + θ2 x + θ3 x2 + θ4 x3
x≤a
fˆ(x) =
q(x) = θ5 + θ6 x + θ7 x2 + θ8 x3 x>a
(a is given)
I we require p(a) = q(a), p0 (a) = q 0 (a)
I fit fˆ to data (xi , yi ), i = 1, . . . , N by minimizing sum square error
N
X
(fˆ(xi ) − yi )2
i=1
fˆ(x)
q(x)
p(x)
x
a
θ1 + θ2 a + θ3 a2 + θ4 a3 − θ5 − θ6 a − θ7 a2 − θ8 a3 = 0
2 2
θ2 + 2θ3 a + 3θ4 a − θ6 − 2θ7 a − 3θ8 a = 0
minimize kxk2
subject to Cx = d
i.e., find the smallest vector that satisfies a set of linear equations
v fin = f1 + f2 + · · · + f10
fin
p = (19/2)f1 + (17/2)f2 + · · · + (1/2)f10
1 1
Position
Force
0 0.5
−1 0
0 2 4 6 8 10 0 2 4 6 8 10
Time Time
minimize kf k2
1 1 ··· 1 1 0
subject to f=
19/2 17/2 ··· 3/2 1/2 1
with variable f
I solution f ln satisfies kf ln k2 = 0.0121 (compare to kf bb k2 = 2)
1
0.05
Position
Force
0 0.5
−0.05
0
0 2 4 6 8 10 0 2 4 6 8 10
Time Time
∂L
I (x̂, z) = cTi x̂ − di = 0, which we already knew
∂zi
I first n equations are more interesting:
n p
∂L X X
(x̂, z) = 2 (AT A)ij x̂j − 2(AT b)i + zj ci = 0
∂xi j=1 j=1
2AT A C T 2AT b
x̂
=
C 0 z d
I implies m + p ≥ n, p ≤ n
I can compute x̂ in 2mn2 + 2(n + p)3 flops; order is n3 flops
2I C T
x̂ 0
=
C 0 z d
x̂ = C T (CC T )−1 d = C † d