Gradient of matrix $b^{T}x$











up vote
0
down vote

favorite












I'm trying to understand my exam solution from the lecturer, but I got confused over one small thing in the solution.





Problem: Consider $f(x)=frac{1}{2}x^{T}Ax - b^{T}x$



Where $A=begin{bmatrix}2&1\1&4end{bmatrix}$ , $b=begin{bmatrix}0\7end{bmatrix}$ and $x=begin{bmatrix}x\yend{bmatrix}$



Caclulate $nabla f(x)$.



Solution:
From the theory we know that if $A$ is symmetric, we get



$nabla f(x)= Ax - b^{T}$



$nabla f(x)=begin{bmatrix}2x+y\x+4y-7end{bmatrix}$





Is it a typo on the answer, where $Ax-b^{T}$ should've been written as $Ax-b$?



If it should've been written as $b$, then I understand why we have $-7$ in the 2nd row.



Thank you










share|cite|improve this question




















  • 1




    Yes, $nabla b^{T}x = b$.
    – Math Lover
    Nov 27 at 20:15










  • Could you please elaborate how the transpose of $b$ becomes $b$? And do you think it is a typo where $b^{T}$ in the answer should've been written as $b$?
    – JIM BOY
    Nov 27 at 20:29












  • Give a look to this other answer: math.stackexchange.com/questions/3013384/…
    – caverac
    Nov 27 at 21:00

















up vote
0
down vote

favorite












I'm trying to understand my exam solution from the lecturer, but I got confused over one small thing in the solution.





Problem: Consider $f(x)=frac{1}{2}x^{T}Ax - b^{T}x$



Where $A=begin{bmatrix}2&1\1&4end{bmatrix}$ , $b=begin{bmatrix}0\7end{bmatrix}$ and $x=begin{bmatrix}x\yend{bmatrix}$



Caclulate $nabla f(x)$.



Solution:
From the theory we know that if $A$ is symmetric, we get



$nabla f(x)= Ax - b^{T}$



$nabla f(x)=begin{bmatrix}2x+y\x+4y-7end{bmatrix}$





Is it a typo on the answer, where $Ax-b^{T}$ should've been written as $Ax-b$?



If it should've been written as $b$, then I understand why we have $-7$ in the 2nd row.



Thank you










share|cite|improve this question




















  • 1




    Yes, $nabla b^{T}x = b$.
    – Math Lover
    Nov 27 at 20:15










  • Could you please elaborate how the transpose of $b$ becomes $b$? And do you think it is a typo where $b^{T}$ in the answer should've been written as $b$?
    – JIM BOY
    Nov 27 at 20:29












  • Give a look to this other answer: math.stackexchange.com/questions/3013384/…
    – caverac
    Nov 27 at 21:00















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to understand my exam solution from the lecturer, but I got confused over one small thing in the solution.





Problem: Consider $f(x)=frac{1}{2}x^{T}Ax - b^{T}x$



Where $A=begin{bmatrix}2&1\1&4end{bmatrix}$ , $b=begin{bmatrix}0\7end{bmatrix}$ and $x=begin{bmatrix}x\yend{bmatrix}$



Caclulate $nabla f(x)$.



Solution:
From the theory we know that if $A$ is symmetric, we get



$nabla f(x)= Ax - b^{T}$



$nabla f(x)=begin{bmatrix}2x+y\x+4y-7end{bmatrix}$





Is it a typo on the answer, where $Ax-b^{T}$ should've been written as $Ax-b$?



If it should've been written as $b$, then I understand why we have $-7$ in the 2nd row.



Thank you










share|cite|improve this question















I'm trying to understand my exam solution from the lecturer, but I got confused over one small thing in the solution.





Problem: Consider $f(x)=frac{1}{2}x^{T}Ax - b^{T}x$



Where $A=begin{bmatrix}2&1\1&4end{bmatrix}$ , $b=begin{bmatrix}0\7end{bmatrix}$ and $x=begin{bmatrix}x\yend{bmatrix}$



Caclulate $nabla f(x)$.



Solution:
From the theory we know that if $A$ is symmetric, we get



$nabla f(x)= Ax - b^{T}$



$nabla f(x)=begin{bmatrix}2x+y\x+4y-7end{bmatrix}$





Is it a typo on the answer, where $Ax-b^{T}$ should've been written as $Ax-b$?



