Updated trig functions to handle infinities