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.