# How to maximise this function: $p \log (1 + x) + q \log (1 − x)$?

Hint: Use the fact that $p \log (1 + x) + q \log (1 − x)$ is maximized when $x = p − q$.

Secondly it was written: Let $f : (-1,1) \rightarrow \mathbb{R} : x \mapsto p\log (1+x) + q \log (1-x).$ Then using the hint above, $f$ is maximised at $p-q$ and $f(p-q) = \log 2 + p\log p + q\log q.$

My first question is, how (possibly using analysis/calculus?) would you deduce/get that $p \log (1 + x) + q \log (1 − x)$ is maximized when $x = p − q?$

The other thing, I have trouble understanding what exactly does $f : (-1,1)$ mean? And how would I intepret/read the following line? Its a bit new to me as I have not seen functions written like the following before. $f : (-1,1) \rightarrow \mathbb{R} : x \mapsto p\log (1+x) + q \log (1-x).$

Lastly, it says that $f$ is maximised at $p-q$ and $f(p-q) = \log 2 + p\log p + q\log q.$ How do you get that $f(p-q) = \log 2 + p\log p + q\log q?$ I tried substituting it into $f(x)=p\log (1+x) + q \log (1-x)$, getting $f(p-q) = p\log(1+p-q) + q\log(1-p+q).$ How would I go about from there?

-
It is rather bad form to remove questions from your post when people have already addressed them in their answer; it makes it look like they don't know what they are talking about to new readers. It's worse if you then try to edit people's answers to remove content because of the content you decided to remove from your own post. And to try to do so 12 days after the fact on top of that... –  Arturo Magidin Apr 2 '12 at 1:42
Thanks, I already flagged this post stating the (valid) reason, why this question should be deleted. Appreciate if you could take a look. –  Heijden Apr 2 '12 at 2:00
I can't think of a reason why a question posted 12 days ago, with an accepted answer, should be deleted; unless, of course, you are somehow trying to cover your tracks for some reason... in which case it should definitely not be deleted. –  Arturo Magidin Apr 2 '12 at 2:06
@Arturo, I have rolled it back to a more suitable version. –  user21436 Apr 2 '12 at 2:16
@ArturoMagidin, I flagged this post to a moderator stating my reason to remove this question, and I am not covering my tracks, in my (original) post I am just asking for explanations to a few things, not trying to get anyone to solve the question for me, hence there is no need to 'cover my tracks'. I gave the reason to the moderator when i flagged it. –  Heijden Apr 2 '12 at 2:20

For your first question, you can see that $p \log (1 + x) + q \log (1 − x)$ is maximized when $x=p-q$ by taking the derivative at setting it equal to $0$. We have $$0=\frac{d}{dx}(p \log (1 + x) + q \log (1 − x))=-\frac{p}{1+x}+\frac{q}{1-x}=\frac{-p(1-x)+q(1+x)}{(x+1)(x-1)}$$ and so $(q-p)+(p+q)x=0$ hence $x=\frac{p-q}{p+q}$, and since $q=1-p$ this simplifies to $x=p-q$. This tells us that $p \log (1 + x) + q \log (1 − x)$ has an extremum at $x=p-q$, and this extremum must be the maximum as making $x$ near $1$ or $-1$ makes $\log(1-x)$ or $\log(1+x)$ very negative, respectively.

For your second question, "$f: (-1,1)$" doesn't mean anything. However, the full statement "$f:(-1,1)\to \mathbb R$" means "$f$ is a function from $(-1,1)$ to $\mathbb R$ (the real numbers)". In your case, the statement $$f : (-1,1) \rightarrow \mathbb{R} : x \mapsto p\log (1+x) + q \log (1-x)$$ means "$f$ is a function from $(-1,1)$ to $\mathbb R$ such that $f(x)=p\log (1+x) + q \log (1-x)$ for any $x\in (-1,1)$ (any $x$ between $-1$ and $1$)".

Edit: To get that $f(p-q)=\log 2+p\log p+q\log q$, use the fact that $p=1-q$ and $q=1-p$ so $$\begin{eqnarray} f(p-q)&=&p\log(1+p-q) + q\log(1-p+q)\\ &=&p\log(1+p-(1-p)) + q\log(1-(1-q)+q)\\ &=&p\log(2p) + q\log(2q)\\ &=&p(\log 2+\log p) + q(\log 2+\log q)\\ &=&(p+q)\log 2+p\log p + q\log q\\ &=&\log 2+p\log p+q\log q. \end{eqnarray}$$

-
Why the downvote? –  Alex Becker Apr 2 '12 at 2:00
$f: (-1,1) \to \mathbb R$ just means that $f$ is a function defined on the interval $(-1,1)$ with values in the real line.
To find critical points of $f(x) = p \log(1+x) + q \log(1-x)$, solve $f'(x)=0$ for $x$. You should find exactly one critical point, at $x=p-q$ (if you remember that $p+q=1$). Note that this is a local maximum (e.g. by using the second derivative test, or noting that $\log(1+x)$ and $\log(1-x)$ are concave functions). If a differentiable function has only one critical point in an interval and it is a local maximum, then it is a global maximum on that interval.