Solution (source code)

= Solution

<Risk aversion> means that a sure mean is preferred to the corresponding risky <portfolio wealth>. An increasing <concave> <utility function>, with $u'>0$ and $u''\le0$, has this property by the <Jensen inequality>; <strictly concave> utility gives strict preference for nondegenerate risks. Differentiating the <expected utility> from part (a) gives
$$
U'(x)=-p(g-r)u'(w_g)+(1-p)(r-b)u'(w_b),\qquad U''(x)=p(g-r)^2u''(w_g)+(1-p)(r-b)^2u''(w_b)\le0.
$$
An interior optimum therefore satisfies
$$
\boxed{p(g-r)u'(w_g)=(1-p)(r-b)u'(w_b).}
$$
This balances the expected loss of <marginal utility> in the good state against its expected gain in the bad state. The borrowing constraint also requires checking the endpoints: $x_*=0$ if $U'(0)\le0$, while $x_*=T$ would require $U'(T)\ge0$. At $x=T$ both state wealths equal $T(1+r)$, so
$$
U'(T)=[r-pg-(1-p)b]u'(T(1+r))<0.
$$
Hence an optimum never puts all wealth into deposits. If $U'(0)>0$, continuity and the displayed endpoint sign give an interior root, and <concavity> makes every such root globally optimal. Under <strict concavity> it is unique.