Deriving pythagorean identity