# Why differentiating a function is similar to differentiating its log function?

$f(6;p)=\binom{25}{6}p^6(1-p)^6,\quad 0\le p\le1$

I have three questions:

$(1)$To find the relative maxima of p, the process is to take the derivative of the function with respect to $p$ equal to $0$ and solving the resulting equation for $p$.

For easy computation we take the log of the function & differentiate the log function with respect to $p$ equal to $0$ and solving the resulting equation for $p$.

$\bullet$"My Question Is Why $\frac{d}{dp}f(6;p)$ is similar to $\frac{d}{dp}\log f(6;p)$"

(2) After the step(1) i found that $p=\frac{6}{25}$ is the only root.

But on the book, which i am reading, is written that $p=0,1,\frac{6}{25}$ are the roots.

$\bullet$"How p=0,1 can be root? The denominator $p(1-p)$ becomes $0$ when i do cross multiplication."

(3)To check which value of $p$ maximize $f(6;p)$ , we take the second derivative of the function with respect to $p$ and set $p=0,1,\frac{6}{25}$ respectively. If the second derivative is less than $0$, then $p=$ that value maximize the function .

for $p=\frac{6}{25}$ the second derivative is $-125.56<0$ , so $p=\frac{6}{25}$ gives maximum.

i also got for $p=0,1$ the second derivative is $\quad-\infty$ , so $p=0,1$ also give maximum. But the book commented out that $p=0,1$ give a minimum.

$\bullet$"How $p=0,1$ give a minimum?"

• If $f$ is positive, then, as $\log$ is strictly increasing, we have that $f(x)$ is maximal iff $\log(f(x))$ is maximal. – Berci Jun 12 '13 at 9:08
• I assume the exponent of $(1-x)$ should by $25-6$ rather than $6.$ – Will Orrick Jun 12 '13 at 9:21
• @BrianM.Scott the derivative of the log is $0$ at $p=\frac{6}{25}$ because $\log f(6;p)=\log \binom{25}{6}+6\log p+19\log(1-p)$. and $\frac{d}{dp}\log f(6;p)=0+\frac{6}{p}-\frac{19}{1-p}$. and $\frac{d}{dp}\log f(6;p)=0\Rightarrow\frac{6}{p}-\frac{19}{1-p}=0$ – time Jun 12 '13 at 9:30
• @BrianM.Scott & Will Orrick I am really sorry. the exponent of $(1-p)$ is $19$, ie, $f(6;p)=\binom{25}{6}p^6(1-p)^{25-6}$ – time Jun 12 '13 at 9:35
• Not to worry; I should have realized from the context what it was supposed to be. – Brian M. Scott Jun 12 '13 at 9:36

## 2 Answers

There is a typo in the post, presumably you mean $p^6(1-p)^{19}$.

Since $\log$ is an increasing function, finding the maximum of $p^6(1-p)^{19}$ and finding the maximum of its logarithm are equivalent problems. There is a bit of a question mark about the endpoints $p=0$ and $p=1$, but the maximum is clearly not there, so we are examining the logarithm in the interval $(0,1)$, where there is no issue.

The logarithm is $6\log p +19\log(1-p)$, which has derivative $\frac{6}{p}-\frac{19}{1-p}$.

This derivative is not $0$ at $p=0$ or $p=1$, in fact it is undefined at these places.

It is true that the derivative of $p^6(1-p)^{19}$ is $0$ at $p=0$ and $p=1$, in addition to $p=\frac{6}{25}$, for the derivative is $(p^6)(-19)(1-p)^{18}+(1-p)^{19}(6)(p^5)$. This clearly vanishes at $p=0$ and $p=1$. In fact, by taking out the common factor $p^5(1-p)^{18}$, we can quickly find where the derivative is $0$ without doing the detour through logarithms.

The second derivative is not really suitable for testing what happens at the endpoints. I assume these are probabilities, so $p$ is restricted to the interval $[0,1]$. Our original expression is obviously $0$ at the endpoints, and positive if $0\lt p\lt 1$, so it is clear that we have an absolute minimum at $0$ and at $1$.

Actually, I would not use the second derivative test at all. Our derivative simplifies to $\frac{6-25p}{p(1-p)}$. The denominator is positive for all $p$ in the interval $(0,1)$. Looking at the numerator, we can see it is positive up to $p=\frac{6}{25}$ and then negative. So the logarithm is increasing in the interval $(0,\frac{6}{25}]$, and then decreasing, so reaches a maximum at $p=\frac{6}{25}$.

• Would you like to explain me if $\frac{d}{dp}f(6;p)$ is similar to $\frac{d}{dp}\log f(6;p)$ then why $p=0,1,\frac{6}{25}$ when $\frac{d}{dp}f(6;p)=0$ and why $p=\frac{6}{25}$ when $\frac{d}{dp}\log f(6;p)=0$ – time Jun 12 '13 at 10:00
• The logarithm goes nuts when $p=0$ and $p=1$. So it is useful only in the interval $(0,1)$. – André Nicolas Jun 12 '13 at 10:04
• Thank you very much, André Nicolas. Thank you,all. – time Jun 12 '13 at 10:08

I agree with André Nicolas that $0$ and $1$ are probably meant to be regarded as endpoints, and therefore should not be treated with the second derivative test. But even if you take the problem at face value, and consider $p$ to lie in the interval $(-\infty,\infty),$ which is what the book seems to do, there are issues at $p=0,1$ that are worth getting right.

The book's solution is suggesting logarithmic differentiation. The idea is that $$\frac{d}{dp}\log f(p)=\frac{f'(p)}{f(p)},$$ and therefore $$f'(p)=f(p)\frac{d}{dp}\log f(p).$$ This is useful since, as you found, the derivative of $\log f(p)$ is much easier to compute than would be the derivative of $f(p)$ directly. Nevertheless, you have to remember to multiply the derivative of $\log f(p)$ by $f(p)$ in order to get $f'(p)$. When you do that, you find that $0$ and $1$ are indeed roots of $f'(p).$

To compute the second derivative, you can use logarithmic differentiation again, but you should make sure to simplify $f'(p)$ first. That is, make sure to express $f'(p)$ as a product of factors before taking the logarithm again.

What you will find at the end of all this is that $f''(0)=f''(1)=0.$ When $f''(p)=0$ at a critical point of $f,$ it is not possible to draw any conclusion from the second derivative about whether that critical point is a relative minimum or maximum. It is necessary to use the first derivative for this. What you will find is that $p=0$ is a relative minimum and that $p=1$ is neither a relative minimum nor a relative maximum. On the interval $[0,1],$ however, both $p=0$ and $p=1$ are absolute minima. The graph should make this clear.

• Thank you.Your answer is also very informative. – time Jun 12 '13 at 10:17