How to differentiate $sum_i(y_i-t_i)^2$ by $y$?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












$L=sum_i(y_i-t_i)^2$



I want to differentiate $L$ by $y$.
Unfortunately I didn't learn this material, so a wild guess would be:



$(1) fracdLdy=fracddy (vecycdot vecy^T -2cdot vecy cdot vect^T + vect cdot vect)$



From here I got to:
$=2vecy-2vect^T$



But I guess this not ok, because the dimensions are not equal. This means I needed to do:



$(2) fracdLdy=fracddy vecycdot vecy^T -2cdot vect cdot vecy^T + vect cdot vect$



And then I'll get $=2vecy-2vect$ which is the correct answer I think.



I switched places because it suited me better, but I don't think that math works that way. I'm sure there is an algorithm for these operations.
How I was supposed to know that I should of opened it like in $(2)$ and not like $(1)$ ?










share|cite|improve this question























  • $y=(y_1,y_2,ldots,y_n)$?
    – MathOverview
    Sep 9 at 13:38










  • @MathOverview Yes sorry
    – sheldonzy
    Sep 9 at 13:39










  • Question. In equality "(1)" would not $ vectcdot vect^T $ be in place of $ vectcdotvect$?
    – MathOverview
    Sep 9 at 13:41















up vote
0
down vote

favorite












$L=sum_i(y_i-t_i)^2$



I want to differentiate $L$ by $y$.
Unfortunately I didn't learn this material, so a wild guess would be:



$(1) fracdLdy=fracddy (vecycdot vecy^T -2cdot vecy cdot vect^T + vect cdot vect)$



From here I got to:
$=2vecy-2vect^T$



But I guess this not ok, because the dimensions are not equal. This means I needed to do:



$(2) fracdLdy=fracddy vecycdot vecy^T -2cdot vect cdot vecy^T + vect cdot vect$



And then I'll get $=2vecy-2vect$ which is the correct answer I think.



I switched places because it suited me better, but I don't think that math works that way. I'm sure there is an algorithm for these operations.
How I was supposed to know that I should of opened it like in $(2)$ and not like $(1)$ ?










share|cite|improve this question























  • $y=(y_1,y_2,ldots,y_n)$?
    – MathOverview
    Sep 9 at 13:38










  • @MathOverview Yes sorry
    – sheldonzy
    Sep 9 at 13:39










  • Question. In equality "(1)" would not $ vectcdot vect^T $ be in place of $ vectcdotvect$?
    – MathOverview
    Sep 9 at 13:41













up vote
0
down vote

favorite









up vote
0
down vote

favorite











$L=sum_i(y_i-t_i)^2$



I want to differentiate $L$ by $y$.
Unfortunately I didn't learn this material, so a wild guess would be:



$(1) fracdLdy=fracddy (vecycdot vecy^T -2cdot vecy cdot vect^T + vect cdot vect)$



From here I got to:
$=2vecy-2vect^T$



But I guess this not ok, because the dimensions are not equal. This means I needed to do:



$(2) fracdLdy=fracddy vecycdot vecy^T -2cdot vect cdot vecy^T + vect cdot vect$



And then I'll get $=2vecy-2vect$ which is the correct answer I think.



I switched places because it suited me better, but I don't think that math works that way. I'm sure there is an algorithm for these operations.
How I was supposed to know that I should of opened it like in $(2)$ and not like $(1)$ ?










share|cite|improve this question















$L=sum_i(y_i-t_i)^2$



I want to differentiate $L$ by $y$.
Unfortunately I didn't learn this material, so a wild guess would be:



$(1) fracdLdy=fracddy (vecycdot vecy^T -2cdot vecy cdot vect^T + vect cdot vect)$



From here I got to:
$=2vecy-2vect^T$



But I guess this not ok, because the dimensions are not equal. This means I needed to do:



$(2) fracdLdy=fracddy vecycdot vecy^T -2cdot vect cdot vecy^T + vect cdot vect$



And then I'll get $=2vecy-2vect$ which is the correct answer I think.



I switched places because it suited me better, but I don't think that math works that way. I'm sure there is an algorithm for these operations.
How I was supposed to know that I should of opened it like in $(2)$ and not like $(1)$ ?







calculus linear-algebra derivatives vectors






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Sep 9 at 13:43









MathOverview

8,41842962




8,41842962










asked Sep 9 at 13:33









sheldonzy

378414




378414











  • $y=(y_1,y_2,ldots,y_n)$?
    – MathOverview
    Sep 9 at 13:38










  • @MathOverview Yes sorry
    – sheldonzy
    Sep 9 at 13:39










  • Question. In equality "(1)" would not $ vectcdot vect^T $ be in place of $ vectcdotvect$?
    – MathOverview
    Sep 9 at 13:41

















  • $y=(y_1,y_2,ldots,y_n)$?
    – MathOverview
    Sep 9 at 13:38










  • @MathOverview Yes sorry
    – sheldonzy
    Sep 9 at 13:39










  • Question. In equality "(1)" would not $ vectcdot vect^T $ be in place of $ vectcdotvect$?
    – MathOverview
    Sep 9 at 13:41
















