Using the method of least squares in order to find the best approximation to a solution for the system
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Use the method of least squares in order to find the best approximation
to a solution for the system
$$3x + y = 1\
x − y = 2\
x + 3y = −1$$
My Try:
$$Ax=B$$
$$beginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrixbeginbmatrix x \ y endbmatrix=beginbmatrix 1 \ 2 \ -1 endbmatrix$$
First I found $A^TA$ and then $A^TB$
$$A^TA=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrix=beginbmatrix 3 & 3 \ 3 & 11 endbmatrix$$
and
$$A^TB=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 \ 2 \ -1 endbmatrix=beginbmatrix 2 \ -4 endbmatrix$$
The I used gaussian elimination for $beginbmatrix 3 & 3 & 2 \ 3 & 11 & -4 endbmatrix$ and got $x=dfrac1712,y=-dfrac34$.
Is this method of least squares correct?
linear-algebra least-squares
add a comment |Â
up vote
0
down vote
favorite
Use the method of least squares in order to find the best approximation
to a solution for the system
$$3x + y = 1\
x − y = 2\
x + 3y = −1$$
My Try:
$$Ax=B$$
$$beginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrixbeginbmatrix x \ y endbmatrix=beginbmatrix 1 \ 2 \ -1 endbmatrix$$
First I found $A^TA$ and then $A^TB$
$$A^TA=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrix=beginbmatrix 3 & 3 \ 3 & 11 endbmatrix$$
and
$$A^TB=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 \ 2 \ -1 endbmatrix=beginbmatrix 2 \ -4 endbmatrix$$
The I used gaussian elimination for $beginbmatrix 3 & 3 & 2 \ 3 & 11 & -4 endbmatrix$ and got $x=dfrac1712,y=-dfrac34$.
Is this method of least squares correct?
linear-algebra least-squares
Your matrix $A$ does not match the system. I got $(frac23, frac-23)$. Your method seems fine though.
– JJC94
Jul 25 at 2:07
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Use the method of least squares in order to find the best approximation
to a solution for the system
$$3x + y = 1\
x − y = 2\
x + 3y = −1$$
My Try:
$$Ax=B$$
$$beginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrixbeginbmatrix x \ y endbmatrix=beginbmatrix 1 \ 2 \ -1 endbmatrix$$
First I found $A^TA$ and then $A^TB$
$$A^TA=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrix=beginbmatrix 3 & 3 \ 3 & 11 endbmatrix$$
and
$$A^TB=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 \ 2 \ -1 endbmatrix=beginbmatrix 2 \ -4 endbmatrix$$
The I used gaussian elimination for $beginbmatrix 3 & 3 & 2 \ 3 & 11 & -4 endbmatrix$ and got $x=dfrac1712,y=-dfrac34$.
Is this method of least squares correct?
linear-algebra least-squares
Use the method of least squares in order to find the best approximation
to a solution for the system
$$3x + y = 1\
x − y = 2\
x + 3y = −1$$
My Try:
$$Ax=B$$
$$beginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrixbeginbmatrix x \ y endbmatrix=beginbmatrix 1 \ 2 \ -1 endbmatrix$$
First I found $A^TA$ and then $A^TB$
$$A^TA=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 & 1 \ 1 & -1 \ 1 & 3 endbmatrix=beginbmatrix 3 & 3 \ 3 & 11 endbmatrix$$
and
$$A^TB=beginbmatrix 1 & 1 & 1 \ 1 & -1 & 3 endbmatrixbeginbmatrix 1 \ 2 \ -1 endbmatrix=beginbmatrix 2 \ -4 endbmatrix$$
The I used gaussian elimination for $beginbmatrix 3 & 3 & 2 \ 3 & 11 & -4 endbmatrix$ and got $x=dfrac1712,y=-dfrac34$.
Is this method of least squares correct?
linear-algebra least-squares
asked Jul 25 at 1:53
philip
1158
1158
Your matrix $A$ does not match the system. I got $(frac23, frac-23)$. Your method seems fine though.
– JJC94
Jul 25 at 2:07
add a comment |Â
Your matrix $A$ does not match the system. I got $(frac23, frac-23)$. Your method seems fine though.
– JJC94
Jul 25 at 2:07
Your matrix $A$ does not match the system. I got $(frac23, frac-23)$. Your method seems fine though.
– JJC94
Jul 25 at 2:07
Your matrix $A$ does not match the system. I got $(frac23, frac-23)$. Your method seems fine though.
– JJC94
Jul 25 at 2:07
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
Yes, the method is correct. It is more common to write it as:
$$ x = (A^TA)^-1A^TB$$
Your calculations are right, except that you have a typo in the matrix $A$, as pointed out in the comments.
To be fair, for large matrices, computing the inverse is too expensive, and row reduction is preferable.
– JJC94
Jul 25 at 2:09
@pedroszattoni when I calculated $(A^TA)^-1A^TB$ I got the matrix as $beginbmatrix frac 17 12 \ frac -3 4 endbmatrix$
– philip
Jul 25 at 2:12
@philip you have a mismatch between your system of equations and your matrix $A$.
– pedroszattoni
Jul 25 at 2:14
Can you please show where I was wrong
– philip
Jul 25 at 2:15
top left entry of matrix $A$ is 1, whereas it should be 3 if you follow the equations of the linear system
– pedroszattoni
Jul 25 at 2:18
 |Â
