How Do You Minimize the Squared Distance to a Line Using Linear Algebra?

In summary, the formula E(a,b) is used to measure the distance between a line and a set of points. The task is to minimize E(a,b) by finding the values of a and b that result in that minimum. This is done by taking the partial derivatives of E with respect to a and b and setting them to zero. The resulting equations involve the averages and dot products of the given vectors.
  • #1
Mathman23
254
0
The following formula [tex]E(a,b) = \sum_{j=1} ^{N} (y_{i} - (a + b_{i})^2[/tex] is used to messure the distance between the points [tex](x_1,y_1),(x_2,y_2), \ldots, (x_n, y_n) \in \mathbb{R}^2 [/tex] and the line [itex]y=a+bx[/itex]

I need to find a set of points [tex](a,b) \in \mathbb{R}^2[/tex] where E(a,b) using tools of linear Algebra.

I'm given the following vectors:

[tex]x = \left [ \begin{array}{c} x_{1} \\ \vdots \\ x_{N} \end{array} \right ], v = \left [ \begin{array}{c} y_{1} \\ \vdots \\ y_{N} \end{array} \right ], \ \ \overline{x} = \frac{1}{N} \sum_{j=1} ^N x_{i}, \ \ \overline{y} = \frac{1}{N} \sum_{j=1} ^N y_{i} [/tex]

I'm tasked with calculating [tex] \mathb{\frac{dE}{da}} , \mathb{\frac{dE}{db}}[/tex] and showing that if [tex] \mathb{\frac{dE}{da}}=0 , \mathb{\frac{dE}{db}}= 0[/tex] leads to the linear system.

[tex]A \left [ \begin{array}{c} a \\ b \end{array} \right ] = c[/tex], where [tex]A = \left [ \begin{array}{cc} \frac{1}{x} \ \ \overline{x} \\ \ \ \frac{x \cdot x}{N} \end{array} \right ][/tex] and [tex] c = \left [ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N}\end{array} \right ] [/tex]

Anybody have any hits/idear for to solve this assignment ??

Many thanks in advance

Sincerley Fred
 
Physics news on Phys.org
  • #2
Mathman23 said:
The following formula [tex]E(a,b) = \sum_{j=1} ^{N} (y_{i} - (a + b_{i})^2[/tex] is used to messure the distance between the points [tex](x_1,y_1),(x_2,y_2), \ldots, (x_n, y_n) \in \mathbb{R}^2 [/tex] and the line [itex]y=a+bx[/itex]

I need to find a set of points [tex](a,b) \in \mathbb{R}^2[/tex] where E(a,b) using tools of linear Algebra.

I'm given the following vectors:

[tex]x = \left [ \begin{array}{c} x_{1} \\ \vdots \\ x_{N} \end{array} \right ], v = \left [ \begin{array}{c} y_{1} \\ \vdots \\ y_{N} \end{array} \right ], \ \ \overline{x} = \frac{1}{N} \sum_{j=1} ^N x_{i}, \ \ \overline{y} = \frac{1}{N} \sum_{j=1} ^N y_{i} [/tex]

I'm tasked with calculating [tex] \mathb{\frac{dE}{da}} , \mathb{\frac{dE}{db}}[/tex] and showing that if [tex] \mathb{\frac{dE}{da}}=0 , \mathb{\frac{dE}{db}}= 0[/tex] leads to the linear system.

[tex]A \left [ \begin{array}{c} a \\ b \end{array} \right ] = c[/tex], where [tex]A = \left [ \begin{array}{cc} \frac{1}{x} \ \ \overline{x} \\ \ \ \frac{x \cdot x}{N} \end{array} \right ][/tex] and [tex] c = \left [ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N}\end{array} \right ] [/tex]

Anybody have any hits/idear for to solve this assignment ??

Many thanks in advance

Sincerley Fred

First, let's make sure the problem is understood. This looks to me like the problem of linear regression. E(a,b) is the sum of the squared deviations in the y (vertical) direction of the data points from the line y = a + bx. Your task is to minimize E(a,b) by finding the values of a and b that result in that minimum. That point is found by taking the partial derivatives of E with respect to a and b and setting each to zero. Your derivatives should be

[tex] \mathb{\frac{\partial E}{\partial a}}=0 , \mathb{\frac{\partial E}{\partial b}}= 0[/tex]

and your first equation should read

[tex]E(a,b) = \sum_{j=1} ^{N} (y_{j} - (a + bx_{j}))^2[/tex]

What is missing in the matrix?

[tex]A = \left [ \begin{array}{cc} \frac{1}{x} \ \ \overline{x} \\ \ \ \frac{x \cdot x}{N} \end{array} \right ][/tex]

Looks like is should be this

