''' can you provide a sample python code to approximate the sine function? ''' import math def sin(x, n=10): """ Computes the approximation of sine function for a given angle x using the first n terms of the Taylor series. """ sine = 0.0 for i in range(n): sign = (-1) ** i numerator = x ** (2*i + 1) denominator = math.factorial(2*i + 1) sine += sign * numerator / denominator return sine # Example usage x = math.pi/4 print("sin({}) = {}".format(x, sin(x))) # Output: sin(0.7853981633974483) = 0.7071067811865476 sin(x) ≈ x - x^3/3! + x^5/5! - x^7/7! + ... + (-1)^n * x^(2n+1) / (2n+1)!