Write a program to give an approximation of sin(x) based on the user's input of x...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Applied Regression Analysis and Other Multivariable Methods
ISBN: 978-1285051086
5th edition
Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg
Posted Date:
Students also viewed these programming questions
-
A. John and Jenny have been saving for two years to take their six children on a vacation to Disneyworld. They are surprised to find out that airline tickets are far more expensive than they had...
-
1. Describe how the First Amendment to the United States Constitution was interpreted in the following Supreme Court cases: (a) Engel v. Vitale (1962) (b) Schenck v. United States (1919). 2. The...
-
What legal and ethical considerations should a counsellor be aware of when working with self-harm and suicidal behaviours?
-
The Secretary of Defense shall establish which program to maintain liaison with industry advisory groups to coordinate the development of the supply catalog?
-
Determine the radius of curvature of the path described by the particle of Prob. 11.98 when t = 0, A = 3, and B = 1.
-
Write a function that will blend three sounds together. Start with part of the first sound, then a blend of sound1 and sound2, and then a blend of sound2 and sound3, and end with the rest of sound3.
-
Listed below are a number of hypothetical research hypotheses. For each hypothesis, identify the independent and dependent variable. a. Male drivers are more likely to exhibit road rage behaviors...
-
Crissie just won the lottery, and she must choose between three award options. She can elect to receive a lump sum today of $61 million, to receive 10 end-of-year payments of $9.5 million, or to...
-
Selling expenses Direct labor Interest expense Manufacturing overhead, actual Raw materials used Administrative expenses $ 159,200 304,000 40,900 112,240 484,000 115,100 During the month, 18,600...
-
The following Tableau Dashboard shows a Snakey Chart for Rumors Coffee Inc, a local coffee shop in the Midwest. Rumors Coffee Inc. pays for its expenditures using three sources of capital; cash,...
-
The Provost has commissioned a study to look at student GPAs relative to the number of hours students have reported watching TV per given week. The data shows student hours reported watching TV per...
-
Toor Industries Limited (TIL) is engaged in the production and sale of product Y, which is used in hi-tech industries. The following are the extracts from TIL's latest accounts: Sales Cost of sales...
-
While reviewing notes from past meetings with a self-employed client in preparation for an upcoming meeting, you are reading a note form 2021 where CPP Benefits were discussed. Your notes indicate...
-
Income Statements under Absorption Costing and Variable Costing Gallatin County Motors Inc. assembles and sells snowmobile engines. The company began operations on July 1 and operated at 100% of...
-
Answer any ten of the following: (") Calculate the wavelength of an electron of energy 10 eV. (in) Why do not we observe the de Broglie wavelength with a fast moving cricket ball? (1) What is the...
-
1. Which of the following is principally involved in internal communication within the body? A. The special senses. B. The respiratory system. C. The reproductive system. D. The endocrine system 2....
-
Assuming each solution to be 0.10 M , rank the following aqueoussolutions in order of decreasing pH. Rank the solutions from thehighest to lowest pH. To rank items as equivalent, overlapthem. N2H4,...
-
An Atomic Energy Commission nuclear facility was established in Hanford, Washington, in 1943. Over the years, a significant amount of strontium 90 and cesium 137 leaked into the Columbia River. In a...
-
A study was conducted by a television network in a certain state to evaluate the viewing characteristics of adult females. Each individual in a stratified random sample of 480 women was sent a...
-
An experiment was conducted regarding a quantitative analysis of factors found in high-density lipoprotein (HDL) in a sample of human blood serum. Three variables thought to be predictive of, or...
-
For the data given in Problem 11 in Chapter 7, which concerns the relationship between the temperature (X) of a certain medium and the growth (Y) of human amniotic cells in a tissue culture,...
-
What quality systems and standards exist in your organisation to 1) ensure quality across the project and 2) ensure quality within the products and services produced by your projects?
-
How can a run chart be used within a project environment?
-
Which types of tools would be useful for investigating the root cause of a problem?
Study smarter with the SolutionInn App