[tex]A = \left[ {\begin{array}{*{20}c}
1 & {\overline x } \\
{\overline x } & {\frac{{ x \cdot x }}{N}} \\
\end{array}} \right][/tex]
 
Last edited:
  • #3
arildno said:
Actually, his first equation should read:
[tex]E(a,b)=\sum_{j=1}^{N}(y_{j}-(a+bx_{j}))^{2}[/tex]
EDIT:
I see OlderDan edited his reply; the index must agree too, of course.

Yep.. I missed the index. good catch.. I will fix that in my previous post also.

I missed the bottom half of those partial derivatives too :rolleyes: . I fixed those also.

And then there are the other index problems from the OP

[tex] \overline{x} = \frac{1}{N} \sum_{j=1} ^N x_{j}, \ \ \overline{y} = \frac{1}{N} \sum_{j=1} ^N y_{j} [/tex]
 
Last edited:
  • #4
Hi

The matrix is suppose to look like this.

[tex]A = \left [ \begin{array}{cc} 1 & \overline{x} \\ \overline{x} & \frac{x \cdot x}{N} \end{array} \right ][/tex]

/Fred
 
Last edited:
  • #5
Mathman23 said:
Hi

I'm not sure what is missing in the matrix. Whats how my professor presented it.

/Fred

I think you copied it wrong. I just added what I think it should be to my first post.
 
  • #6
Hi Dan and thanks for Your answer,

Then taking the partial derivative of E. First step is that to write the complete sum-formula ??

/Fred

OlderDan said:
First, let's make sure the problem is understood. This looks to me like the problem of linear regression. E(a,b) is the sum of the squared deviations in the y (vertical) direction of the data points from the line y = a + bx. Your task is to minimize E(a,b) by finding the values of a and b that result in that minimum. That point is found by taking the partial derivatives of E with respect to a and b and setting each to zero. Your derivatives should be

[tex] \mathb{\frac{\partial E}{\partial a}}=0 , \mathb{\frac{\partial E}{\partial b}}= 0[/tex]

and your first equation should read

[tex]E(a,b) = \sum_{j=1} ^{N} (y_{j} - (a + bx_{j}))^2[/tex]

What is missing in the matrix?

[tex]A = \left [ \begin{array}{cc} \frac{1}{x} \ \ \overline{x} \\ \ \ \frac{x \cdot x}{N} \end{array} \right ][/tex]

Looks like is should be this

[tex]A = \left[ {\begin{array}{*{20}c}
1 & {\overline x } \\
{\overline x } & {\frac{{ x \cdot x }}{N}} \\
\end{array}} \right][/tex]
 
  • #7
Mathman23 said:
Hi Dan and thanks for Your answer,

Then taking the partial derivative of E. First step is that to write the complete sum-formula ??

/Fred

Setting the two partial derivatives of E to zero gives you two equations for a and b. The partial with respct to a is simpler and yields an equation in a and b that involves only that averages of x and y. The partial with respect to b is a bit more complicated, involving the dot product of x and y and the dot product of x with itself. With the corrected A matrix you should be able to show that those equations are equivalent to the matrix equation you posted.
 
  • #8
OlderDan said:
Setting the two partial derivatives of E to zero gives you two equations for a and b. The partial with respct to a is simpler and yields an equation in a and b that involves only that averages of x and y. The partial with respect to b is a bit more complicated, involving the dot product of x and y and the dot product of x with itself. With the corrected A matrix you should be able to show that those equations are equivalent to the matrix equation you posted.

How do I take the partial derivative of that sum-formula?

Sincerley

Fred
 
  • #9
Mathman23 said:
How do I take the partial derivative of that sum-formula?

Sincerley

Fred

When you take the partial derivative with respect to a, everything else is constant. You know that the derivative of a sum of functions is the sum of the derivatives of the functions. In other words, the derivative "moves inside" the sum. You will be taking the derivative of every term in the sum and you will be left with a sum of terms where each term is a sum of other terms. You will want to separate those into separate sums. For the derivative wrt a, there will be three sums, a sum of all the y, a sum of all the x times a constant, and the sum of a constant. You can reduce that equation to an equation involving the two constants (a and b) and the averages of x and y. If you get that one, I think you will see how to do the derivative wrt b, but it is a bit more complicated.

Give it a try and post your result. If you don't get it right, I or someone else will post it.
 
  • #10
Hello Dan,

If I differentiate [tex]E(a,b)[/tex] first with respect to a and then to b.

I got the following two equations.

[tex]\begin{array}{cc} \frac{\partial E}{ \partial a} = 2(ax_{j} - y_{j} +b_{j}) x_{j} \ \ \mathrm{and} \ \ \frac{\partial E}{ \partial b} = 2(b_{j} + ax_{j} -y_{j}) \end{array}[/tex]

Is this what You mean?

Again thank You very much for Your help.

Sincerley and Best Regards
Fred
 
