Solving the system $k= a\cos\alpha+b\sin\beta$, $h=a\sin\alpha+b\cos\beta$ I've got problems with this system. I need to calculate $\theta_2$ and $\theta_4$ knowing all the other values $(k,~h,~a_2,~a_3)$. Any idea on how I can solve this?
\begin{equation}
    \begin{cases}
      k= a_{2}\times\cos(\theta_{2}) + a_{3}\times\sin(\theta_{4})\\
      h= a_{2}\times\sin(\theta_{2}) + a_{3}\times\cos(\theta_{4})\\
    \end{cases}\,.
\end{equation}
As suggested, I'll link some of my tries in resolving this problem, all without success.
First Try, using the relation $\sin^2(x) + \cos^2(x) = 1$
Second Try, elevating everything squared
Third Try, using an extended version of sum-to-product formulas
Clarification: this formulas comes from a kinematic problem, I'm trying to model this arm. I'm sorry if it appears confusing.
 A: Edit: a simpler solution than the first one (that you will still find at the bottom).
Your equations evidently come from:
$$\underbrace{\binom{k}{h}}_{V=\vec{OM}}= \underbrace{a_{2}\binom{\cos(\theta_{2}) }{\sin(\theta_{2})}}_{V_1=\vec{OE}}+\underbrace{a_{3}\binom{\cos(\theta_{4})}{\sin(\theta_{4})}}_{V_2=\vec{EM}}\tag{*}$$
(where $E$ is the "elbow" of the articulated arm).
Consider the following figure (with my own notations, sorry, $a_k$ for the angles, $a,b,c$ for the lengths) where the position of $M$ is known ; otherwise said, angle $a_1$ and length $b=OM$ are known.
We are in a "SSS" configuration (S = side) where all the sides are known. We are therefore able to deduce all the angles. In fact, we need to determine only two of them given by the cosine law:
$$\begin{cases}a^2&=&b^2+c^2-2bc \cos(a_1-a_3)\\ c^2&=&a^2+b^2-2ab \cos(a_2-a_1) \end{cases}$$
giving $a_1-a_3=\cos^{-1}(...)$ and $a_2-a_1=\cos^{-1}(...)$ and therefore giving $a_2$ and $a_3$ (because $a_1$ is known).

The second part of the image displays the four possible triangles. Indeed, we have considered a case were the signed angle $a_2-a_1$ is positive : this is essential to be allowed to use $\cos^{-1}$ in $a_2-a_1 = \cos^{-1}(...)$ this is essential. If $a_2-a_1 < 0$ (as is the case where $E$ is in $E_3$), one must consider the unsigned angle $|a_2-a_1|=\cos^{-1}(...)$ and, in a second step, come back to the signed angle, by expressing the fact that $a_2-a_1=-|a_2-a_1|$.
Remark: I just found a similar computation here.

Alternative solution:
In your issue, $M$ is a given point in the "reach" of the articulated arm, meaning that $\|V\|\le \|V_1\|+\|V_2\|$.
Due to the fact that $dist(E,M) = dist(M,E)$, $E$ is to be taken as one of the two intersection points of the circle with center $M$ and radius $a_3$ and the circle with center $0$ and radius $a_2$ ; it amounts to solve the system:
$$\begin{cases}(x-k)^2+(y-h)^2&=&a_3^2 \\ x^2+y^2&=&a_2^2\end{cases}$$
This is done by classical algebraic manipulations giving a quadratic equation in $x$ by elimination of variable $y$ :
$$x^2+\frac{1}{h^2}\left(\frac12 (h^2+k^2-a_3^2+a_2^2)-kx\right)^2=a_2^2$$
Let $x_0$ be one of the roots (there are in general two roots): from it, we get $y_0=\pm \sqrt{a_2^2-x_0^2}$. Now, take:
$$\theta_2=atan2(y_0,x_0)\tag{1}$$
(do you know the extension $atan2$ of $atan$ ?)
Once you have $\theta_2$, it's easy to get $\theta_4$ using formulas (*):
$$\theta_4=atan2(k-a_2 \cos(\theta_2),h-a_2 \sin(\theta_2))\tag{2}$$
A: You have the system
$$ k = a \cos \alpha + b \sin \beta $$
$$ h = a \sin \alpha + b \cos \beta $$
where $k,h,a,b$ are known, and you want to find $\alpha, \beta$
Define the three vectors
$ u = \begin{bmatrix} k \\ h \end{bmatrix} $
$ v_1 =\begin{bmatrix} \cos \alpha \\ \sin \alpha \end{bmatrix} $
$ v_2 =  \begin{bmatrix} \sin \beta \\ \cos \beta \end{bmatrix} $
Then,
$ u = a v_1 + b v_2 $
Note that  $v_1$ and $v_2$ are unit vectors.
Now solve for $v_2$:
$ v_2 = \dfrac{1}{b} ( u - a v_1 ) $
Since $v_2$ is a unit vector, then
$v_2^T v_2 = 1 $
Therefore,
$ \dfrac{1}{b^2} ( u^T u + a^2 - 2 a u^T v_1 ) = 1 $
This equation is of the form
$ A \cos \alpha + B \sin \alpha = C $
where,
$ A = 2 a k , B = 2 a h , C = k^2 + h^2 + a^2 - b^2  $
It can be solved for $\alpha$ by angle shift method, namely
$ A \cos \alpha + B \sin \alpha = \sqrt{A^2 + B^2} \cos(\alpha - \gamma)$
where $\cos \gamma = \dfrac{A}{\sqrt{A^2 + B^2}} $ and $ \sin \gamma = \dfrac{B}{\sqrt{A^2 + B^2}} $
Hence,
$\alpha = \gamma \pm \cos^{-1} \dfrac{ C }{\sqrt{A^2 + B^2} } $
Once we have $\alpha$ , vector $v_1$ is determined, from which we can calculate vector $v_2$ from $ v_2 = \dfrac{1}{b} (u - a v_1 ) $, and finally $\beta$ can be determined because
$ \sin \beta = v_{2x} $ and $ \cos \beta = v_{2y} $
So, $\beta = \text{Atan2}( v_{2y}, v_{2x} ) $
A: A purely algebraic approach
Using $c$ for $\cos(.)$ and $s$ for $\sin(.)$, rewrite the problem as
$$K= c_{2} + \alpha\, s_4 \tag1 $$
$$H=s_{2} + \alpha\, c_{4} \tag 2$$
$$1=c_2^2+s_2^2 \tag 3$$
$$1=c_4^2+s_4^2 \tag 4$$ where $K=\frac k{a_2}$ and $\alpha=\frac {a_3}{a_2}$.
Now, two elimination steps
$$(1) \qquad \implies  \qquad c_2=K-\alpha\,s_4\tag 5$$
$$(2) \qquad \implies  \qquad s_2=H-\alpha\,c_4\tag 6$$
Plug $(5)$ and $(6)$ in $(3)$ and solve for $c_4$ from the equation (squaring to get a quadratic equation
$$c_4=\frac{H}{\alpha }\pm\sqrt{\left(\frac{1+K}{\alpha }-s_4\right) \left(\frac{1-K}{\alpha }+s_4\right) } \tag 7$$
Plug in $(4)$ and you will obtain another quadratic in $s_4$.
As a total, four solutions.
