Having $(lat, lon)$ I used the following formulae to convert it to Cartesian \begin{align} x & = R \cos(lat) \cos(lon)\\ y &= R \cos(lat) \sin(lon) \end{align}
Now, I need to convert x,y back to latitude, longitude.
I need the solution for the inversion formulae
You can get the longitude by taking $\arctan \frac yx$ and correcting for the quadrant. If you have Atan2 available it will take care of the quadrant. Then you can find the $\cos$ and $\sin$ of that and divide them out. Now you just need an $\arccos$ to get there.