Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update maths/maclaurin_sin.py
Co-authored-by: Christian Clauss <cclauss@me.com>
  • Loading branch information
chriso345 and cclauss authored Oct 21, 2022
commit f276cb22c97e05c3d6e4ab8dbbde35dd6fa1967e
11 changes: 5 additions & 6 deletions maths/maclaurin_sin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ def maclaurin_sin(theta: float, accuracy: int = 30) -> float:
raise ValueError("maclaurin_sin() requires a positive int for accuracy")

theta = float(theta)

div = theta // (2 * pi)
theta = theta - (2 * div * pi)

total = 0
for r in range(accuracy):
total += ((-1) ** r) * ((theta ** (2 * r + 1)) / (factorial(2 * r + 1)))
theta -= 2 * div * pi
return sum(
((-1) ** r) * ((theta ** (2 * r + 1)) / factorial(2 * r + 1))
for r in range(accuracy)
)
return total


Expand Down