Possibly multiplying the numbers by themselves instead of "squaring" might be considered an optimization, depending on how a computer language might implement squaring. Your using squaring instead of taking square roots is already a major optimization over a really naive way you could have done it.