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?
-
How has India's software industry changed in recent years? What are the implications of these changes for American companies like IBM and Microsoft?
-
Draw the Lewis structure of AlH 3 . Strategy Draw the Lewis structure in the normal way but realize that, in certain cases, it is not possible to place eight electrons around the central atom.
-
6. Rebecca Reyher wrote (and copyrighted) a children's book entitled My Mother Is the Most Beautiful Woman in the World. The story was based on a Russian folktale told to her by her own mother. Years...
-
Fogerty Company makes two products, titanium Hubs and Sprockets. Data regarding the two products follow: Additional information about the company follows: a. Hubs require $32 in direct materials per...
-
WORK The standard deviation of the market-index portfolio is 50%. Stock A has a beta of 1.30 and a residual standard deviation of 60%. a. Calculate the total variance for an increase of 0.20 in its...
-
You're the pricing product manager for Lyft's ride-scheduling feature, and you're launching a new city --Toledo. The prevailing rate that people are used to paying for rides from the airport to...
-
In a paper on weather and stock market returns, the researchers write: There is strong correlation between sunlight exposure and behavior. Among other things, lack of sunlight exposure is linked to...
-
Distinguish among the following substantive tests of plant assets and indicate the assertion(s) to which each test pertains: a. Apply analytical procedures. b. Inspect plant assets. c. Examine title...
-
What circumstances pertaining to property, plant, and equipment may warrant the following assessments of inherent risk (IR)? a. Low for the existence or occurrence assertion. b. Moderate or high for...
-
Which of the following statements is generally correct about the competence of evidential matter? a. The auditors direct personal knowledge, obtained through observation and inspection, is more...
-
How practical is the workload approach to sales force size determination?
-
What factors should be considered by an auditor in specifying the acceptable level of detection risk for assertions pertaining to (a) merchandise inventory and (b) manufactured finished goods...
-
Customer L pays 16000 upfront on 1july 2020. Etna determines taht if it were to charge a separate fee for each service separately, the fee would be joining fee-2000, dental service-8000, chiroparatic...
-
What is the ideal number of children to have? This question was asked on the Sullivan Statistics Survey I. Draw a dot plot of the variable Children from theSullivanStatsSurveyI data set at...
-
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,...
-
Sevilla Chemicals earned $1 billion in after-tax operating income on capital invested of $5 billion last year. The firms cost of equity is 12%, its debt-to-capital ratio is 25%, and the after-tax...
-
Stereo City is a retailer of stereos and televisions. The firm has operating income of $150 million, after operating lease expenses of $50 million. The firm has operating lease commitments for the...
-
Jeeves Software is a small software firm in high growth. The firm is all equity financed. In the current year, the firm earned $20 million in after-tax operating income on capital invested of $60...
Study smarter with the SolutionInn App