Following page 118 of this, I tried to solve a simple problem, but it appears to give me solutions that aren't feasible. What am I doing wrong?
The problem I want to solve is, \begin{align} \text{extrem}\ \ &x(x+1)(x-1) \\ \text{s.t.}\ \ &x \ge 0 \end{align}
My Lagrangian and the derivatives become, including my slack variable $s$, \begin{align} \mathcal{L} &= x(x+1)(x-1) + \lambda(x - s^2) = 0 \\ \frac{\partial}{\partial x} \mathcal{L} &= 3x^2 -1 + \lambda = 0 \\ \frac{\partial}{\partial \lambda} \mathcal{L} &= x - s^2 = 0\\ \frac{\partial}{\partial s} \mathcal{L} &= -2 s\lambda = 0 \end{align}
Solving these, \begin{align} 0 &= (s\lambda)^2 \\ &= x \lambda^2 \\ &= x (3x^2 -1)^2 \end{align}
This gives 3 roots $ x = 0, \pm \frac{1}{\sqrt{3}} $. The negative one doesn't satisfy the constraint. What did I do wrong?
When solving nonlinear systems of equations, you need to check for spurious solutions (or keep extremely careful track of what range of values the different expressions are allowed to attain, and how irreversible operations like squaring both sides affects these.) In this case, you cannot take $x=-\frac{1}{\sqrt{3}}$ since $s$ must be real.
Although it doesn't affect your solution, you also made a few algebra mistakes: first, in the $x$ derivative; you should get $3x^2-1+\lambda=0$.
Next, when you substitute in for $\lambda^2$, somehow the second power disappeared; you should get $$0 = x(1-3x^2)^2.$$