show 1 more comment
up vote
0
down vote
Since you did not specify that matrix calculation was a requirement, admitting that you need to solve $n$ linear equations written as
$$a_ix+b_iy=c_i qquad qquad (i=1,2,cdots,n)$$ with $n>2$, by analogy with least squares method, you could simply minimize with respect to $(x,y)$ the norm
$$Phi=frac 12sum_i=1^n(a_ix+b_iy-c_i)^2$$ Computing the partial derivatives
$$fracpartial Phipartial x=sum_i=1^na_i(a_ix+b_iy-c_i)$$
$$fracpartial Phipartial y=sum_i=1^nb_i(a_ix+b_iy-c_i)$$ Setting them equal to $0$, you then end with two linear equations in $(x,y)$, namely
$$x sum_i=1^n a_i^2+y sum_i=1^n a_ib_i=sum_i=1^n a_ic_i$$
$$x sum_i=1^n a_ib_i+y sum_i=1^n b_i^2=sum_i=1^n b_ic_i$$
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Yes, the method is correct. It is more common to write it as:
$$ x = (A^TA)^-1A^TB$$
Your calculations are right, except that you have a typo in the matrix $A$, as pointed out in the comments.
To be fair, for large matrices, computing the inverse is too expensive, and row reduction is preferable.
– JJC94
Jul 25 at 2:09
@pedroszattoni when I calculated $(A^TA)^-1A^TB$ I got the matrix as $beginbmatrix frac 17 12 \ frac -3 4 endbmatrix$
– philip
Jul 25 at 2:12
@philip you have a mismatch between your system of equations and your matrix $A$.
– pedroszattoni
Jul 25 at 2:14
Can you please show where I was wrong
– philip
Jul 25 at 2:15
top left entry of matrix $A$ is 1, whereas it should be 3 if you follow the equations of the linear system
– pedroszattoni
Jul 25 at 2:18
 |Â
show 1 more comment
up vote
0
down vote
accepted
Yes, the method is correct. It is more common to write it as:
$$ x = (A^TA)^-1A^TB$$
Your calculations are right, except that you have a typo in the matrix $A$, as pointed out in the comments.
To be fair, for large matrices, computing the inverse is too expensive, and row reduction is preferable.
– JJC94
Jul 25 at 2:09
@pedroszattoni when I calculated $(A^TA)^-1A^TB$ I got the matrix as $beginbmatrix frac 17 12 \ frac -3 4 endbmatrix$
– philip
Jul 25 at 2:12
@philip you have a mismatch between your system of equations and your matrix $A$.
– pedroszattoni
Jul 25 at 2:14
Can you please show where I was wrong
– philip
Jul 25 at 2:15
top left entry of matrix $A$ is 1, whereas it should be 3 if you follow the equations of the linear system
– pedroszattoni
Jul 25 at 2:18
 |Â