$y=(y_1,y_2,ldots,y_n)$?
– MathOverview
Sep 9 at 13:38




$y=(y_1,y_2,ldots,y_n)$?
– MathOverview
Sep 9 at 13:38












@MathOverview Yes sorry
– sheldonzy
Sep 9 at 13:39




@MathOverview Yes sorry
– sheldonzy
Sep 9 at 13:39












Question. In equality "(1)" would not $ vectcdot vect^T $ be in place of $ vectcdotvect$?
– MathOverview
Sep 9 at 13:41





Question. In equality "(1)" would not $ vectcdot vect^T $ be in place of $ vectcdotvect$?
– MathOverview
Sep 9 at 13:41











1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










beginalignfracpartial Lpartial y_j&=fracpartial partial y_j sum_i (y_i-t_i)^2\&= fracpartial partial y_j left[(y_j-t_j)^2 + sum_i ne j (y_i-t_i)^2right]\&= fracpartial partial y_j left[(y_j-t_j)^2right] + left[fracpartialpartial y_j sum_i ne j (y_i-t_i)^2right]
\&=2(y_j-t_j) fracpartial (y_j-t_j)partial y_j +0\&=2(y_j-t_j) endalign



Hence $$nabla_y L=2(y-t)$$



Note that $y^Tt=t^Ty$, here all my vectors are column vectors.






share|cite|improve this answer






















  • Care to explain why it is equal to $2(y_j-t_j) fracpartial (y_j-t_j)partial y_j $ ? I guess by chain rule? Can you please write down the full calculation?
    – sheldonzy
    Sep 9 at 13:46










  • I have added more details.
    – Siong Thye Goh
    Sep 9 at 13:50










  • Thanks! Just checking: it is $fracpartial (y_j-t_j)partial y_j $ because you are actually doing $fracLpartial (y_j-t_j) cdot fracpartial (y_j-t_j)partial y_j $ Right?
    – sheldonzy
    Sep 9 at 13:57










  • yup, that is just chain rule.
    – Siong Thye Goh
    Sep 9 at 14:01










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',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
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%2f2910787%2fhow-to-differentiate-sum-iy-i-t-i2-by-y%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










beginalignfracpartial Lpartial y_j&=fracpartial partial y_j sum_i (y_i-t_i)^2\&= fracpartial partial y_j left[(y_j-t_j)^2 + sum_i ne j (y_i-t_i)^2right]\&= fracpartial partial y_j left[(y_j-t_j)^2right] + left[fracpartialpartial y_j sum_i ne j (y_i-t_i)^2right]
\&=2(y_j-t_j) fracpartial (y_j-t_j)partial y_j +0\&=2(y_j-t_j) endalign



Hence $$nabla_y L=2(y-t)$$



Note that $y^Tt=t^Ty$, here all my vectors are column vectors.






share|cite|improve this answer






















  • Care to explain why it is equal to $2(y_j-t_j) fracpartial (y_j-t_j)partial y_j $ ? I guess by chain rule? Can you please write down the full calculation?
    – sheldonzy
    Sep 9 at 13:46










  • I have added more details.
    – Siong Thye Goh
    Sep 9 at 13:50










  • Thanks! Just checking: it is $fracpartial (y_j-t_j)partial y_j $ because you are actually doing $fracLpartial (y_j-t_j) cdot fracpartial (y_j-t_j)partial y_j $ Right?
    – sheldonzy
    Sep 9 at 13:57










  • yup, that is just chain rule.
    – Siong Thye Goh
    Sep 9 at 14:01














up vote
1
down vote



accepted










beginalignfracpartial Lpartial y_j&=fracpartial partial y_j sum_i (y_i-t_i)^2\&= fracpartial partial y_j left[(y_j-t_j)^2 + sum_i ne j (y_i-t_i)^2right]\&= fracpartial partial y_j left[(y_j-t_j)^2right] + left[fracpartialpartial y_j sum_i ne j (y_i-t_i)^2right]
\&=2(y_j-t_j) fracpartial (y_j-t_j)partial y_j +0\&=2(y_j-t_j) endalign



Hence $$nabla_y L=2(y-t)$$



Note that $y^Tt=t^Ty$, here all my vectors are column vectors.






share|cite|improve this answer






















  • Care to explain why it is equal to $2(y_j-t_j) fracpartial (y_j-t_j)partial y_j $ ? I guess by chain rule? Can you please write down the full calculation?
    – sheldonzy
    Sep 9 at 13:46










  • I have added more details.
    – Siong Thye Goh
    Sep 9 at 13:50










  • Thanks! Just checking: it is $fracpartial (y_j-t_j)partial y_j $ because you are actually doing $fracLpartial (y_j-t_j) cdot fracpartial (y_j-t_j)partial y_j $ Right?
    – sheldonzy
    Sep 9 at 13:57










  • yup, that is just chain rule.
    – Siong Thye Goh
    Sep 9 at 14:01