If it should've been written as $b$, then I understand why we have $-7$ in the 2nd row.



Thank you







matrices vector-analysis differential






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 27 at 21:21

























asked Nov 27 at 20:12









JIM BOY

356




356








  • 1




    Yes, $nabla b^{T}x = b$.
    – Math Lover
    Nov 27 at 20:15










  • Could you please elaborate how the transpose of $b$ becomes $b$? And do you think it is a typo where $b^{T}$ in the answer should've been written as $b$?
    – JIM BOY
    Nov 27 at 20:29












  • Give a look to this other answer: math.stackexchange.com/questions/3013384/…
    – caverac
    Nov 27 at 21:00
















  • 1




    Yes, $nabla b^{T}x = b$.
    – Math Lover
    Nov 27 at 20:15










  • Could you please elaborate how the transpose of $b$ becomes $b$? And do you think it is a typo where $b^{T}$ in the answer should've been written as $b$?
    – JIM BOY
    Nov 27 at 20:29












  • Give a look to this other answer: math.stackexchange.com/questions/3013384/…
    – caverac
    Nov 27 at 21:00










1




1




Yes, $nabla b^{T}x = b$.
– Math Lover
Nov 27 at 20:15




Yes, $nabla b^{T}x = b$.
– Math Lover
Nov 27 at 20:15












Could you please elaborate how the transpose of $b$ becomes $b$? And do you think it is a typo where $b^{T}$ in the answer should've been written as $b$?
– JIM BOY
Nov 27 at 20:29






Could you please elaborate how the transpose of $b$ becomes $b$? And do you think it is a typo where $b^{T}$ in the answer should've been written as $b$?
– JIM BOY
Nov 27 at 20:29














Give a look to this other answer: math.stackexchange.com/questions/3013384/…
– caverac
Nov 27 at 21:00






Give a look to this other answer: math.stackexchange.com/questions/3013384/…
– caverac
Nov 27 at 21:00












2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










There is no typo, you need to transpose $b$ if you want to compute its scalar product with $x$ (quick check, treat this as a normal matrix-matrix multiplication: the dimensions would not agree without transposition!).



And yes, $nabla (b^Tx) = b$.



In this case, since there are only two components, we can compute everything by hand. You can then understand how this generalizes, once you figure out what happens when applying the gradient.



We have:



$$b^Tx = begin{bmatrix} 0 & 7end{bmatrix} cdot begin{bmatrix} x \ y end{bmatrix} = 0x + 7y$$



and since



$$nabla = begin{bmatrix} frac{partial}{partial x} \ frac{partial}{partial y} end{bmatrix},$$



you can compute



$$nabla (b^Tx) = begin{bmatrix} frac{partial}{partial x} (0x + 7y) \ frac{partial}{partial y} (0x + 7y) end{bmatrix} = begin{bmatrix} 0 \ 7 end{bmatrix}.$$






share|cite|improve this answer





















  • Thanks. Now I get it how $nabla b^{T}x = b$. What I mean by typo is on the answer. My lecturer wrote $-b^{T}$. It should be $-b$ right?
    – JIM BOY
    Nov 27 at 21:14








  • 1




    Oh, sure, that is right.
    – alrigazzi
    Nov 28 at 19:15


















up vote
1
down vote













Call a column vector $vec{x}$. Indicate $x^1$ for the 1st component, $x^2$ for the second, and so on. Square of a component will be $(x^1)^2$ Will be the first component (usually x coponent) squared.



$x^i$ will be used to represent the i_th component or the whole vector.



The transpose of vector will be represented with a lowered index $x_i$ is $vec{x}^T$



Inner products can only be performed between a column vector and a row vector, so one vector is addressed by lower indices, the other by vectors. Matching indicies imply a sum.



So $b^Tx=b_ix^i=b_xx_x+b_yx_y+b_zx_z$



$nabla(b^Tx)=frac{partial}{partial x^j}(b_ix^i)$



By the product rule:



$frac{partial}{partial x^j}(b_ix^i)=frac{partial b_i}{partial x_j}x^i+b_ifrac{partial x^i}{partial x^j}$



But $vec{b}$ isa constant, so the derivatives of any component is 0. $frac{partial x_j}{partial x_i}$ is 0 unless the indices match, in which case the value is 1.



