These systems of equations become a single matrix equation...
in this case...
[X]{Y} = {Z}
[X] is a 2 by 2 matrix containing the relationship values....
[1,1]
[4,2]
{Y} is the vector containing the variables...
{pig,hen}
{Z} is the vector containing the resulting products of the equation...
{30,70}
One could compact this into a form we can even solve by fusing the right hand side into the left hand side and so equating it equal to 0 (well a vector of 0s).
[A]{B} = {0,0}
[A] is matrix [X] with vector -{Z} compentents added to it (as we had to subrast {Z] from both sides).
[1,1,-30]
[4,2,-70]
{B} is {Y} but exntended with an additional constant to accomidate the new row.
{pig,hen,1}
Note we could make the consant -1 and in doing so make the values positive that were added in matrix [A].
By utalizing matrix transformations, make [X] an eshelon matrix (diagonal of 1s).
[1,1,-30]
[4,2,-70]
goes to
[1,1,-30]
[0,-2,50]
goes to
[1,0,-5]
[0,1,-25]
Now in eshelon form, we can insert it back into the equation to get a vector equation.
{1pig + 0hen -5,0pig +1hen -25} = {0,0}
0 times anything is 0 so remove those values.
Take the constants across.
Thus we end up with the final solution.
{pig,hen} = {5,25}
Thus you can see there are 25 hens. The 5 pigs is a bonus answer. It is also technically right as the answer was worked out utalizing a single equation via rearrangements. It also did not specify you can not work out the number of pigs (just you need the number of hens) in the same equation.
However you were probably meant to do it the child way of...
4(30 - y) + 2y = 70
as shown by posters above as that will only work out the numbers of hens she had and does not utalize matrix and vector mathematics.