Yep, I focused on all trigonometric functions take arguments and return values of type double precision. Looking for the error I lost focus on numeric values directly on the select and diff inner calculations.
I think best approach will be maintain double precision on trigonometric calculations for faster and cast to numeric before acos operation.