# Bivariate transformation of random variables: brute force algebra?

Suppose I have 2 random variables, $$Z_1$$ and $$Z_2$$. I then define the following bivariate transformations,

$$$$X = a_xZ_1 + b_xZ_2 + c_x$$$$ $$Y = a_yZ_1 + b_yZ_2 + c_y$$

where $$a_x, a_y, b_x, b_y, c_x, c_y$$ are constants.

I want to write $$Z_1$$ and $$Z_2$$ in terms of $$X$$ and $$Y$$. Typically, this involves isolating one of $$Z_1$$, $$Z_2$$ and then plugging it into the second equation, i.e.

$$Z_2 = \frac{X-c_x-a_xZ_1}{b_x}$$ and then plug this expression into $$Y = a_yZ_1 + b_yZ_2 + c_y$$ to obtain an expression where I can write $$Z_1$$ as a function of $$X$$ and $$Y$$.

Typically, this involves some brute force algebra, and I'm wondering if there are any tips/tricks when it comes to dealing with the algebra so that I can quickly arrive at these expressions:

$$Z_1 = \frac{b_y(X - c_x) - b_x(Y-c_y)}{a_xb_y-a_yb_x}$$ $$Z_2 = \frac{a_y(X - c_x) - a_x (Y-c_y)}{a_yb_x-a_xb_y}$$

Multiply both sides of the first equation by $$b_y$$ and both sides of the second equation by $$b_x$$ and then subtract second equation from the first one. You end up with $$Z_1, X$$ and $$Y$$ since $$Z_2$$ will cancel out from the subtraction.
Can do the same type of action for $$Z_2$$