Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· OpenAIAi2 WildChat-4.8M (AI2)

A={{1,1,0,},{-2,-1,2,},{-1,1,0,},{2,-2,0,}} b={{-2},{3},{-3},{2}} The system Ax=b has a…

  1. User

    A={{1,1,0,},{-2,-1,2,},{-1,1,0,},{2,-2,0,}} b={{-2},{3},{-3},{2}} The system Ax=b has a unique least squares solution u = {x,y,z} a. Find x,y and z b. Compute the “least square error” ||\boldsymbol{b}-\boldsymbol{Au}||^2

  2. Assistant

    a. First, let's write down the normal equations for the least squares problem:

    A^T * A * u = A^T * b

    A^T is the transpose of matrix A:

    A^T = {{1, -2, -1, 2}, {1, -1, 1, -2}, {0, 2, 0, 0}}

    Now, let's calculate A^T * A:

    A^T * A = {{1+4+1+4, -1-1-2+2, -1-1}, {-1-1-2+2, 1+1+4-4, 1+1}, {-1-1, 1+1, 0}}

    A^T * A = {{10, -2, -2}, {-2, 6, 2}, {-2, 2, 0}}

    And let's also compute A^T * b:

    A^T * b = {{1(-2)+(-2)(3)+(-1)(-3)+2(2)}, {(-2)+(-1)(3)+1(-3)-2(2)}, {2(3)}}

    A^T * b = {{13}, {-9}, {6}}

    Now, we solve the system of linear equations A^T * A * u = A^T * b:

    10x - 2y - 2z = 13 -2x + 6y + 2z = -9 -2x + 2y = 6

    From the third equation, we get

    y = 3 - x

    Now plug this into the second equation:

    -2x + 6(3 - x) + 2z = -9

    -2x + 18 - 6x + 2z = -9

    Now plug y = 3 - x into the first equation:

    10x - 2(3 - x) - 2z = 13

    10x - 6 + 2x - 2z = 13

    12x - 2z = 19

    Now we have a system of 2 equations with 2 variables:

    4x - z = 5 -4x + 4y = 12

    Solve for z:

    z = 4x - 5

    Then plug into the second equation:

    -4x + 4(3 - x) = 12

    -4x + 12 - 4x = 12

    Now solve for x:

    x = 1.5

    And plug back to find y and z:

    y = 3 - x = 3 - 1.5 = 1.5

    z = 4x - 5 = 4(1.5) - 5 = 1

    So the unique least squares solution is u = {x, y, z} = {1.5, 1.5, 1}

    b. To compute the least square error, we first need to find Au:

    A * u = {{1,1,0},{-2,-1,2},{-1,1,0},{2,-2,0}} * {{1.5},{1.5},{1}}

    A * u = {{1.5+1.5}, {-3-1.5+2}, {-1.5+1.5}, {3-3}}

    A* u = {{3}, {-2}, {0}, {0}}

    Now, we find the difference b - Au:

    b - Au = {{-2 - 3}, {3 - (-2)}, {-3 - 0}, {2 - 0}}

    b - Au = {{-5}, {5}, {-3}, {2}}

    Finally, we compute the norm squared of this vector:

    ||b - Au||^2 = (-5)^2 + 5^2 + (-3)^2 + 2^2 = 25 + 25 + 9 + 4 = 63

    Thus, the least square error is ||b-Au||^2 = 63.