deriving the normal equation