# Should there be a signum function in the derivative of this sum?

Say we want to derive the following sum with respect to $A_i$ $$S=\sum_{j=1}^M\left(\sum_{i=0}^NA_ix_j^i-y_j\right)^2$$ In the book the derivative is given as $$\frac{dS}{dA_i}=2\sum_{j=1}^M\left(\sum_{i=0}^NA_ix_j^i-y_i\right)x_j^l$$ where $l$ equals the degree of $x$ that corresponds to $A_i$ which we're deriving with respect to. Now this makes perfect sense, when $A_i>0$ for all $i$. But I'm wondering what if we drop the assumption that all of $A_i$ must be positive, wouldn't the derivative look like this $$\frac{dS}{dA_i}=sgn(A_i)\sum_{j=1}^M\left(\sum_{i=0}^NA_ix_j^i-y_i\right)x_j^l$$ since we can stumble upon some $A_i$ that is negative and if we derive by it a minus sign will go in front, changing the equation. Is this a mistake?

• You did make a mistake. Don't know where you get the minus sign from. We have $\frac{d}{dx} x^2 = 2x$. End of transmission. – Tobias Nov 7 '16 at 18:32
• @Tobias Apply chain rule. I don't "get" a minus sign, I'm just trying to write out a general form of this derivative, that would include the case when there is at least one $A_i<0$ – bonehead Nov 7 '16 at 18:37
• The chain rule does not change a thing in what I have written. Sums and products with some constants are all linear operations that re-appear unchanged in the derivative. – Tobias Nov 7 '16 at 19:02
• Ah, yes. One more thing. The symbol $i$ is bound as summation index in the inner sum of the derivative. The formula looks like you actually mean $dS / dA_l$ instead of $d S / dA_i$. – Tobias Nov 7 '16 at 19:07
• Note, the derivative of $\sum_{i=0}^NA_ix_j^i-y_j$ w.r.t. $A_l$ is $x_j^l$. This is what you need as inner derivative and this is also what the book says. The outer derivatives are twice the sums that are squared in the original equation. – Tobias Nov 7 '16 at 19:11

Assuming all $y_j$ are zeros. Moreover, let all $x_j^i$ be zeros too except $x_1^1=t$. Then we have $S=(A_1t)^2$. What is the derivative of $S$ with respect to $A_1$:
• $2(A_1t)t$ (the book),
• $\operatorname{sgn}(A_1)(A_1t)t$ (your suggestion)?