Improved performance: Added function to calculate sine from cosine, using sin^2 x + cos^2 x = 1 and condition for negative sine.