Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ (if you dont understand part of the code dont answer this at all) How output should look Lab 6 - Functions: Taylor Series Objectives

C++ (if you dont understand part of the code dont answer this at all) image text in transcribed
image text in transcribed
How output should look
image text in transcribed
Lab 6 - Functions: Taylor Series Objectives Make use of various "pass by value" functions to solvea single problem Apply programming to math (calculus) concepts The cosine of an angle can be computed from the following infinite series: Your task is to make a program t manner described above. To do this, you will need to make use of a number of functions and a menu system. hat will calculate Cos x in the Factorial: This should take in a double n. This should return the factorial of n as a double. (You cannot return anything but a double do to the fact that no other data type can hold numbers large enough to support a factorial greater than 20) The formula for factorial is: n!-n(n-1) (n-2)* 1 Ex: 5!-5*432*1 Power Yes, there is already a power function defined in However, this time around you need to write your own version of this method. It should take in two numbers as parameters: a double b, representing the base, and an integer e, representing the power you wish to raise it to (exponent.) The method should return the answer as a double. These variable names are not required just used as examples to help illustrate the requirements. Function 1: Write a function that takes in an angle x. Inside the function, compute the cosine of the angle using the first five terms of this series defined above. Print or return the value computed Hint: For loops will allow for a set number of calculations Function 2 Start by reusing the code from function 1. However, instead of calculating just the first five terms, this time you will continue to Function 1 Write a function that takes in an angle x. Inside the function, compute the cosine of the angle using the first five terms of this series defined above. Print or return the value computed. Hint: For loops will allow for a set number of calculations Function 2 Start by reusing the code from function 1. However, instead of calculating just the first five terms, this time you will continue to calculate terms while a given term remains greater than 0.0001 Make sure you print out the final result, and the number of terms used to calculate this result Hint: Use a while loop for this one Menu You should set up a menu that will allow the user to pick either of the two functions above (methods for calculating the cos of x) In addition to having options for both of the above described ways of calculating cosine of x, you should include another case/option that will display the cosine of x according to the C++ default Library's function. The code to use the default library function is simply cos(x Run: When running the program, please run them with the following values in the following order Option 1, x-0, Option 2, x = 0, Option 3, x-0 Option 1, x = l. Option 2, x = 1 . Option 3, X-| Option 1, x-2. Option 2, x-2. Option 3, x-2. Option 1, x 3. Option 2, x 3. Option 3, x -3 Option 1, x 4. Option 2, x 4. Option 3, x-4 Option 1, x 5, Option 2, x = 5, Option 3, x = 5 Option 1, x = 6, Option 2, X-6. Option 3, x-6 this Radian 0 Taylorl1 Taylor21 Math Function = 1 Radian 1 Taylorl 0.540302 Taylor2-0.540303 Math Function-0.540302 1 Radian 2 Taylor! =-0.416155 Taylor2--0.16147 Math Function-0.416147 Radian 3 Taylorl--0.991049 Taylor2--0.989994 Math Function =-0.989992 Radian 4 Taylorl0.685785 Taylor2 -0.653644 Math Function-0.653644 Radian 5 Taylorl--0.162747 Taylor2 0.283664 Math Function-0.283662 Radian 6 Taylorl--2.80571 Taylor2 0.960171 Math Function- 0.96017

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

Discuss the importance of linking pay to ethical behavior.

Answered: 1 week ago