Last edited:
  • #11
Mathman23 said:
Hello Dan,

If I differentiate [tex]E(a,b)[/tex] first with respect to a and then to b.

I got the following two equations.

[tex]\begin{array}{cc} \frac{\partial E}{ \partial a} = 2(ax_{j} - y_{j} +b_{j}) x_{j} \ \ \mathrm{and} \ \ \frac{\partial E}{ \partial b} = 2(b_{j} + ax_{j} -y_{j}) \end{array}[/tex]

Is this what You mean?

Again thank You very much for Your help.

Sincerley and Best Regards
Fred
The derivatives are still sums of terms

[tex]E(a,b) = \sum_{j=1} ^{N} (y_{j} - (a + bx_{j}))^2[/tex]

[tex]E(a,b) = \sum_{j=1} ^{N} (y_{j} - a - bx_{j})^2[/tex]

[tex] \frac{\partial E}{ \partial a} = \sum_{j=1} ^{N} 2(y_{j} - a - bx_{j})(-1) = -2\sum_{j=1} ^{N} y_{j} + 2a\sum_{j=1} ^{N} 1 + 2b\sum_{j=1} ^{N} x_{j} = 0[/tex]

[tex] \frac{\partial E}{ \partial b} = \sum_{j=1} ^{N} 2(y_{j} - a - bx_{j})(-x_{j}) = -2\sum_{j=1} ^{N} x_{j}y_{j} + 2a\sum_{j=1} ^{N} x_{j} + 2b\sum_{j=1} ^{N} x_{j}^2 = 0[/tex]

Divide each of these results by -2N and you should start to identify some terms as simple averages. One will reduce to the parameter a. Other terms will involve the dot product of x and y, and the dot product of x with itself. The resulting equations can be put into the matrix form you were given.
 
Last edited:
  • #12
Hello Dan and many thanks for Your answer,

I divide the three terms in first and second with [tex]-2N[/tex]
and get the following results:


[tex]-2 \sum _{j=1} ^{N} y_{j} \rightarrow \frac{-N y}{2} \rightarrow \frac{-N}{2} \sum_{j=1} ^ {n} y[/tex]

[tex]-2a \sum _{j=1} ^{N} 1 \rightarrow a \rightarrow a \sum_{j=1} ^{N} 1 [/tex]

[tex]-2b \sum _{j=1} ^{N} x_{j} \rightarrow bx \rightarrow b \sum_{j=1} ^{N} x[/tex]

The three sums in the second part yields:

[tex]-2 \sum _{j=1} ^{N} x_{j} y_{j} \rightarrow xy \rightarrow \sum_{j=1} ^{N} xy[/tex]

[tex]-2a \sum _{j=1} ^{N} x_{j} \rightarrow ax \rightarrow a \sum_{j=1} ^{N} x [/tex]

[tex]-2b \sum _{j=1} ^{N} {x_{j}}^2 \rightarrow b x^2 \rightarrow b \sum_{j=1} ^{N} x^2[/tex]

If I insert the above in an array A I get the following:

[tex] A= \left[ \begin{array}{cc} 1 & x \\ x & x^2 \end{array} \right ][/tex]

Which can also we written as:

[tex] A \left [ \begin{array}{c} a \\ b \end{array} \right ] = ??[/tex]

But how do I conclude that the product of these two arrays equal the array

[tex] C = \left[ \begin{array}{c} y \\ xy \end{array} \right ][/tex] ??

Sincerely and Best regards

/Fred

OlderDan said:
[tex] \frac{\partial E}{ \partial b} = \sum_{j=1} ^{N} 2(y_{j} - a - bx_{j})(-x_{j}) = -2\sum_{j=1} ^{N} x_{j}y_{j} -2a\sum_{j=1} ^{N} x_{j} -2b\sum_{j=1} ^{N} x_{j}^2 = 0[/tex]

Divide each of these results by -2N and you should start to identify some terms as simple averages. One will reduce to the parameter a. Other terms will involve the dot product of x and y, and the dot product of x with itself. The resulting equations can be put into the matrix form you were given.
 
Last edited:
  • #13
Mathman23 said:
Hello Dan and many thanks for Your answer,

I divide the three terms in first and second with [tex]-2N[/tex]
and get the following results:


[tex]-2 \sum _{j=1} ^{N} y_{j} \rightarrow \frac{-N y}{2} \rightarrow \frac{-N}{2} \sum_{j=1} ^ {n} y[/tex]

You have not divided by -2N. I see I made a foolish sign error in my previous post. I will go back and fix my error, but here are the correct equations

[tex] \frac{\partial E}{ \partial a} = \sum_{j=1} ^{N} 2(y_{j} - a - bx_{j})(-1) = -2\sum_{j=1} ^{N} y_{j} +2a\sum_{j=1} ^{N} 1 +2b\sum_{j=1} ^{N} x_{j} = 0[/tex]

