Calculating mean variance portfolio with risk aversion parameter I want to calculate the classic mean variance portfolio (Markowitz) with a risk aversion parameter $\gamma$. 
I have the following problem where I want to maximize:


  $max(x_t) \ \ x_t^T\mu_t - \frac{\gamma}{2}x_t^T\Sigma_tx_t$


Where $\mu$ = mean 

$x_t$ = portfolio at time $t$

$\Sigma$ = sample covariance matrix

w(t) is the vector of relative weights in the portfolio, calculated as follows: 

$w_t=\frac{x_t}{1_N^Tx_t}$

1_N is a vector of ones (N elements)

My concern is that in the literature I have seen only solution for the above maximization problem where the risk aversion parameter drops out:

$w_t=\frac{\Sigma_t^{-1}\mu_t}{1_N\Sigma_t^{-1}\mu_t}$

I'm wondering at which point do we account for the risk aversion parameter during the optimization?
Here's how you would account for risk aversion.

First of all, I think this problem is usually set up using weights as the variables (see here http://www.math.ku.dk/~rolf/CT_FinOpt.pdf, page 141). If you want to use dollar weights, you will have to transform the result.

The optimization problem is:

$$ \max_w \quad  w'\mu −\frac{\gamma}{2} w'\Sigma w$$ 

Weights add up to 1:

$$ w'e = 1 $$

Where you have $N$ assets, $w$ and $\mu$ are $N\times1$ vectors, and $\Sigma$ is an $N\times N$ matrix. $e$ is an $N\times1$ vector of ones.

The Lagrangian for the problem is:

$$ \max_w \quad  w'\mu −\frac{\gamma}{2} w'\Sigma w + \lambda (w'e - 1)$$ 

To optimize, we take the gradient of the objective function, and set each element equal to zero. So we will have an $N\times 1$ vector equation:

$$0 = \mu - \gamma \Sigma w + \lambda e$$

This can be solved for $w$:

$$w = \left(\gamma \Sigma\right)^{-1} \left(\mu + \lambda e\right)$$

Plugging this back into the constraint, we get:

$$ \left(\left(\gamma \Sigma\right)^{-1} \left(\mu + \lambda e\right)\right)'e = 1$$

The transpose reverses the order of the terms, and has no effect on the symmetric $\Sigma^{-1}$ matrix:

$$ \left(\left(\mu' + \lambda e'\right)\frac{\Sigma^{-1}}{\gamma} \right)e = 1$$

This can be simplified to:

$$ \mu' \Sigma^{-1} e + \lambda e' \Sigma^{-1} e = \gamma$$

Solving for $\lambda$, we get

$$ \lambda = \frac{\gamma - \mu' \Sigma^{-1} e}{e'\Sigma^{-1} e} $$

So the overall formula for the weights is:

$$w = \left(\gamma\Sigma\right)^{-1} \left(\mu + \frac{\gamma - \mu' \Sigma^{-1} e}{e'\Sigma^{-1} e} e\right)$$