Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Sine_series_Maclaurin_Series.py
Original file line number Diff line number Diff line change
@@ -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).