[tex] \frac{\partial E}{ \partial b} = \sum_{j=1} ^{N} 2(y_{j} - a - bx_{j})(-x_{j}) = -2\sum_{j=1} ^{N} x_{j}y_{j} + 2a\sum_{j=1} ^{N} x_{j} + 2b\sum_{j=1} ^{N} x_{j}^2 = 0[/tex]

[tex] -2\sum_{j=1} ^{N} y_{j} + 2a\sum_{j=1} ^{N} 1 + 2b\sum_{j=1} ^{N} x_{j} = 0 \rightarrow \frac{1}{N} \sum_{j=1} ^{N} y_{j} - \frac{a}{N}\sum_{j=1} ^{N} 1 - \frac{b}{N} \sum_{j=1} ^{N} x_{j} = \overline{y} - a - b \overline{x} = 0[/tex]

See if you can fix the second equation and take it from there. Keep in mind that a sum over a product of corresponding vector components is a dot product.
 
  • #14
OlderDan said:
You have not divided by -2N. I see I made a foolish sign error in my previous post. I will go back and fix my error, but here are the correct equations

[tex] \frac{\partial E}{ \partial a} = \sum_{j=1} ^{N} 2(y_{j} - a - bx_{j})(-1) = -2\sum_{j=1} ^{N} y_{j} +2a\sum_{j=1} ^{N} 1 +2b\sum_{j=1} ^{N} x_{j} = 0[/tex]

[tex] \frac{\partial E}{ \partial b} = \sum_{j=1} ^{N} 2(y_{j} - a - bx_{j})(-x_{j}) = -2\sum_{j=1} ^{N} x_{j}y_{j} + 2a\sum_{j=1} ^{N} x_{j} + 2b\sum_{j=1} ^{N} x_{j}^2 = 0[/tex]

[tex] -2\sum_{j=1} ^{N} y_{j} + 2a\sum_{j=1} ^{N} 1 + 2b\sum_{j=1} ^{N} x_{j} = 0 \rightarrow \frac{1}{N} \sum_{j=1} ^{N} y_{j} - \frac{a}{N}\sum_{j=1} ^{N} 1 - \frac{b}{N} \sum_{j=1} ^{N} x_{j} = \overline{y} - a - b \overline{x} = 0[/tex]

See if you can fix the second equation and take it from there. Keep in mind that a sum over a product of corresponding vector components is a dot product.

HI Dan and many for thanks for Your answers,

In the second equation I get the following:

[tex] -2\sum_{j=1} ^{N} x_{j}y_{j} + 2a\sum_{j=1} ^{N} x_{j} + 2b\sum_{j=1} ^{N} x_{j}^2 = 0 \rightarrow \sum_{j=1} ^{N} \frac{x_{j} y_{j}}{N} - \frac{a}{N} \sum_{j=1} ^{N} x_{j} - b \sum_{j=1} ^{N} \frac{x_{j}^2}{N} = (\overline{x} \cdot \overline{y}) - a \overline{x} - b(\overline{x} \cdot \overline{x}) = 0 [/tex]

If I rewrite Your result combined with mine I got the following set of equations:

[tex]\begin{array}{ccc}
a + b \cdot \overline{x} & = & \overline{y} \\ a \cdot \overline{x} + b \cdot (\overline{x} \cdot \overline{x}) & = & \overline{x} \cdot \overline{y} \end{array}[/tex]

This can also be written as the inhomogeneous linear equation present in the original problem:

[tex]\left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right] \cdot \left [ \begin{array}{c} a \\ b \end{array} \right ] = \left [ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N}\end{array} \right ] [/tex]

One question then remains, how does one prove the claim that solving the above system let's one obtain the minimum value for E(a,b) ??

Sincerely and Best Regards,

Fred
 
  • #15
Mathman23 said:
One question then remains, how does one prove the claim that solving the above system let's one obtain the minimum value for E(a,b) ??

Fred

In the calculus of one variable you learned that maxima and minima are found by setting the first derivative of a function to zero. In multivariate calculus, the analogous thing is setting the partial derivatives equal to zero. For a function of two variables you have

[tex] df(a,b) = \frac{\partial f(a,b)}{\partial a}da + \frac{\partial f(a,b)}{\partial b}db[/tex]

If you change a slightly without changing b, the change in f(a,b) is just the first term on the right. When you change b without changing a, the change in f(a,b) is just the second term. When both those terms are zero, because the partial derivatives are both zero, an arbitrary small change in both a and b gives no change in f(a,b). There are three possibilities. If both partials represent minima, the function is a minimum. If both are maxima, the function is at a maximum. If one is a minimum, and the other is a maximum it is referred to as a "saddle point" because the graph of f(a,b) has the shape of a saddle. In this problem, the point is a minimum. You could prove that by taking second derivatives. I'll leave that for another problem.
 
  • #16
