# Solving a pair of equations across a data set

I have the following pair of equations:

$a = x\cos(k) - y\sin(k),\ b = x\sin(k) + y\cos(k)$

I know that all variables but $k$ are in the set $\mathbb{N}^0$.

Given the above, if I know the value of $a$, $b$, and $k$, how do I compute $x$ and $y$?

• HINT: Solve the two linear simultaneous equations for $x,y$ in terms of $a,b,k$ – lab bhattacharjee Dec 7 '14 at 17:06
• I'm not sure how they're simultaneous, or how I'd re-write them. I'm sure you're correct, I just can't seem to visualise it. – Polynomial Dec 7 '14 at 17:08
• Given a value of $k$, $k_0$, there will most likely be a solution to your equations. However, if you have more than one, you probably need to look into least squares methods. – robjohn Dec 7 '14 at 17:16
• @robjohn You've lost me there. $k$ is unchanging across the data set. – Polynomial Dec 7 '14 at 17:19
• @Polynomial: wait are you saying that $k$ is a constant value? I thought $k$ was from a data set. What is varying across the data set? – robjohn Dec 7 '14 at 18:32

If we know $a$, $b$, and $k$, we have the matrix equations $$\begin{bmatrix}a\\b\end{bmatrix}=\begin{bmatrix}\cos(k)&-\sin(k)\\\sin(k)&\cos(k)\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}\\ \Downarrow\\ \begin{bmatrix}\cos(k)&\sin(k)\\-\sin(k)&\cos(k)\end{bmatrix}\begin{bmatrix}a\\b\end{bmatrix}=\begin{bmatrix}x\\y\end{bmatrix}$$ which solve for $x$ and $y$.
The first matrix equation above is a restatement of the question. The second matrix equation is the first multiplied by the inverse of the $2\times2$ matrix, and represents the solution \begin{align} x&=\hphantom{-}a\cos(k)+b\sin(k)\\ y&=-a\sin(k)+b\cos(k) \end{align} If you plug in the values for $a$ and $b$ from the question, you will see that \begin{align} \hphantom{-}a\cos(k)+b\sin(k)&=\hphantom{-}\overbrace{(x\cos(k)-y\sin(k))}^a\cos(k)+\overbrace{(x\sin(k)+y\cos(k))}^b\sin(k)=x\\ -a\sin(k)+b\cos(k)&=-(x\cos(k)-y\sin(k))\sin(k)+(x\sin(k)+y\cos(k))\cos(k)=y \end{align} since $\cos^2(k)+\sin^2(k)=1$.