show 1 more comment
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Yes, the method is correct. It is more common to write it as:
$$ x = (A^TA)^-1A^TB$$
Your calculations are right, except that you have a typo in the matrix $A$, as pointed out in the comments.
Yes, the method is correct. It is more common to write it as:
$$ x = (A^TA)^-1A^TB$$
Your calculations are right, except that you have a typo in the matrix $A$, as pointed out in the comments.
edited Jul 25 at 2:08
answered Jul 25 at 2:01
pedroszattoni
14819
14819
To be fair, for large matrices, computing the inverse is too expensive, and row reduction is preferable.
– JJC94
Jul 25 at 2:09
@pedroszattoni when I calculated $(A^TA)^-1A^TB$ I got the matrix as $beginbmatrix frac 17 12 \ frac -3 4 endbmatrix$
– philip
Jul 25 at 2:12
@philip you have a mismatch between your system of equations and your matrix $A$.
– pedroszattoni
Jul 25 at 2:14
Can you please show where I was wrong
– philip
Jul 25 at 2:15
top left entry of matrix $A$ is 1, whereas it should be 3 if you follow the equations of the linear system
– pedroszattoni
Jul 25 at 2:18
 |Â
show 1 more comment
To be fair, for large matrices, computing the inverse is too expensive, and row reduction is preferable.
– JJC94
Jul 25 at 2:09
@pedroszattoni when I calculated $(A^TA)^-1A^TB$ I got the matrix as $beginbmatrix frac 17 12 \ frac -3 4 endbmatrix$
– philip
Jul 25 at 2:12
@philip you have a mismatch between your system of equations and your matrix $A$.
– pedroszattoni
Jul 25 at 2:14
Can you please show where I was wrong
– philip
Jul 25 at 2:15
top left entry of matrix $A$ is 1, whereas it should be 3 if you follow the equations of the linear system
– pedroszattoni
Jul 25 at 2:18
To be fair, for large matrices, computing the inverse is too expensive, and row reduction is preferable.
– JJC94
Jul 25 at 2:09
To be fair, for large matrices, computing the inverse is too expensive, and row reduction is preferable.
– JJC94
Jul 25 at 2:09
@pedroszattoni when I calculated $(A^TA)^-1A^TB$ I got the matrix as $beginbmatrix frac 17 12 \ frac -3 4 endbmatrix$
– philip
Jul 25 at 2:12
@pedroszattoni when I calculated $(A^TA)^-1A^TB$ I got the matrix as $beginbmatrix frac 17 12 \ frac -3 4 endbmatrix$
– philip
Jul 25 at 2:12
@philip you have a mismatch between your system of equations and your matrix $A$.
– pedroszattoni
Jul 25 at 2:14
@philip you have a mismatch between your system of equations and your matrix $A$.
– pedroszattoni
Jul 25 at 2:14
Can you please show where I was wrong
– philip
Jul 25 at 2:15
Can you please show where I was wrong
– philip
Jul 25 at 2:15
top left entry of matrix $A$ is 1, whereas it should be 3 if you follow the equations of the linear system
– pedroszattoni
Jul 25 at 2:18
top left entry of matrix $A$ is 1, whereas it should be 3 if you follow the equations of the linear system
– pedroszattoni
Jul 25 at 2:18
 |Â
