Created
May 20, 2016 05:59
-
-
Save AFAgarap/921938815cf067d8d00c3ec0fd3a87fb to your computer and use it in GitHub Desktop.
Maclaurin series for sin(x)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
print("\t\t\t10th degree of Maclaurin series, sin(x)") | |
x = float(input("Enter value of x (in Radians): ")) | |
answer = x; i = 1; j = 1 | |
while(i < 10): | |
if(i == 1): | |
answer -= (x ** (j + 2)) / factorial(j + 2) | |
elif(i % 2 == 0): | |
answer += (x ** (j + 2)) / factorial(j + 2) | |
elif(i % 2 != 0): | |
answer -= (x ** (j + 2)) / factorial(j + 2) | |
i += 1; j += 2 | |
print(answer) | |
def factorial(number): | |
return 1 if (number == 0) else (number * factorial(number - 1)) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment