I have these system of equations that I'm solving for a 3DoF robotic joint. I've come to the pinnacle of the problem and I'm kinda stuck.

**Here $P_x$, $P_y$, $P_z$ and $a_1$, $a_2$, $a_3$ are known constants and $\theta_1$, $\theta_2$ and $\theta_3$ are unknowns to be found.**

$\begin{bmatrix}cos(\theta_1).P_x + P_y.sin(\theta_1)\\cos(\theta_1).P_y - P_x.sin(\theta_1)\\P_z \end{bmatrix}$ = $\begin{bmatrix} a_1 + a_2.cos(\theta_2)+a_3(cos(\theta_2).cos(\theta_3) - sin(\theta_2.sin(\theta_3)) \\0 \\a_2.sin(\theta_2) + a_3(cos(\theta_2).sin(\theta_3) + cos(\theta_3).sin(\theta_2))\end{bmatrix}$

Here taking equation 2 from the left matrix we get $\theta_1$ like this.

$$\frac{sin(\theta_1)}{cos(\theta_1)} = \frac{P_y}{P_x}$$ $$ tan\theta_1 = \frac{P_y}{P_x}$$ $$\theta_1 = arctan(\frac{P_y}{P_x})$$

thus giving us a system of 2 nonlinear equations with 2 unknowns.

$$[ cos(\theta_1).P_x + P_y.sin(\theta_1)] = [a_1 + a_2.cos(\theta_2) + a_3(cos(\theta_2).cos(\theta_3)-sin(\theta_2).sin(\theta_3))$$ $$[P_z] = [a_2.sin(\theta_2) + a_3(cos(\theta_2).sin(\theta_3) + cos(\theta_3).sin(\theta_2))]$$

How do I go about solving this? ( I have gone further solving these equations but got to no where ) could anyone please guide me on this?