From 45f4dc0c0b279b2b27d3a9279fdc2a8dae8b81f5 Mon Sep 17 00:00:00 2001 From: Vinay Reddy Date: Sat, 7 Oct 2023 21:44:32 +0530 Subject: [PATCH] Create Sine_series_Maclaurin_Series.py --- Sine_series_Maclaurin_Series.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Sine_series_Maclaurin_Series.py diff --git a/Sine_series_Maclaurin_Series.py b/Sine_series_Maclaurin_Series.py new file mode 100644 index 0000000..0a09088 --- /dev/null +++ b/Sine_series_Maclaurin_Series.py @@ -0,0 +1,14 @@ +from math import factorial # Import the factorial function from the math module. + +# Function to approximate the sine of an angle using the Maclaurin series. +def sine(x, terms=10): + result = 0 # Initialize the result to 0. + + for n in range(terms): + # Calculate the current term in the Maclaurin series. + term = ((-1) ** n) * (x ** (2 * n + 1)) / factorial(2 * n + 1) + + # Add the current term to the result. + result += term + + return result # Return the final approximation of sine(x).