\[a + b = 5;\ \ ab = 4.\]
\[a^{2} + b^{2} =\]
\[= a^{2} + b^{2} + 2ab - 2ab =\]
\[= (a + b)^{2} - 2ab = 5^{2} - 2 \cdot 4 =\]
\[= 25 - 8 = 17.\]