up vote
1
down vote



accepted







up vote
1
down vote



accepted






beginalignfracpartial Lpartial y_j&=fracpartial partial y_j sum_i (y_i-t_i)^2\&= fracpartial partial y_j left[(y_j-t_j)^2 + sum_i ne j (y_i-t_i)^2right]\&= fracpartial partial y_j left[(y_j-t_j)^2right] + left[fracpartialpartial y_j sum_i ne j (y_i-t_i)^2right]
\&=2(y_j-t_j) fracpartial (y_j-t_j)partial y_j +0\&=2(y_j-t_j) endalign



Hence $$nabla_y L=2(y-t)$$



Note that $y^Tt=t^Ty$, here all my vectors are column vectors.






share|cite|improve this answer














beginalignfracpartial Lpartial y_j&=fracpartial partial y_j sum_i (y_i-t_i)^2\&= fracpartial partial y_j left[(y_j-t_j)^2 + sum_i ne j (y_i-t_i)^2right]\&= fracpartial partial y_j left[(y_j-t_j)^2right] + left[fracpartialpartial y_j sum_i ne j (y_i-t_i)^2right]
\&=2(y_j-t_j) fracpartial (y_j-t_j)partial y_j +0\&=2(y_j-t_j) endalign



Hence $$nabla_y L=2(y-t)$$



Note that $y^Tt=t^Ty$, here all my vectors are column vectors.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Sep 9 at 13:50

























answered Sep 9 at 13:39









Siong Thye Goh

82.9k1456104




82.9k1456104











  • Care to explain why it is equal to $2(y_j-t_j) fracpartial (y_j-t_j)partial y_j $ ? I guess by chain rule? Can you please write down the full calculation?
    – sheldonzy
    Sep 9 at 13:46










  • I have added more details.
    – Siong Thye Goh
    Sep 9 at 13:50










  • Thanks! Just checking: it is $fracpartial (y_j-t_j)partial y_j $ because you are actually doing $fracLpartial (y_j-t_j) cdot fracpartial (y_j-t_j)partial y_j $ Right?
    – sheldonzy
    Sep 9 at 13:57










  • yup, that is just chain rule.
    – Siong Thye Goh
    Sep 9 at 14:01
















  • Care to explain why it is equal to $2(y_j-t_j) fracpartial (y_j-t_j)partial y_j $ ? I guess by chain rule? Can you please write down the full calculation?
    – sheldonzy
    Sep 9 at 13:46










  • I have added more details.
    – Siong Thye Goh
    Sep 9 at 13:50










  • Thanks! Just checking: it is $fracpartial (y_j-t_j)partial y_j $ because you are actually doing $fracLpartial (y_j-t_j) cdot fracpartial (y_j-t_j)partial y_j $ Right?
    – sheldonzy
    Sep 9 at 13:57










  • yup, that is just chain rule.
    – Siong Thye Goh
    Sep 9 at 14:01















Care to explain why it is equal to $2(y_j-t_j) fracpartial (y_j-t_j)partial y_j $ ? I guess by chain rule? Can you please write down the full calculation?
– sheldonzy
Sep 9 at 13:46




Care to explain why it is equal to $2(y_j-t_j) fracpartial (y_j-t_j)partial y_j $ ? I guess by chain rule? Can you please write down the full calculation?
– sheldonzy
Sep 9 at 13:46












I have added more details.
– Siong Thye Goh
Sep 9 at 13:50




I have added more details.
– Siong Thye Goh
Sep 9 at 13:50












Thanks! Just checking: it is $fracpartial (y_j-t_j)partial y_j $ because you are actually doing $fracLpartial (y_j-t_j) cdot fracpartial (y_j-t_j)partial y_j $ Right?
– sheldonzy
Sep 9 at 13:57




Thanks! Just checking: it is $fracpartial (y_j-t_j)partial y_j $ because you are actually doing $fracLpartial (y_j-t_j) cdot fracpartial (y_j-t_j)partial y_j $ Right?
– sheldonzy
Sep 9 at 13:57












yup, that is just chain rule.
– Siong Thye Goh
Sep 9 at 14:01




yup, that is just chain rule.
– Siong Thye Goh
Sep 9 at 14:01

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2910787%2fhow-to-differentiate-sum-iy-i-t-i2-by-y%23new-answer', 'question_page');

);

Post as a guest













































































這個網誌中的熱門文章

How to combine Bézier curves to a surface?

Why am i infinitely getting the same tweet with the Twitter Search API?

Carbon dioxide