Let the two numbers be x and y.
x + y = 42 is one equation.
y = 2x is the other equation, and putting both variables on one side of the equation gives us 2x - y = 0.
This is a system of linear equations:
x + y = 42
2x - y = 0
Let M be this matrix:
1 1
2 -1
Let A be this column vector:
x
y
Let B be the column vector
42
0
Then we get this matrix equation:
MA = B.
If the determinant of M is not zero, then M has an inverse matrix M-1, and we can our matrix equation on the left by M-1, giving us
M-1MA = M-1B
But M-1M = I, so
A = M-1B
So, what is the determinant of M? M =
1 1
2 -1
so det(M) = 1*(-1) - 2*1 = -1 - 2 = -3 ≠ 0
Thus, a unique inverse of M exists. Let's find it using Cramer's rule.
1 1 | 1 0
2 -1 | 0 1
Adding row 1 to row 2,
1 1 | 1 0
3 0 | 1 1
Subtracting 1/3 of row 2 from row 1,
0 1 | 2/3 -1/3
3 0 | 1 1
Multiplying row 2 by 1/3
0 1 | 2/3 -1/3
1 0 | 1/3 1/3
Interchanging the two rows,
1 0 | 1/3 1/3
0 1 | 2/3 -1/3
Thus, M-1 is
1/3 1/3
2/3 -1/3
Let's check our work. M-1M =
1/3 1/3 x 1 1 = 1 0
2/3 -1/3 2 -1 0 1
Our work checks out. Then A = M-1B =
1/3 1/3 x 42 = 42/3 = 14 = x
2/3 -1/3 0 2*42/3 28 y
So x = 14 and y = 28. Checking our solution, substituting into our two equations:
14 + 28 = 42
2*14 - 28 = 0
Thus, x = 14 and y = 28.
There are easier ways of doing this problem, but this approach will work in any number of dimensions, not just in 2 dimensions as in this problem.