normal equation implementation