How does the product rule work for a double derivative, $\frac{\partial^2 }{\partial x^2}$?

I have this function $$A_x=A_0\frac{1}{1+e^{-az}}e^{ik(z-ct)}$$ where $$A_0$$ is a constant and $$a$$ and $$k$$ are constants with dimensions of inverse length and $$z \in \mathbb{R}$$

I wish to compute $$\frac{\partial^2 A_x}{\partial z^2}$$

So my attempt is

$$\frac{\partial^2 A_x}{\partial z^2}=A_0\left[\frac{\partial^2}{\partial z^2} \left(\frac{1}{1+e^{-az}}\right)-\frac{k^2}{1+e^{-az}}\right]e^{ik\left(z-ct \right)}$$

where I have simply applied the product rule for differentiation making the assumption that it works for double derivatives.

The reason why I have done it this way is to simplify the calculation further by using the following result:

$$\frac{\partial^2}{\partial z^2}\left(\frac{1}{1+e^{-az}}\right)=a^2\frac{e^{-az}\left(e^{-az}-1\right)}{\left(1+e^{-az}\right)^3}$$

The problem, however, is that the correct answer is

$$\frac{\partial^2 A_x}{\partial z^2}=A_0\left[\frac{\partial^2}{\partial z^2} \left(\frac{1}{1+e^{-az}}\right)+\color{blue}{2ik\frac{\partial}{\partial z}\left(\frac{1}{1+e^{-az}}\right)}-\frac{k^2}{1+e^{-az}}\right]e^{ik\left(z-ct \right)}$$

My answer is identical with the exception of the blue term, I don't understand where this term comes from and I know that my answer is wrong, but I would like to know where this term comes from and hence why the product rule does not apply to double derivatives?

• You need to differentiate one step at a time. Get the first derivative and then the second derivative. Aug 15, 2019 at 20:42
• What are $i$ and $c$ (I'm assuming $t$ is an independent variable)? Are they constants, or variables? Also (and this is just out of curiosity), why index $A$ with $x$? Isn't it simpler to just write $A$ if the $x$ is of no significance? Aug 15, 2019 at 21:20
• @Allawonder $i=\sqrt{-1}$ and $c=299792458\mathrm{ms^{-1}}$ Aug 15, 2019 at 21:22
• @Allawonder This is part of an electromagnetism problem, $A_x$ is the $x$ component of the vector potential $\vec A$. I just used the same notation as given in the problem I was working with, so for future reference, I will remember the origin of this problem and yes $t$ is an independent variable. Aug 15, 2019 at 22:40
• @BLAZE I see. In future it might be better to define all your symbols in the body of the question. Aug 16, 2019 at 9:06

The product rule is slightly different for double derivatives. For simplicity, let $$f$$ and $$g$$ be twice continuously differentiable functions of $$x$$. Then,

$$\frac{d^2}{dx^2}fg = \frac{d}{dx}\left(\frac{d}{dx}fg\right) = \frac{d}{dx}\left(f'g + fg'\right) = \frac{d}{dx}f'g + \frac{d}{dx}fg' = f''g + f'g' + f'g' + fg'' = f''g + \mathbf{2f'g'} + fg''.$$

The bold term corresponds to the blue term missing from your answer.

By the way, you can extend this to higher order derivatives in the same way. You end up with,

$$\frac{d^n}{dx^n}fg = \sum_{k=0}^n \binom{n}{k}f^{(n-k)}g^{(k)}.$$

edit: fixed typo

• Thanks for your proof and explanation, the other answers were very helpful but this one made it the clearest to me. Aug 16, 2019 at 15:55

The notation

$$\frac{\partial^2 f}{\partial x^2}$$

is an abbreviation of

$$\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}\right)$$

which is where you are confused. It means differentiate twice. Try this and you'll get the right answer.

• Thanks, but this is something I already knew, I'm just confused as I never seen an example like the one I have. Aug 15, 2019 at 20:49
• @BLAZE if you're familiar with first derivatives, simply heed the words in my answer: you need to differentiate once and apply the product rule as needed, and take the resulting function and differentiate again. The product rule is defined for first derivatives, you unfortunately cannot skip steps when differentiating here. You have to differentiate twice. Aug 15, 2019 at 20:53

Assuming no other variable apart from $$A_x$$ depends on $$z,$$ then we may simplify the result as (I'll set $$A_x=A$$) $$A=G\frac{1}{e^{mz}+e^{nz}},$$ where $$G=A_0e^{-ikct},\,\,m=-ik$$ and $$n=-a-ik.$$

Then we have that $$A'_z=\frac{-G(me^{mz}+ne^{nz})}{(e^{mz}+e^{nz})^2}.$$ If you now differentiate again (to do this easily split $$A'_z$$ into two parts and reduce the numerator of each summand to a constant by the above trick; that's better than applying the quotient rule here), and then back-substitute, you'll find this more easy to operate with, and errors easier to track.

To get the product rule for a second derivative, first start with the product rule for a first derivative: $$(fg)' = f' g + f g'.$$ Then, take the derivative again: $$(fg)'' = (f' g)' + (f g')' = [f'' g + f' g'] + [f' g' + f g''] = f'' g + 2 f' g' + f g''.$$

For higher-order derivatives, we get a general result which can be similarly proved by induction:

$$(fg)^{(n)} = \sum_{k=0}^n \binom{n}{k} f^{(n-k)} g^{(k)}.$$

Incidentally, since you mentioned partial derivatives, there is a further generalization of the above formula using the language of multi-indices, which will also allow you to calculate mixed derivatives of a product:

$$\frac{\partial^N}{\partial x^N} (fg) = \sum_{K \le N} \binom{N}{K} \frac{\partial^{N-K} f}{\partial x^{N-K}} \cdot \frac{\partial^K g}{\partial x^K}.$$

Here, if $$f, g$$ are functions of $$x_1, \ldots, x_r$$, and $$N = (n_1, \ldots, n_r)$$, then: $$\frac{\partial^N f}{\partial x^N} = \frac{\partial^{n_1 + \cdots + n_r} f}{\partial x_1^{n_1} \cdots \partial x_r^{n_r}};\\ K \le N \iff k_1 \le n_1 \wedge \cdots \wedge k_r \le n_r; \\ \binom{N}{K} = \binom{n_1}{k_1} \cdots \binom{n_r}{k_r}.$$ So for example, if we had functions $$f, g$$ of $$x, y$$ and we wanted to calculate $$\frac{\partial^3}{\partial x \partial^2 y}(f g)$$, then we would apply the formula with $$N = (1, 2)$$. The sum would involve six values of $$K$$, $$(0,0), (0,1), (0,2), (1,0), (1,1), (1,2)$$, and the end result would be: $$(fg)_{xyy} = f_{xyy} g + 2 f_{xy} g_y + f_x g_{yy} + f_{yy} g_x + 2 f_y g_{xy} + f g_{xyy}.$$

• The formula featured in this answer is sometimes attributed to Leibniz. Aug 16, 2019 at 0:32