Hi

I remember that from my calculas course. Thank You :-)

I was informed today that I also need to calculate the determinant of A.

[tex]A= \left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right] [/tex]

I get [tex]det(A) = \frac{x \cdot x}{N}[/tex]

But if that's correct, for which values is A then invertible ?

Sincerley and Best Regards.

Fred

OlderDan said:
In the calculus of one variable you learned that maxima and minima are found by setting the first derivative of a function to zero. In multivariate calculus, the analogous thing is setting the partial derivatives equal to zero. For a function of two variables you have

[tex] df(a,b) = \frac{\partial f(a,b)}{\partial a}da + \frac{\partial f(a,b)}{\partial b}db[/tex]

If you change a slightly without changing b, the change in f(a,b) is just the first term on the right. When you change b without changing a, the change in f(a,b) is just the second term. When both those terms are zero, because the partial derivatives are both zero, an arbitrary small change in both a and b gives no change in f(a,b). There are three possibilities. If both partials represent minima, the function is a minimum. If both are maxima, the function is at a maximum. If one is a minimum, and the other is a maximum it is referred to as a "saddle point" because the graph of f(a,b) has the shape of a saddle. In this problem, the point is a minimum. You could prove that by taking second derivatives. I'll leave that for another problem.
 
  • #17
Mathman23 said:
Hi

I remember that from my calculas course. Thank You :-)

I was informed today that I also need to calculate the determinant of A.

[tex]A= \left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right] [/tex]

I get [tex]det(A) = \frac{x \cdot x}{N}[/tex]

But if that's correct, for which values is A then invertible ?

Sincerley and Best Regards.

Fred

You are missing a term in the determinant.
 
  • #18
Hi

I have re-calculated the determinant for A.

I get the following result

[tex]det(A) = (\frac{1}{N} -1) x^2 \rightarrow (\frac{1}{N} -1) \sum_{j=1} ^{N} (-x_{j}^2) [/tex]

To answer my second question I need to set the above equation to equal zero, in order to determin for which values the matrix A is invertible.

[tex]det(A) = (\frac{1}{N} -1) x^2 = 0[/tex]

But for which variable do I need to solve the above equation ?

Sincerely and Best Regards

Fred
OlderDan said:
You are missing a term in the determinant.
 
  • #19
Mathman23 said:
Hi

I have re-calculated the determinant for A.

I get the following result

[tex]det(A) = (\frac{1}{N} -1) x^2 \rightarrow (\frac{1}{N} -1) \sum_{j=1} ^{N} (-x_{j}^2) [/tex]

To answer my second question I need to set the above equation to equal zero, in order to determin for which values the matrix A is invertible.

[tex]det(A) = (\frac{1}{N} -1) x^2 = 0[/tex]

But for which variable do I need to solve the above equation ?

Sincerely and Best Regards

Fred

That is still not correct

[tex] \overline{x} = \frac{1}{N} \sum_{j=1} ^N x_{j}[/tex]

The second term in the determinant is

[tex] -\overline{x}^2 = -\left[\frac{1}{N} \sum_{j=1} ^N x_{j}\right]^2 = -\frac{1}{N^2}\left[ \sum_{j=1} ^N x_{j}\right]^2[/tex]

The square of the sum is not the same thing as the sum of the squares

[tex] \frac{x \cdot x}{N} = \frac{1}{N} \sum_{j=1} ^N x_{j}^2[/tex]
 
  • #20
OlderDan said:
That is still not correct

[tex] \overline{x} = \frac{1}{N} \sum_{j=1} ^N x_{j}[/tex]

The second term in the determinant is

[tex] -\overline{x}^2 = -\left[\frac{1}{N} \sum_{j=1} ^N x_{j}\right]^2 = -\frac{1}{N^2}\left[ \sum_{j=1} ^N x_{j}\right]^2[/tex]

The square of the sum is not the same thing as the sum of the squares

[tex] \frac{x \cdot x}{N} = \frac{1}{N} \sum_{j=1} ^N x_{j}^2[/tex]

For which values is A invertible then ?

Hi Dan and again many thanks for Your answer :)

Correct me if I'm wrong this is the determinant for A??

[tex] -\overline{x}^2 = -\left[\frac{1}{N} \sum_{j=1} ^N x_{j}\right]^2 = -\frac{1}{N^2}\left[ \sum_{j=1} ^N x_{j}\right]^2[/tex]

Sincerely and
Fred
 
  • #21
Mathman23 said:
For which values is A invertible then ?

Hi Dan and again many thanks for Your answer :)

Correct me if I'm wrong this is the determinant for A??

