Question: Write a program to give an approximation of sin(x) based on the user's input of x and n Task 1: 1. Define the function


Write a program to give an approximation of sin(x) based on the user's input of x and n Task 1: 1. Define the function approxSin with two parameters: x (float) and n (integer) 2. Write a loop that computes that computes that approximate value of sin(x) computed using n terms of the Maclaurin series 3. Return the compute value for approximation. Do not print anything. Task 2: 1. Define the main function with no arguments 2. Prompt the user to input values for x and n. You can assume that the user would input valid values for x and n 3. Call the function approxSin with the user-input x and n as arguments to compute the approximation for sin(x) 4. Print a message that displays the computed approximation for sin(x) 5. Print a message that displays the difference between the computed approximation and the actual value for sin(x) 6. Call the main function. We will use a special call for the main function as shown below: if name == 11 '____main__": main () Notes: You may use the input() function to prompt the user for inputs Use the round function to round the final values of the approximation and the difference to 6 decimal places. Make sure to round when printing and not before computing the difference You may use the sin() function from the math library to compute the actual value You may use the factorial() function from the math library to compute the value of factorial of a number Sample Input/Output: >> Input a value for x: 1.5 >> Input a value for n: 3 >> The approximate value of sin computed using 1.5 and 3 is 1.000781 >> The difference between actual sin and approximate value is -0.003286 README
Step by Step Solution
3.48 Rating (148 Votes )
There are 3 Steps involved in it
Heres a Python program that approximates the value of sinx using a Maclaurin series based on user input for x and the number of terms ndef approxSinx ... View full answer
Get step-by-step solutions from verified subject matter experts
