Fixed sine and cosine in Python code