Can the quadratic equation apply to functions? I'd like to know if the approach I took below (solving quadratic formula for function $u$) was valid.
Solve for $\theta$:
$2\cos \theta = 3\cos^2 \theta - 1$
Let $u = \cos \theta$:
$0 = 3u^2 - 2u - 1$
Apply quadratic formula:
$u = \frac{1\pm 2}{3}$
$\cos \theta_1 = 1, \cos \theta_2 = -\frac{1}{3}$
$\theta_1 = \arccos(1), \theta_2 = \arccos(-\frac{1}{3})$
I only wanted $\theta$ in $(0..\pi)$, which is $\theta_2$, which I happen to know is indeed the correct answer.
Again, what I'd like to know is if my approach was valid. Specifically, substituting a variable for a function, solving the quadratic equation for that variable, then solving for the function equal to that variable. It felt wrong, but gave the correct answer. Could I do this for any $u$, or was I just fortunate that $\cos \theta$ met some condition? I tried searching the web but everything I found talking about the quadratic formula only showed examples for $x$.
 A: This is absolutely valid. In fact, the quadratic formula was unnecessary. Just as factorsies to give
$$3u^2-2u-1 \equiv (3u+1)(u-1),$$
we have the exactly analogous expression
$$3\cos^2\theta-2\cos\theta-1 \equiv (3\cos\theta+1)(\cos\theta-1)$$
Solutions to $3\cos^2\theta-2\cos\theta-1=0$ are then given by $3\cos\theta+1=0$ or $\cos\theta-1=0$.
This works for all kinds of functions. For example 
$$\operatorname{e}^{2x}-3\!\operatorname{e}^x+2 \equiv \left(\operatorname{e}^x-1\right)\left(\operatorname{e}^x-2\right)$$
and so $\operatorname{e}^{2x}-3\!\operatorname{e}^x+2=0$ over the reals if, amd only if, $\operatorname{e}^x=1$ or $\operatorname{e}^x=2$, i.e. $x=0$ or $x = \ln 2$.
~~~ EDIT ~~~ 
In general, you may apply the formula. For example
$$\cos^2\theta + 4\cos\theta + 1=0 \iff \cos\theta = -2\pm\sqrt{3}$$
$$2\ln^2x+3\ln x-4=0 \iff \ln x= -\tfrac{3}{4} \pm \tfrac{1}{4}\sqrt{31}$$
A: Your approach is absolutely correct, as long as the quantity $x$ (where $x$ is a variable, function, power of a variable, etc.) exactly matches at all terms.
This method is also applicable for solving an equation in multiple variables in terms of one of those variables.