So the other term gives us $b_j$, establishing the expected result.






share|cite|improve this answer























  • Thanks. What I mean by typo is on the answer. My lecturer wrote $−b^T$. It should be $−b$ right?
    – JIM BOY
    Nov 27 at 23:04






  • 1




    Yep. the $delta^i_k$ makes that happen.
    – TurlocTheRed
    Nov 27 at 23:08











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3016249%2fgradient-of-matrix-btx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










There is no typo, you need to transpose $b$ if you want to compute its scalar product with $x$ (quick check, treat this as a normal matrix-matrix multiplication: the dimensions would not agree without transposition!).



And yes, $nabla (b^Tx) = b$.



In this case, since there are only two components, we can compute everything by hand. You can then understand how this generalizes, once you figure out what happens when applying the gradient.



We have:



$$b^Tx = begin{bmatrix} 0 & 7end{bmatrix} cdot begin{bmatrix} x \ y end{bmatrix} = 0x + 7y$$



and since



$$nabla = begin{bmatrix} frac{partial}{partial x} \ frac{partial}{partial y} end{bmatrix},$$



you can compute



$$nabla (b^Tx) = begin{bmatrix} frac{partial}{partial x} (0x + 7y) \ frac{partial}{partial y} (0x + 7y) end{bmatrix} = begin{bmatrix} 0 \ 7 end{bmatrix}.$$






share|cite|improve this answer





















  • Thanks. Now I get it how $nabla b^{T}x = b$. What I mean by typo is on the answer. My lecturer wrote $-b^{T}$. It should be $-b$ right?
    – JIM BOY
    Nov 27 at 21:14








  • 1




    Oh, sure, that is right.
    – alrigazzi
    Nov 28 at 19:15















up vote
2
down vote



accepted










There is no typo, you need to transpose $b$ if you want to compute its scalar product with $x$ (quick check, treat this as a normal matrix-matrix multiplication: the dimensions would not agree without transposition!).



And yes, $nabla (b^Tx) = b$.



In this case, since there are only two components, we can compute everything by hand. You can then understand how this generalizes, once you figure out what happens when applying the gradient.



We have:



$$b^Tx = begin{bmatrix} 0 & 7end{bmatrix} cdot begin{bmatrix} x \ y end{bmatrix} = 0x + 7y$$



and since



$$nabla = begin{bmatrix} frac{partial}{partial x} \ frac{partial}{partial y} end{bmatrix},$$



you can compute



$$nabla (b^Tx) = begin{bmatrix} frac{partial}{partial x} (0x + 7y) \ frac{partial}{partial y} (0x + 7y) end{bmatrix} = begin{bmatrix} 0 \ 7 end{bmatrix}.$$






share|cite|improve this answer





















  • Thanks. Now I get it how $nabla b^{T}x = b$. What I mean by typo is on the answer. My lecturer wrote $-b^{T}$. It should be $-b$ right?
    – JIM BOY
    Nov 27 at 21:14








  • 1




    Oh, sure, that is right.
    – alrigazzi
    Nov 28 at 19:15













up vote
2
down vote



accepted







up vote
2
down vote



accepted






There is no typo, you need to transpose $b$ if you want to compute its scalar product with $x$ (quick check, treat this as a normal matrix-matrix multiplication: the dimensions would not agree without transposition!).



And yes, $nabla (b^Tx) = b$.



In this case, since there are only two components, we can compute everything by hand. You can then understand how this generalizes, once you figure out what happens when applying the gradient.



We have:



$$b^Tx = begin{bmatrix} 0 & 7end{bmatrix} cdot begin{bmatrix} x \ y end{bmatrix} = 0x + 7y$$



and since



$$nabla = begin{bmatrix} frac{partial}{partial x} \ frac{partial}{partial y} end{bmatrix},$$



you can compute



$$nabla (b^Tx) = begin{bmatrix} frac{partial}{partial x} (0x + 7y) \ frac{partial}{partial y} (0x + 7y) end{bmatrix} = begin{bmatrix} 0 \ 7 end{bmatrix}.$$






share|cite|improve this answer












There is no typo, you need to transpose $b$ if you want to compute its scalar product with $x$ (quick check, treat this as a normal matrix-matrix multiplication: the dimensions would not agree without transposition!).



