First, #sqrt(1/2) = sqrt(1) / sqrt(2) = 1 / sqrt(2)# and also #sqrt(1/8) = 1 / sqrt(8)#:
#5 * sqrt(1/2) - 2 * sqrt(1/8)#
# = 5 / sqrt(2) - 2 / sqrt(8)#
# = 5 / sqrt(2) - 2 / sqrt(4*2)#
# = 5 / sqrt(2) - 2 / (sqrt(4)*sqrt(2))#
# = 5 / sqrt(2) - 2 / (2*sqrt(2))#
# = 5 / sqrt(2) - cancel(2) / (cancel(2)*sqrt(2))#
# = 5 / sqrt(2) - 1 / sqrt(2)#
# = (5 - 1) / sqrt(2)#
# = 4 / sqrt(2)#
This might already be the final solution. However, it is nicer not to have any radicals in the denominator, so you could transform it further:
#4 / sqrt(2) = (4 * sqrt(2)) / (sqrt(2) * sqrt(2)) = (4 * sqrt(2)) / 2 = 2 * sqrt(2)#