Created
May 20, 2016 05:58
-
-
Save AFAgarap/ad81096d309a3d316fbcd972a592ad09 to your computer and use it in GitHub Desktop.
Maclaurin series for cos(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, cos(x)") | |
x = float(input("Enter value of x (in Radians): ")) | |
answer = 1; i = 1; j = 2 | |
while(i < 10 and j <= 10): | |
if (i % 2 == 0): | |
answer += (x ** j) / factorial(j) | |
elif (i % 2 != 0): | |
answer -= (x ** j) /factorial(j) | |
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