Assume that we have this quadratic function:
$$ J = \frac {1}{2}x^TQx + c^Tx $$
And our gradient is the derivative:
$$ J_g = x^TQ + c^T $$
We want to minimize $J$ and we can do that with setting $J_g = 0$ and solve for $x^T $.
Or we can use gradient descent.
$$x^T_{k+1} = x^T_{k} +\alpha J_g(x_{k})$$
Where $\alpha > 0$ is a small number positive number.
That sounds easy. But how would I do if I want to minimize $J$ with constraints:
$$Ax \leq b $$ $$x \geq 0$$
What would I do then? What method should I use? Can I use if-statements to check when $x$ is outside of the cobstraints?