Using Least Squares to get the 'input'

53 Views Asked by At

I would like to solve the system of equations $$Ax=B$$ for $x$. However, unlike almost every tutorial on the internet, I do NOT want the coefficients of the operator $A$ - rather I want the actual inputs $x$. To be specific, let $$A=\begin{bmatrix} 3& 5x & 6x^2 & 7sin(x) \end{bmatrix}$$ (Where there will be as many rows as there are measurements or inputs) I know how to get the vector $\beta=\begin{bmatrix}1& 5 & 6 & 7\end{bmatrix}$, that is simply $\beta=(A^TA)^{-1}A^TB$. But how can I use Least Squares to get $x$ given the form of $A$ and the output $B$? (If this is nonlinear, you can drop the last two terms in $A$)

1

There are 1 best solutions below

4
On BEST ANSWER

Taking the example we have

$$ \epsilon^2(x) = \Vert A(x) x-B\Vert^2 = 111 - 6 x - 41 x^2 - 72 x^3 + 25 x^4 + 36 x^6 - 98 x \sin(x) + 49 x^2 \sin^2(x) $$

and then

$$ x = \arg \min_x \epsilon^2(x) = 1.00885 $$

If you have instead

$$ x = (x_1,x_2,x_3,x_4) $$

$$ A(x) = \left( \begin{array}{cccc} 3 & 5 x_1 & 6x_1^2& 7\sin x_1 \\ 3 & 5 x_2 & 6x_2^2& 7\sin x_2 \\ 3 & 5 x_3 & 6x_3^2& 7\sin x_3 \\ 3 & 5 x_4 & 6x_4^2& 7\sin x_4 \end{array} \right) $$

then

$$ \epsilon^2(x) = \Vert A(x) x-B\Vert^2 $$

and

$$ x = \arg \min_x \epsilon^2(x) = (0.0925942,\ 0.516572,\ 0.608943,\ 0.697946) $$

with a RMSE of $\epsilon \approx 1.88411\times10^{-15}$

The $\epsilon^2(x)$ minimization should follow a Newton-Raphson like procedure.