Consider a one period economy with K states of the world, a risk-free asset and some risky assets. Consider an agent with initial wealth x and quadratic utility $U(x) = \frac{1}{2}(a-x)^2$ Let M be a SDF. The agent maximizes their final expected utility subject to the budget constraint $x = E[MX]$, where X is their final wealth.
a) Prove that the optimal final wealth is $\overline{X} = a - (\frac{aE[M]-x}{E[M^2]})M$
b) Let $M^*$ be the orthogonal projection (under the L2 norm) of M on the space of portfolio payoffs. Show that $M^{*}$ is a SDF.
c) Define $R^{*} = \frac{M^{*}}{E[(M^{*})^2]}$ the return of the payoff $M^{*}$. Write $\overline{X}$ in terms of $a$, $x$, $R_f$ and $R^*$ only.
My approach to this question has been limited as I don't think I really understand this Stochastic Discount Factors. However, this is what I've done so far:
I started expressing the final expected utility $E[U(X)] = -\frac{a^2}{2}+aE[X]-\frac{1}{2}E[X^2]$ and tried to derive and equal it to $0$ (trying to maximize that final expected utility). However, I don't know how to introduce the SDF (M) into this equation, so I dont think this is the correct approach. Thank you in advance.
Since there are $K$ states of the world, let's define the possible outcomes for $X$ and $M$ as $\{x_1,x_2,\ldots,x_K\}$ and $\{m_1,m_2,\ldots,m_K\}$ resp. The probabilities for each state are $\{p_1,p_2,\ldots,p_K\}$. Then the expectation of the utility function can be expressed as
$$E[U(X)] = \sum_k \frac{1}{2}p_k(a-x_k)^2$$
and the condition $x=E[MX]$ can be expressed as
$$x=\sum_k p_k m_k x_k \; .$$
We can then define a Lagrange function as follows
$$L(x_k,\lambda) = \sum_k \frac{1}{2}p_k(a-x_k)^2 + \lambda\left(\sum_k p_k m_k x_k - x\right)$$
Optimization then becomes inspecting the stationary points of this Lagrange function. Therefore we take partial derivatives w.r.t. the $x_k$ and put them equal to zero which gives
$$p_k(a-x_k) + \lambda p_k m_k = 0 \;\;\; (*)$$
for each $k$.
Multiplying these equations by $m_k$ and summing over $k$ we can write this as:
$$ a E[M] - E[MX] + \lambda E[M^2] = 0$$
Since the condition is that $E[MX] = x$, we can use this to rewrite as an expression for $\lambda$
$$\lambda = \frac{x-aE[M]}{E[M^2]}$$
Putting this back in $(*)$ and summing over $k$ we get an expression for $E[X]$
$$E[X] = a + \frac{x-aE[M]}{E[M^2]}E[M]$$
which is the answer to a).
For b) and c), I'm going to need more info. But you should try yourself first.