When is this a perfect square?