And yes, $nabla (b^Tx) = b$.



In this case, since there are only two components, we can compute everything by hand. You can then understand how this generalizes, once you figure out what happens when applying the gradient.



We have:



$$b^Tx = begin{bmatrix} 0 & 7end{bmatrix} cdot begin{bmatrix} x \ y end{bmatrix} = 0x + 7y$$



and since



$$nabla = begin{bmatrix} frac{partial}{partial x} \ frac{partial}{partial y} end{bmatrix},$$



you can compute



$$nabla (b^Tx) = begin{bmatrix} frac{partial}{partial x} (0x + 7y) \ frac{partial}{partial y} (0x + 7y) end{bmatrix} = begin{bmatrix} 0 \ 7 end{bmatrix}.$$







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Nov 27 at 21:10









alrigazzi

363




363












  • Thanks. Now I get it how $nabla b^{T}x = b$. What I mean by typo is on the answer. My lecturer wrote $-b^{T}$. It should be $-b$ right?
    – JIM BOY
    Nov 27 at 21:14








  • 1




    Oh, sure, that is right.
    – alrigazzi
    Nov 28 at 19:15


















  • Thanks. Now I get it how $nabla b^{T}x = b$. What I mean by typo is on the answer. My lecturer wrote $-b^{T}$. It should be $-b$ right?
    – JIM BOY
    Nov 27 at 21:14








  • 1




    Oh, sure, that is right.
    – alrigazzi
    Nov 28 at 19:15
















Thanks. Now I get it how $nabla b^{T}x = b$. What I mean by typo is on the answer. My lecturer wrote $-b^{T}$. It should be $-b$ right?
– JIM BOY
Nov 27 at 21:14






Thanks. Now I get it how $nabla b^{T}x = b$. What I mean by typo is on the answer. My lecturer wrote $-b^{T}$. It should be $-b$ right?
– JIM BOY
Nov 27 at 21:14






1




1




Oh, sure, that is right.
– alrigazzi
Nov 28 at 19:15




Oh, sure, that is right.
– alrigazzi
Nov 28 at 19:15










up vote
1
down vote













Call a column vector $vec{x}$. Indicate $x^1$ for the 1st component, $x^2$ for the second, and so on. Square of a component will be $(x^1)^2$ Will be the first component (usually x coponent) squared.



$x^i$ will be used to represent the i_th component or the whole vector.



The transpose of vector will be represented with a lowered index $x_i$ is $vec{x}^T$



Inner products can only be performed between a column vector and a row vector, so one vector is addressed by lower indices, the other by vectors. Matching indicies imply a sum.



So $b^Tx=b_ix^i=b_xx_x+b_yx_y+b_zx_z$



$nabla(b^Tx)=frac{partial}{partial x^j}(b_ix^i)$



By the product rule:



$frac{partial}{partial x^j}(b_ix^i)=frac{partial b_i}{partial x_j}x^i+b_ifrac{partial x^i}{partial x^j}$



But $vec{b}$ isa constant, so the derivatives of any component is 0. $frac{partial x_j}{partial x_i}$ is 0 unless the indices match, in which case the value is 1.



So the other term gives us $b_j$, establishing the expected result.






share|cite|improve this answer























  • Thanks. What I mean by typo is on the answer. My lecturer wrote $−b^T$. It should be $−b$ right?
    – JIM BOY
    Nov 27 at 23:04






  • 1




    Yep. the $delta^i_k$ makes that happen.
    – TurlocTheRed
    Nov 27 at 23:08















up vote
1
down vote













Call a column vector $vec{x}$. Indicate $x^1$ for the 1st component, $x^2$ for the second, and so on. Square of a component will be $(x^1)^2$ Will be the first component (usually x coponent) squared.



$x^i$ will be used to represent the i_th component or the whole vector.



The transpose of vector will be represented with a lowered index $x_i$ is $vec{x}^T$



Inner products can only be performed between a column vector and a row vector, so one vector is addressed by lower indices, the other by vectors. Matching indicies imply a sum.



So $b^Tx=b_ix^i=b_xx_x+b_yx_y+b_zx_z$



$nabla(b^Tx)=frac{partial}{partial x^j}(b_ix^i)$



By the product rule:



$frac{partial}{partial x^j}(b_ix^i)=frac{partial b_i}{partial x_j}x^i+b_ifrac{partial x^i}{partial x^j}$



