I am currently trying to use iterative least squares to solve a system, $y = Hx + v$ where $y$ is a vector of observations, $H$ is the design matrix, and $v$ is the observation error.
From my understanding, iterative least squares tries to minimize a cost $J$ where $J = \min (Hx-y)^2$.
My pseudocode for this is
while ||x^k-x^{k-1}||
H = h(x^{k-1})
r = f(x^{k-1}) - y
dx = pinv(H)*r
x^{k} = x^{k-1} + dx
end
where $H$ is the Jacobian and the output of $f(x)$ is the expected observations.
Can $r$ be called the cost of the system because it is the residual/difference between $f(x)$ at estimate $x^{k-1}$ and $y$? Should it be squared in an implementation of iterative least squares?