Completing the Square on a Function