But $vec{b}$ isa constant, so the derivatives of any component is 0. $frac{partial x_j}{partial x_i}$ is 0 unless the indices match, in which case the value is 1.



So the other term gives us $b_j$, establishing the expected result.






share|cite|improve this answer























  • Thanks. What I mean by typo is on the answer. My lecturer wrote $−b^T$. It should be $−b$ right?
    – JIM BOY
    Nov 27 at 23:04






  • 1




    Yep. the $delta^i_k$ makes that happen.
    – TurlocTheRed
    Nov 27 at 23:08













up vote
1
down vote










up vote
1
down vote









Call a column vector $vec{x}$. Indicate $x^1$ for the 1st component, $x^2$ for the second, and so on. Square of a component will be $(x^1)^2$ Will be the first component (usually x coponent) squared.



$x^i$ will be used to represent the i_th component or the whole vector.



The transpose of vector will be represented with a lowered index $x_i$ is $vec{x}^T$



Inner products can only be performed between a column vector and a row vector, so one vector is addressed by lower indices, the other by vectors. Matching indicies imply a sum.



So $b^Tx=b_ix^i=b_xx_x+b_yx_y+b_zx_z$



$nabla(b^Tx)=frac{partial}{partial x^j}(b_ix^i)$



By the product rule:



$frac{partial}{partial x^j}(b_ix^i)=frac{partial b_i}{partial x_j}x^i+b_ifrac{partial x^i}{partial x^j}$



But $vec{b}$ isa constant, so the derivatives of any component is 0. $frac{partial x_j}{partial x_i}$ is 0 unless the indices match, in which case the value is 1.



So the other term gives us $b_j$, establishing the expected result.






share|cite|improve this answer














Call a column vector $vec{x}$. Indicate $x^1$ for the 1st component, $x^2$ for the second, and so on. Square of a component will be $(x^1)^2$ Will be the first component (usually x coponent) squared.



$x^i$ will be used to represent the i_th component or the whole vector.



The transpose of vector will be represented with a lowered index $x_i$ is $vec{x}^T$



Inner products can only be performed between a column vector and a row vector, so one vector is addressed by lower indices, the other by vectors. Matching indicies imply a sum.



So $b^Tx=b_ix^i=b_xx_x+b_yx_y+b_zx_z$



$nabla(b^Tx)=frac{partial}{partial x^j}(b_ix^i)$



By the product rule:



$frac{partial}{partial x^j}(b_ix^i)=frac{partial b_i}{partial x_j}x^i+b_ifrac{partial x^i}{partial x^j}$



But $vec{b}$ isa constant, so the derivatives of any component is 0. $frac{partial x_j}{partial x_i}$ is 0 unless the indices match, in which case the value is 1.



So the other term gives us $b_j$, establishing the expected result.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Nov 28 at 16:56

























answered Nov 27 at 21:50









TurlocTheRed

818311




818311












  • Thanks. What I mean by typo is on the answer. My lecturer wrote $−b^T$. It should be $−b$ right?
    – JIM BOY
    Nov 27 at 23:04






  • 1




    Yep. the $delta^i_k$ makes that happen.
    – TurlocTheRed
    Nov 27 at 23:08


















  • Thanks. What I mean by typo is on the answer. My lecturer wrote $−b^T$. It should be $−b$ right?
    – JIM BOY
    Nov 27 at 23:04






  • 1




    Yep. the $delta^i_k$ makes that happen.
    – TurlocTheRed
    Nov 27 at 23:08
















Thanks. What I mean by typo is on the answer. My lecturer wrote $−b^T$. It should be $−b$ right?
– JIM BOY
Nov 27 at 23:04




Thanks. What I mean by typo is on the answer. My lecturer wrote $−b^T$. It should be $−b$ right?
– JIM BOY
Nov 27 at 23:04




1




1




Yep. the $delta^i_k$ makes that happen.
– TurlocTheRed
Nov 27 at 23:08




Yep. the $delta^i_k$ makes that happen.
– TurlocTheRed
Nov 27 at 23:08


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3016249%2fgradient-of-matrix-btx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

To store a contact into the json file from server.js file using a class in NodeJS

Redirect URL with Chrome Remote Debugging Android Devices

Dieringhausen