A-B=4 (1)
A²+B²=58 (2)
(A-B)²=A²-2AB+B²=16
Substitute from equation (2)
(A-B)²=-2AB+58=16
So now have -2AB+58=16 or that -2AB=-42 or that AB=21
Look at A-B=4 and AB=21
Substitute A=B+4 into AB=21 and have (B+4)B=21 or that
B²+4B-21=0 which factors int (B+7)(B-3)=0 which gives that B=3 or B=-7
For B=3, A=7 and A²+B²=58
For B=-7, A=-11 and A²+B²=170 not a solution
Smaller number =3; larger number =7