Find the closest point ax to b

407 Views Asked by At

$$ A= \begin{pmatrix} 1 & 5\\ 2 & -2\\ -1 & 1 \end{pmatrix} $$

$$ b= \begin{pmatrix} 3 \\ 2 \\5 \end{pmatrix} $$

this is another one of those least square solution problems which are a pain to compute by hand, so i will skip most of the computation and show the results

To find the least square solution, i am supposed to use this equation.

$x = inverse(A^TA) * A^Tb $

and this is what i got for x = [1/3 , 8/15] , this is the least square solution

now i am being asked to find the distance from Ax to b

and i think im supposed to use the formula

||b - Ax||

is this the correct formula to find the distance between Ax and b?

the result i got was 5.36656, i need someone to check this for me

1

There are 1 best solutions below

0
On BEST ANSWER

As a student of mathematics, it is very beneficial to learn a programming like mathematical programming language like MATLAB or Mathematica so you can check your work. For example, using MATLAB, we compute

>> A = [1 5;2 -2;-1 1]

A =

     1     5
     2    -2
    -1     1

>> b = [3;2;5]

b =

     3
     2
     5

>> x = [1/3;8/15]

x =

    0.3333
    0.5333

>> norm(A*x-b, 2)

ans =

    5.3666

So yes, you are right.