show 1 more comment
up vote
0
down vote
Since you did not specify that matrix calculation was a requirement, admitting that you need to solve $n$ linear equations written as
$$a_ix+b_iy=c_i qquad qquad (i=1,2,cdots,n)$$ with $n>2$, by analogy with least squares method, you could simply minimize with respect to $(x,y)$ the norm
$$Phi=frac 12sum_i=1^n(a_ix+b_iy-c_i)^2$$ Computing the partial derivatives
$$fracpartial Phipartial x=sum_i=1^na_i(a_ix+b_iy-c_i)$$
$$fracpartial Phipartial y=sum_i=1^nb_i(a_ix+b_iy-c_i)$$ Setting them equal to $0$, you then end with two linear equations in $(x,y)$, namely
$$x sum_i=1^n a_i^2+y sum_i=1^n a_ib_i=sum_i=1^n a_ic_i$$
$$x sum_i=1^n a_ib_i+y sum_i=1^n b_i^2=sum_i=1^n b_ic_i$$
add a comment |Â
up vote
0
down vote
Since you did not specify that matrix calculation was a requirement, admitting that you need to solve $n$ linear equations written as
$$a_ix+b_iy=c_i qquad qquad (i=1,2,cdots,n)$$ with $n>2$, by analogy with least squares method, you could simply minimize with respect to $(x,y)$ the norm
$$Phi=frac 12sum_i=1^n(a_ix+b_iy-c_i)^2$$ Computing the partial derivatives
$$fracpartial Phipartial x=sum_i=1^na_i(a_ix+b_iy-c_i)$$
$$fracpartial Phipartial y=sum_i=1^nb_i(a_ix+b_iy-c_i)$$ Setting them equal to $0$, you then end with two linear equations in $(x,y)$, namely
$$x sum_i=1^n a_i^2+y sum_i=1^n a_ib_i=sum_i=1^n a_ic_i$$
$$x sum_i=1^n a_ib_i+y sum_i=1^n b_i^2=sum_i=1^n b_ic_i$$
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Since you did not specify that matrix calculation was a requirement, admitting that you need to solve $n$ linear equations written as
$$a_ix+b_iy=c_i qquad qquad (i=1,2,cdots,n)$$ with $n>2$, by analogy with least squares method, you could simply minimize with respect to $(x,y)$ the norm
$$Phi=frac 12sum_i=1^n(a_ix+b_iy-c_i)^2$$ Computing the partial derivatives
$$fracpartial Phipartial x=sum_i=1^na_i(a_ix+b_iy-c_i)$$
$$fracpartial Phipartial y=sum_i=1^nb_i(a_ix+b_iy-c_i)$$ Setting them equal to $0$, you then end with two linear equations in $(x,y)$, namely
$$x sum_i=1^n a_i^2+y sum_i=1^n a_ib_i=sum_i=1^n a_ic_i$$
$$x sum_i=1^n a_ib_i+y sum_i=1^n b_i^2=sum_i=1^n b_ic_i$$
Since you did not specify that matrix calculation was a requirement, admitting that you need to solve $n$ linear equations written as
$$a_ix+b_iy=c_i qquad qquad (i=1,2,cdots,n)$$ with $n>2$, by analogy with least squares method, you could simply minimize with respect to $(x,y)$ the norm
$$Phi=frac 12sum_i=1^n(a_ix+b_iy-c_i)^2$$ Computing the partial derivatives
$$fracpartial Phipartial x=sum_i=1^na_i(a_ix+b_iy-c_i)$$
$$fracpartial Phipartial y=sum_i=1^nb_i(a_ix+b_iy-c_i)$$ Setting them equal to $0$, you then end with two linear equations in $(x,y)$, namely
$$x sum_i=1^n a_i^2+y sum_i=1^n a_ib_i=sum_i=1^n a_ic_i$$
$$x sum_i=1^n a_ib_i+y sum_i=1^n b_i^2=sum_i=1^n b_ic_i$$
answered Jul 25 at 4:44
Claude Leibovici
111k1055126
111k1055126
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2861949%2fusing-the-method-of-least-squares-in-order-to-find-the-best-approximation-to-a-s%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Your matrix $A$ does not match the system. I got $(frac23, frac-23)$. Your method seems fine though.
– JJC94
Jul 25 at 2:07