[tex] -\overline{x}^2 = -\left[\frac{1}{N} \sum_{j=1} ^N x_{j}\right]^2 = -\frac{1}{N^2}\left[ \sum_{j=1} ^N x_{j}\right]^2[/tex]

Sincerely and
Fred

[tex]A= \left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right] [/tex]

The determinant of a 2 by 2 matirx is the difference of the cross products.

[tex] Det(A) = \frac{x \cdot x}{N} -\overline{x}^2 = \frac{1}{N} \sum_{j=1} ^N x_{j}^2 - \frac{1}{N^2}\left[ \sum_{j=1} ^N x_{j}\right]^2[/tex]

In order to have an inverse, the determinant must not be zero. The inverse of a 2 by 2 is shown here

http://mathworld.wolfram.com/MatrixInverse.html

Operating from the left with the inverse on

[tex]\left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right] \cdot \left [ \begin{array}{c} a \\ b \end{array} \right ] = \left [ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N}\end{array} \right ] [/tex]

Gives you

[tex] \left [ \begin{array}{c} a \\ b \end{array} \right ] = \left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right]^{-1} \cdot \left [ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N}\end{array} \right ] [/tex]

Which is equivalent to a pair of equations for the coefficients a and b. When you invert the matrix, you are almost done.
 
  • #22
Hi

Then by using this formula I calculate the inverse of A.


[tex]A^{-1} = (x^2 - \frac{1}{x^2}) \left[ {\begin{array}{*{20}c} {\frac{{ x \cdot x }}{N}} & -{\overline x } \\ -{\overline x } & 1\\\end{array}} \right] = \left[ {\begin{array}{*{20}c} {\frac{{( x \cdot x \cdot x \cdot x) -1 }}{N}} & {\frac{{-(( x \cdot x \cdot x \cdot x) -1) }}{x}} } \\ {\frac{{-(( x \cdot x \cdot x \cdot x) -1 )}}{x}} & x \cdot x - \frac{1}{x \cdot x}\\\end{array}} \right][/tex]

Is this correct?

Best Regards

Fred

p.s. Thank You again Dan for all Your answers :-)

OlderDan said:
[tex]A= \left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right] [/tex]

The determinant of a 2 by 2 matirx is the difference of the cross products.

[tex] Det(A) = \frac{x \cdot x}{N} -\overline{x}^2 = \frac{1}{N} \sum_{j=1} ^N x_{j}^2 - \frac{1}{N^2}\left[ \sum_{j=1} ^N x_{j}\right]^2[/tex]

In order to have an inverse, the determinant must not be zero. The inverse of a 2 by 2 is shown here

http://mathworld.wolfram.com/MatrixInverse.html

Operating from the left with the inverse on

[tex]\left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right] \cdot \left [ \begin{array}{c} a \\ b \end{array} \right ] = \left [ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N}\end{array} \right ] [/tex]

Gives you

[tex] \left [ \begin{array}{c} a \\ b \end{array} \right ] = \left[ {\begin{array}{*{20}c} 1 & {\overline x } \\ {\overline x } & {\frac{{ x \cdot x }}{N}} \\\end{array}} \right]^{-1} \cdot \left [ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N}\end{array} \right ] [/tex]

Which is equivalent to a pair of equations for the coefficients a and b. When you invert the matrix, you are almost done.
 
Last edited:
  • #23
Mathman23 said:
Hi

Then by using this formula I calculate the inverse of A.


[tex]A^{-1} = (x^2 - \frac{1}{x^2}) \left[ {\begin{array}{*{20}c} {\frac{{ x \cdot x }}{N}} & -{\overline x } \\ -{\overline x } & 1\\\end{array}} \right] = \left[ {\begin{array}{*{20}c} {\frac{{( x \cdot x \cdot x \cdot x) -1 }}{N}} & {\frac{{-(( x \cdot x \cdot x \cdot x) -1) }}{x}} } \\ {\frac{{-(( x \cdot x \cdot x \cdot x) -1 )}}{x}} & x \cdot x - \frac{1}{x \cdot x}\\\end{array}} \right][/tex]

Is this correct?

Best Regards

Fred

p.s. Thank You again Dan for all Your answers :-)

Your factor in front of the matrix is not correct. You really need to be careful with the notation. Since the dot product of a vector with itself is a scalar, or the square of the norm (length) of the vector there is a shorthand notation often used to write

[tex] x \cdot x = x^2 [/tex]

That is a bit dangerous to do in this problem, because in addition to [tex] x^2 [/tex], there is also an [tex]\overline{x}^2 [/tex], which is a totally different thing. I suggest you keep the dot product notation everywhere you have a dot product in your expressions. In that form

[tex] Det(A) = \frac{x \cdot x}{N} - \overline{x}^2 = \frac{x \cdot x -N \overline{x}^2}{N} [/tex]

