Solving a set of 3 Nonlinear Equations In the following 3 equations:
$$
k_1\cos^2(\theta)+k_2\sin^2(\theta) = c_1
$$
$$
2(k_2-k_1)\cos(\theta)\sin(\theta)=c_2
$$
$$
k_1\sin^2(\theta)+k_2\cos^2(\theta) = c_3
$$
$c_1$, $c_2$ and $c_3$ are given, and $k_1$, $k_2$ and $\theta$ are the unknowns. What is the best way to solve for the unknowns? Specifically, I need to solve many independent instances of this system in an algorithm. Therefore, ideally the solution method should be fast.
 A: Re-write in terms of double-angle expressions, and define values $A$, $B$, $C$:
$$\begin{align}
k_1 \cos^2\theta + k_2 \sin^2\theta = c_1 &\quad\implies\quad \cos 2\theta = \frac{2 c_1-k_1-k_2}{k_1-k_2} & =: A \\[5pt]
2 \left(k_1-k_2\right) \sin\theta \cos\theta = c_2 &\quad\implies\quad \sin 2\theta = \frac{c_2}{k_1-k_2} &=: B \\[5pt]
k_1 \sin^2\theta + k_2 \cos^2\theta = c_3 &\quad\implies\quad \cos 2\theta = \frac{k_1+k_2-2c_3}{k_1-k_2} &=: C
\end{align}$$
Now, $A=C$ implies $k_1 + k_2 = c_1 + c_3$ (but we'd know that simply by adding your first and third equations together), so that $k_2 = c_1+c_3-k_1$ and
$$
A = \frac{c_1-c_3}{2k_1-c_1-c_3} \qquad\qquad
B = \frac{c_2}{2k_1-c_1-c_3}
$$
Observe that you can already write
$$\tan 2\theta = \frac{c_2}{c_1-c_3}$$
which gives you $\theta$. For $k_1$ and $k_2$, note that $A^2+B^2=1$ implies
$$(c_1-c_3)^2 + c_2^2 = \left(2k_1-c_1-c_3\right)^2$$
so that
$$\begin{align}
k_1 &= \frac{1}{2}\left( c_1+c_3 \pm \sqrt{(c_1-c_3)^2+c_2^2} \right) \\
k_2 &= \frac{1}{2}\left( c_1+c_3 \mp \sqrt{(c_1-c_3)^2+c_2^2} \right)
\end{align}$$
(I would guess that the $k_1$ and $k_2$ are simply the two roots of the quadratic ---so that, say, $k_1$'s "$\pm$" is "$+$", while $k_2$'s "$\mp$" is "$-$"--- but this ambiguity is really for you to resolve based on your circumstances.) 
A: Put $u_1 = k_1 + k_2$ and $u_2 = k_2 - k_1$. Then, as Anil Baseski mentioned in the comment, the equation is transformed into
$$ \begin{cases}
u_1 &= c_1 + c_3 \\
u_2 \sin(2\theta) &= c_2.
\end{cases} $$
So it seems that a solution is not uniquely determined from the given conditions.
A: We can rewrite the system of equations as
$$\begin{align} (k_1 - k_2) \cos^2 \theta &= c_1 - k_2 \\ (k_1 - k_2) \cos^2 \theta &= k_1 - c_3 \\ 2 (k_1 - k_2) \sin \theta \cos \theta &= -c_2. \end{align}$$
Or, equivalently, 
$$\begin{align} (k_1 - k_2) \cos^2 \theta &= c_1 - k_2 \tag{1} \\ (k_1 - k_2) \cos^2 \theta &= k_1 - c_3 \tag{2} \\ (k_1 - k_2) \cos^2 \theta &= -\frac{c_2}{2} \cot \theta. \tag{3} \end{align}$$
Using (1) and (3) we can isolate $k_2$ as $$k_2 = c_1 + \frac{c_2}{2} \cot \theta.$$ Similarly, we can isolate $k_1$ as $$k_1 = c_3 - \frac{c_2}{2} \cot \theta.$$ Substituting this in (3), we get $$(c_3 - c_1 - c_2 \cot \theta) \cos^2 \theta = -\frac{c_2}{2} \cot \theta.$$
From this you can solve $\theta$, and using (1) and (2) you can then also solve for $k_1$ and $k_2$.
A: Hint:
$k_1 \cos^2(\theta)+k_2 \sin^2(\theta) = c_1$
$k_1 \sin^2(\theta)+k_2 \cos^2(\theta) = c_3$
$c_1+c_3=k_1+k_2$
$2(k_2-k_1)\cos(\theta)\sin(\theta)=c_2 \implies (k_2-k_1)\sin 2\theta=c_2$
$(k_2-k_1) \sin 2 \theta+k_1+k_2=c_1+c_2+c_3$
$k_2(\sin 2 \theta+1)+k_1(1- \sin 2\theta)=c_1+c_2+c_3$
A: Add and subtract equations $1$ and $3$, giving the system
$$\begin{cases}\begin{align}k_1+k_2&=c_1+c_3\\(k_1-k_2)\sin2\theta&=-c_2\\(k_1-k_2)\cos2\theta&=c_1-c_3\end{align}\end{cases}$$
Then you find $k_1-k_2$ and $2\theta$ by a polar-to-Cartesian transform, giving
$$\begin{cases}\begin{align}k_1+k_2&=c_1+c_3,\\k_1-k_2&=\sqrt{c_2^2+(c_1-c_3)^2},\\2\theta&=\arctan_2(-c_2,c_1-c_3).\end{align}\end{cases}$$
