Inconsistencies with derivatives

106 Views Asked by At

I am working with formulas containing the complementary error function. In those formulas, I have something like $$f(\mu, \sigma) = \frac{1}{2} \cdot e^{\mu + \frac{\sigma^2}{2}} \cdot \mathrm{erfc}\left(\frac{\mu + \sigma^2}{\sigma \sqrt{2}}\right)$$ for instance.

When assuming $\mu = 0$, this simplifies to $$f(0, \sigma) = \frac{1}{2} \cdot e^\frac{\sigma^2}{2} \cdot \mathrm{erfc}\left(\frac{\sigma}{\sqrt{2}}\right)$$ and the derivatives for this simplified function are $$\begin{align} \frac{\partial f(0, \sigma)}{\partial \mu} & = 0 \\ \frac{\partial f(0, \sigma)}{\partial \sigma} & = \frac{1}{2} \cdot \sigma e^\frac{\sigma^2}{2} \cdot \mathrm{erfc}\left(\frac{\sigma}{\sqrt{2}}\right) - \frac{1}{\sqrt{2 \pi}} \end{align}$$

In order to generalise this (also look at other $\mu$), I took a look at the derivatives of $f(\mu, \sigma)$ $$\begin{align} \frac{\partial f(\mu, \sigma)}{\partial \mu} & = \frac{1}{2} \cdot e^{\mu + \frac{\sigma^2}{2}} \cdot \mathrm{erfc}\left(\frac{\mu + \sigma^2}{\sigma \sqrt{2}}\right) - \frac{1}{\sigma \sqrt{2 \pi}} \cdot e^{-\frac{\mu^2}{2 \sigma^2}} \\ \frac{\partial f(\mu, \sigma)}{\partial \sigma} & = \frac{1}{2} \cdot \sigma e^{\mu + \frac{\sigma^2}{2}} \cdot \mathrm{erfc}\left(\frac{\mu + \sigma^2}{\sigma \sqrt{2}}\right) - \frac{\sigma^2 - \mu}{\sigma^2 \sqrt{2 \pi}} e^{-\frac{\mu^2}{2 \sigma^2}} \end{align}$$ and see what happens for $\mu = 0$, we find $$\begin{align} \frac{\partial f}{\partial \mu}(0, \sigma) & = \frac{1}{2} \cdot e^{\frac{\sigma^2}{2}} \cdot \mathrm{erfc}\left(\frac{\sigma}{\sqrt{2}}\right) - \frac{1}{\sigma \sqrt{2 \pi}} \\ \frac{\partial f}{\partial \sigma}(0, \sigma) & = \frac{1}{2} \cdot \sigma e^\frac{\sigma^2}{2} \cdot \mathrm{erfc}\left(\frac{\sigma}{\sqrt{2}}\right) - \frac{1}{\sqrt{2 \pi}} \end{align}$$

Now, the derivative with regard to $\sigma$ is the same, but for $\mu$, I have two equations.

Does this mean I have a mistake in my derivatives or is it normal. I can imagine that it has something to do with the fact that $\mu$ is set to zero - this obviously makes any $\mu$ dissapear in the equation, leading to the zero derivative, but now I was wondering whether something like that is wrong and/or wheter it makes sense to do something like this. Assuming that I would be especially interested in the case $\mu = 0$, am I allowed to say that the derivative is zero or should I always go with the second "general" formula?

PS: If anyone would happen to know a better title, feel free to edit...

1

There are 1 best solutions below

3
On BEST ANSWER

We can do without partials to see what's wrong. Suppose $$f(x) = x.$$

Then $f'(x) = 1$, so $f'(0) = 1$.

On the other hand, $$f(0) = 0.$$ If one just takes the derivative of the $0$ on the right-hand side of the previous, one gets $0$ - which of course is not right, in that it is not $f'(0)$... Do you understand the problem? In any case, this is pretty much the issue with the manipulation (substitution before differentation) in your original question.