[tex] \frac{1}{Det(A)} = \frac{N}{x \cdot x - N\overline{x}^2}}[/tex]

This is the factor you need to multiply the matrix. The matrix itself looks fine.
 
  • #24
Hi Dan and thanks,

This should be right inverse matrix(A) ??

[tex]A^{-1} = \left[ \begin{array}{*{40} cc} \frac{N (x \cdot x)}{(N(x \cdot x) -(N^2 (\overline{x}^2))} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2} \end{array} \right][/tex]

Moving one to the next part of the problem: For which values is Matrix A invertible??

[tex]\left[ \begin{array}{c} a & b \end{array} \right] = \left[ \begin{array}{*{40} cc} \frac{N (x \cdot x)}{(N(x \cdot x) -(N^2 (\overline{x}^2))} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2} \end{array} \right] \left[ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N} \end{array} \right]= \left[ \begin{array}{c} \frac{N (x \cdot x) \cdot \overline{y}}{(N(x \cdot x) -(N^2 (\overline{x}^2))} + \frac{-\overline{x }N \overline{y}}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x }N(x \cdot y)}{N(x \cdot x) - N^2 \overline{x} ^2} + \frac{N (x \cdot y)}{N(x \cdot x) - N^2 \overline{x}^2} \end{array} \right][/tex]

Is it possible to write out [tex]\left[ \begin{array}{c} a & b \end{array} \right][/tex] to a more compact form ??

Sincerely and Best Regards

Fred

OlderDan said:
Your factor in front of the matrix is not correct. You really need to be careful with the notation. Since the dot product of a vector with itself is a scalar, or the square of the norm (length) of the vector there is a shorthand notation often used to write

[tex] x \cdot x = x^2 [/tex]

That is a bit dangerous to do in this problem, because in addition to [tex] x^2 [/tex], there is also an [tex]\overline{x}^2 [/tex], which is a totally different thing. I suggest you keep the dot product notation everywhere you have a dot product in your expressions. In that form

[tex] Det(A) = \frac{x \cdot x}{N} - \overline{x}^2 = \frac{x \cdot x -N \overline{x}^2}{N} [/tex]

[tex] \frac{1}{Det(A)} = \frac{N}{x \cdot x - N\overline{x}^2}}[/tex]

This is the factor you need to multiply the matrix. The matrix itself looks fine.
 
Last edited:
  • #25
Mathman23 said:
Hi Dan and thanks,

This should be right inverse matrix(A) ??

[tex]A^{-1} = \left[ \begin{array}{*{40} cc} \frac{N (x \cdot x)}{(N(x \cdot x) -(N^2 (\overline{x}^2))} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2} \end{array} \right][/tex]

Moving one to the next part of the problem: For which values is Matrix A invertible??

[tex]\left[ \begin{array}{c} a & b \end{array} \right] = \left[ \begin{array}{*{40} cc} \frac{N (x \cdot x)}{(N(x \cdot x) -(N^2 (\overline{x}^2))} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2} \end{array} \right] \left[ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N} \end{array} \right]= \left[ \begin{array}{c} \frac{N (x \cdot x) \cdot \overline{y}}{(N(x \cdot x) -(N^2 (\overline{x}^2))} + \frac{-\overline{x }N \overline{y}}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x }N(x \cdot y)}{N(x \cdot x) - N^2 \overline{x} ^2} + \frac{N (x \cdot y)}{N(x \cdot x) - N^2 \overline{x}^2} \end{array} \right][/tex]

Is it possible to write out [tex]\left[ \begin{array}{c} a & b \end{array} \right][/tex] to a more compact form ??

Sincerely and Best Regards

Fred

You can reduce the upper left term in your inverse by dividing numeratior and denominator by N. Other than that it looks fine.
[tex]A^{-1} = \frac{N}{x \cdot x - N\overline{x}^2}} \left[ {\begin{array}{*{20}c} {\frac{{ x \cdot x }}{N}} & -{\overline x } \\ -{\overline x } & 1\\\end{array}} \right] = \left[ \begin{array}{*{40} cc} \frac{ x \cdot x}{x \cdot x -N \overline{x}^2} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2} \end{array} \right][/tex]

Your matrix multiplication is not fine however. You do not have the terms matched up properly. Review your matrix multiplication rules and give this another try. The expressions for a and b will not be very "simple" in any case, but you could help yourself by leaving the 1/det(A) term out in front of the matrix product, since it is a common factor in every term. It will also be a common factor in a and b.
 
  • #26
Hi

I try again.


Is its correct now?

