
LINLSQX.OMS
Script File:
# Description:
# Solves the minimum norm of a singular linear least squares problem.
#
# The objective function for this problem is
# f(x) = (x(1) + x(2)  1)^2 + (x(1) + x(2)  2)^2
#
# The partial of f with respect to x(1) or with respect to x(2) is
# (x(1) + x(2)  1) + (x(1) + x(2)  2)
#
# The function f is convex, it is minimized when its partials are zero; i.e.,
# 2 * x(1) + 2 * x(2)  3 = 0
# x(2) = 1.5  x(1)
#
# linlsq will return the x that minimizes x^2 subject to x(2) = 1.5  x(1)
# g(x(1)) = x^2 = x(1)^2 + x(2)^2 = x(1)^2 + (1.5  x(1))^2
# g'(x(1)) = 2 * x(1) + 2 * (1.5  x(1)) = 0 implies that x(1) = .75
#
#
# f(x) =  A * x  b ^2 where A and b are defined as
#
clear
A = { [1., 1.], [1., 1.] }
b = {1., 2.}
eps = 1e7
x = linlsq(A, b, eps)
print "x =", x
Output:
x = {
0.75000
0.75000
}

