Write a program to give an approximation of sin(x) based on the user's input of x...
Fantastic news! We've located 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 userinput 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)
Here s a Python program that approximates the value of sin x using a Maclaurin series based on user input for x and the number of terms n def approxSi View the full answer
Related Book For
Applied Regression Analysis and Other Multivariable Methods
ISBN: 9781285051086
5th edition
Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg
Posted Date:
Students also viewed these programming questions

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 are decision support systems, and what role do they play in the business environment?

A skeleton of Westview Country Florist's income statement appears as follows (amounts in thousands): Use the following ratio data to complete Westview Country Florist's income statement: a. Inventory...

Why might a contractor bid on a job that has no potential for profit?

Optimize the following Boolean functions F together with the don tcare conditions d:

Debra Bishops cabinetmaking shop, in Des Moines, has five tools that automate the drilling of holes for the installation of hinges. These machines need setting up for each order of cabinets. The...

It asks to find the heat transfer rate of the dehumidification section in KW Moist air enters an airconditioning system as shown in the figure below at T = 28C, 1 = 70% and a volumetric flow rate of...

Layne Resources, Inc. has a $1,000 face value convertible bond outstanding that has a market value of $1,020. It has a coupon rate of 5 percent and matures in 12 years. The conversion price is $20....

The subject property is one year old home home. Adjusted sale prices of three comparables and net adjustment levels are as follows: C omp 1: $180,000 (10%) Comp 2 190,000 (9%) Comp 3: 200,000 (30%)....

A 6 percent coupon bond paying interest semiannually has a modified duration of 10 years, sells for $800, and is priced at a yield to maturity (YTM) of 8 percent. If the YTM increases to 9 percent,...

Balance each of the following skeletal equations by using oxidation and reduction halfreactions. All the reactions take place in acidic solution. Identify the oxidizing agent and reducing agent in...

Initiate a performance analysis of the Templeton Global Bond Fund (TPINX).

In Problems 4750, perform the indicated operations and simplify. {( =x) (Z + x)  [(x7)x  x]x}x_

Predict the major products of each of the following reactions and then balance the equations: (a) FeCrO4(s) + C(s) A (b) CrO (s) + HO*(aq) (c) MnO (s) + Al(s) A

Limelite is a Joint Stock Company in Muscat, Sultanate of Oman. Limelite was established in 2012 and has since been leading Oman Cellular Phone Accessory manufacturer, producing diverse range of...

Rewrite Programming Exercise 7.5 using streams. Display the numbers in increasing order. Data from Programming Exercise 7.5 Write a program that reads in 10 numbers and displays the number of...

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 highdensity 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,...

A shopper standing 3.00 m from a convex security mirror sees his image with a magnification of 0.250. (a) Where is his image? (b) What is the focal length of the mirror? (c) What is its radius of...

An object 1.50 cm high is held 3.00 cm from a persons cornea, and its reflected image is measured to be 0.167 cm high. (a) What is the magnification? (b) Where is the image? (c) Find the radius of...

Ray tracing for a flat mirror shows that the image is located a distance behind the mirror equal to the distance of the object from the mirror. This is stated d i = d o , since this is a negative...
Question Categories