TITLE: Derivative of absolute value of complex-valued function
QUESTION [5 upvotes]: I was wondering whether there was a nice formula for something like 
$$ \dfrac{\partial}{\partial x} \left| e^x + (1+i)e^{-x} \right|. $$
(Note that the function is chosen on purpose to have no discontinuities in the derivative, as the argument to the absolute value function never passes through zero.)
So I typed into WolframAlpha:
D[|exp(x) + (1+i)*exp(-x)|, x]

and it said:



Huh!? What imaginary component?

REPLY [3 votes]: Well from what I know, $|e^x+(1+i)e^{-x}|=\sqrt{(e^x+e^{-x})^2+e^{-2x}}=\sqrt{e^{2x}+2+2e^{-2x}}$.
Take the derivative of that to get $\dfrac{\partial}{\partial x}|e^x+(1+i)e^{-x}|=\boxed{\displaystyle \frac{e^{2x}-2e^{-2x}}{\sqrt{e^{2x}+2+2e^{-2x}}}}$.