Question: PYTHON ONLY! FOLLOW GUIDE GIVEN Implement the function sin() in sin. py that calculates the sine of the argument chi in radians, using the formula:
PYTHON ONLY! FOLLOW GUIDE GIVEN
Implement the function sin() in sin. py that calculates the sine of the argument chi in radians, using the formula: sin (x) = x - x^3/3! + x^5/5! - x^7/7! + middot middot middot. $ python sin. py 60 0.866025403784 0.866025403784 import math import studio import sys # Return sin(x) calculated using the formula: # sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... def sin(x): # Initialize total (sum of the series) to 0.0. # Initialize term (each term in the series) to 1.0. and sign (sign of # the term) to 1. # Initialize i (loop variable) to 1. ... # Repeat until convergence, while .... # Set term to its previous value times x divided by i. # If i is odd. increment total by sign * term, and toggle sign. # Increment i. ... # Return the result. ... # Test client [DO NOT EDIT], Reads a float x (representing an angle in # degrees) from the command line and prints sin(x) and math.sin(x). def _main(): x = math.radians(float (sys.argv[1])) studio, write ln(sin (x)) studio, write ln(math. sin(x)) if _name_ ='_ main_': main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
