# How can $z = xa + x$ be differentiated with only chain rule?

I am trying to put some rigour to my understanding of the Chain Rule (with Leibniz Notation). I came across this question and the second answer there (David K's) states,

$$\frac{dz}{dx} = a + 1 + x\frac{da}{dx}$$, as you surmised, though you could also have gotten that last result by considering $$a$$ as a function of $$x$$ and applying the Chain Rule.

I understand how could one evaluate $$\frac{dz}{dx}$$ using the product rule,

\begin{align*} \frac{dz}{dx} & = \frac{d(xa + x)}{dx} \\ & = \frac{d(xa)}{dx} + \frac{d(x)}{dx} \\ & = \Bigg(\frac{d(x)}{dx}a + x\frac{d(a)}{dx}\Bigg) + 1 && \text{Product Rule}\\ & = a + x\frac{da}{dx} + 1 \end{align*}

Though, I seem to be getting something wrong when using the Chain Rule,

\begin{align*} \frac{dz}{dx} & = \frac{d(xa + x)}{dx} \\ & = \frac{d(xa)}{dx} + \frac{d(x)}{dx} \\ & = \Bigg(\frac{d(xa)}{d(xa)} \times \frac{d(xa)}{d(a)} \times \frac{d(a)}{d(x)} \Bigg) + 1 && \text{Chain Rule} \\ & = \Bigg(1 \times x \times \frac{d(a)}{d(x)} \Bigg) + 1 \\ & = x\frac{d(a)}{d(x)} + 1 \end{align*}

I am missing the $$a$$ in the chain rule variant. Did I expand the chain rule correctly in terms of the Leibniz notation? What am I missing here?

EDIT: I think my mistake was the assumption that I can differentiate $$z = xa + x$$ without any form of product rule. With that being said, here is how one could do it with chain rule first and product rule second,

\begin{align*} \frac{dz}{dx} & = \frac{d(xa + x)}{dx} \\ & = \frac{d(xa)}{dx} + \frac{d(x)}{dx} \\ & = \Bigg(\frac{d(xa)}{d(xa)} \times \frac{d(xa)}{d(a)} \times \frac{d(a)}{d(x)} \Bigg) + \frac{d(x)}{dx} && \text{Chain Rule} \\ & = \Bigg(\frac{d(xa)}{d(xa)} \times \Big(\frac{d(x)} {d(a)}a + \frac{d(a)}{d(a)}x\Big) \times \frac{d(a)}{d(x)} \Bigg) + \frac{d(x)}{dx} && \text{Product Rule} \\ & = \Bigg(\frac{d(xa)}{d(xa)} \times \Big(\frac{d(x)} {d(a)}\frac{d(a)}{d(x)}a + \frac{d(a)} {d(a)}\frac{d(a)}{d(x)}x\Big)\Bigg) + \frac{d(x)}{dx} \\ & = \Bigg(1 \times \Big(a + \frac{d(a)}{d(x)}x\Big)\Bigg) + 1 \\ & = a + \frac{da}{dx}x + 1 \end{align*}

The chain rule refers here rather to the function

$$z=z(a,x)$$ $$\Rightarrow \frac{dz}{dx} = \frac{\partial z}{\partial a}\cdot\frac{da}{dx} + \frac{\partial z}{\partial x} \cdot \frac{dx}{dx}$$ $$= x\frac{da}{dx}+ a +1$$

• But aren't you treating $a$ as a variable in a multi-variable equation than a function of $x$ as in $a(x)$ as said in the quote? – scribe May 27 '20 at 4:27
• @scribe : My suggestion here is that the quote refers to the standard result, that the product rule can also be derived using the chain rule applied to $z=uv$ where $u=u(x)$ and $v=v(x)$: $$\frac{dz}{dx}= \frac{\partial z}{\partial u}\frac{du}{dx} + \frac{\partial z}{\partial v}\frac{dv}{dx} = v\frac{du}{dx} + u\frac{dv}{dx}$$ – trancelocation May 27 '20 at 6:16
• I understand. Thank You! Do you mind taking a look at the edit? I know I am making it more complicated than it needs to be but if my edit is correct, I have another question, but before that I want to know if what I did albeit long, but is correct? I do get the right answer. – scribe May 29 '20 at 0:00
• @scribe : I have checked it and it is indeed cumbersome but correct. You could ommit right from the beginning the term $\frac{d(ax)}{d(ax)}$ since it doesn't factor in anything relevant. Your mixing in of the chain rule in the beginning is rather like tecnically enforcing the appearance of this rule although it isn't necessary at all. Nevertheless, your calculations are correct now. :-) – trancelocation May 29 '20 at 4:20

There seem to be a lot of misconceptions of the chain rule there, which hopefully someone else can clear up, but I can point out that the term $$\frac{d(ax)}{d(a)}$$

is a problem. It might be meaningless, or you might have cheated your way out of using the product rule by assuming $$x$$ is not a function of $$a$$.

Nope, I did mean "assuming $$x$$ is not a function of $$a$$". Which seems a bit nonsensical, which is why I offered the option for what you wrote to be meaningless. Writing $$\frac{dA}{dB}$$ means we are comparing how $$A$$ changes in response to a change in $$B$$. If you're not careful in clarifying which quantities depend on which other quantities you'll end up with just a mess of symbols, which is what I think you've got.
The chain rule says that if $$z$$ depends on $$y$$, and $$y$$ depends on $$x$$, then $$\frac{dz}{dx} = \frac{dz}{dy} \cdot \frac{dy}{dx}$$. If you want to use the chain rule for $$\frac{dax}{dx}$$, identify what plays the role of $$y$$ and $$z$$, and check that you have a chain of dependence like that which is required by the chain rule.
• "by assuming $x$ is not a function of $a$", did you mean, "by assuming $a$ is not a function of $x$"? Because I am taking $x$ as the variable and $a(x)$ as another function of $x$ which is used to define $z(x) = a(x)x + x$. I am not trying to cheat my way out of using the product rule, I am just trying understand the claim made in the quote about being able to use chain rule by "considering $a$ as a function of $x$". – scribe May 27 '20 at 4:31
• I understand the chain rule. By $\frac{d(xa)}{da}$ what I meant is $f(x) = a(x)x, \frac{df}{da}$. So the chain rule here will be $\frac{df}{da}\frac{da}{dx}$. Which is what I had. I think my mistake was $\frac{d(xa)}{da} \neq x$. Take a look at the edit. – scribe May 28 '20 at 23:56