[tex]\left[ \begin{array}{c} a \\ b \end{array} \right] = \left[ \begin{array}{*{40} cc} \frac{ x \cdot x}{x \cdot x -N \overline{x}^2} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2} \end{array} \right] \left[ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N} \end{array} \right] = \left[ \begin{array}{c} \frac{( x \cdot x) \overline{y}}{x \cdot x -N \overline{x}^2} + \frac{-\overline{x }N (x \cdot y)}{(x \cdot x)N - N^2 \overline{x} ^2} \\ \frac{-\overline{x }N(\overline{y})}{x \cdot x - N \overline{x} ^2} + \frac{N (x \cdot y)}{N(x \cdot x) - N^2 \overline{x}^2} \end{array} \right] [/tex]

Sincerely and Best Regards

Fred

OlderDan said:
You can reduce the upper left term in your inverse by dividing numeratior and denominator by N. Other than that it looks fine.
[tex]A^{-1} = \frac{N}{x \cdot x - N\overline{x}^2}} \left[ {\begin{array}{*{20}c} {\frac{{ x \cdot x }}{N}} & -{\overline x } \\ -{\overline x } & 1\\\end{array}} \right] = \left[ \begin{array}{*{40} cc} \frac{ x \cdot x}{x \cdot x -N \overline{x}^2} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2}\end{array} \right][/tex]

Your matrix multiplication is not fine however. You do not have the terms matched up properly. Review your matrix multiplication rules and give this another try. The expressions for a and b will not be very "simple" in any case, but you could help yourself by leaving the 1/det(A) term out in front of the matrix product, since it is a common factor in every term. It will also be a common factor in a and b.
 
  • #27
Mathman23 said:
Hi

I try again.


Is its correct now?

[tex]\left[ \begin{array}{c} a \\ b \end{array} \right] = \left[ \begin{array}{*{40} cc} \frac{ x \cdot x}{x \cdot x -N \overline{x}^2} & \frac{-\overline{x }N}{x \cdot x - N \overline{x} ^2} \\ \frac{-\overline{x} N}{x \cdot x - N \overline{x}^2} & \frac{N}{x \cdot x - N \overline{x}^2} \end{array} \right] \left[ \begin{array}{c} \overline{y} \\ \frac{x \cdot y}{N} \end{array} \right] = \left[ \begin{array}{c} \frac{( x \cdot x) \overline{y}}{x \cdot x -N \overline{x}^2} + \frac{-\overline{x }N (x \cdot y)}{(x \cdot x)N - N^2 \overline{x} ^2} \\ \frac{-\overline{x }N(\overline{y})}{x \cdot x - N \overline{x} ^2} + \frac{N (x \cdot y)}{N(x \cdot x) - N^2 \overline{x}^2} \end{array} \right] [/tex]

Sincerely and Best Regards

Fred

It looks correct, but it should be simplified. You again have factors of N that you can cancel in the second term of a and the second term of b. You should be combining the two terms in each case to write them over common denominators. The common denominator will be there if you get rid of the unnecessary N factors. Not only that, it will be the same denominator in b that you have in a. That would be obvious if you left the 1/Det(A) term out in front, and it would save you a lot of writing.
 

1. What is linear algebra?

Linear algebra is a branch of mathematics that deals with systems of linear equations and their representations in vector spaces. It involves the study of linear transformations, matrices, and vector spaces.

2. What are the applications of linear algebra?

Linear algebra has various applications in fields such as physics, engineering, computer graphics, and economics. It is used to solve systems of equations, analyze and manipulate data, and model real-world situations.

3. What is a linear algebra problem?

A linear algebra problem is a mathematical problem that involves solving equations or systems of equations using the principles and techniques of linear algebra. These problems may involve finding solutions to equations, performing matrix operations, or analyzing data using vectors and matrices.

4. How do you solve a linear algebra problem?

To solve a linear algebra problem, you first need to identify the type of problem and determine the appropriate method or technique to use. This may involve reducing a system of equations to its row-echelon form, finding the inverse of a matrix, or performing matrix operations such as addition, subtraction, and multiplication. Then, you can use the appropriate formulas and algorithms to obtain the solution.

5. What are some common challenges in solving linear algebra problems?

Some common challenges in solving linear algebra problems include understanding the underlying concepts and principles, applying the correct techniques and formulas, and dealing with large and complex systems of equations or matrices. It is also important to pay attention to detail and avoid making calculation errors.

Similar threads

  • Introductory Physics Homework Help
Replies
1
Views
193
  • Introductory Physics Homework Help
Replies
7
Views
676
  • Linear and Abstract Algebra
Replies
19
Views
2K
  • Introductory Physics Homework Help
Replies
2
Views
795
  • Advanced Physics Homework Help
Replies
19
Views
934
  • Linear and Abstract Algebra
Replies
3
Views
2K
  • Introductory Physics Homework Help
Replies
6
Views
569
Replies
7
Views
2K
Replies
1
Views
368
  • Special and General Relativity
5
Replies
146
Views
6K
Back
Top