Question: C++ program on visual studio. 2. Using Math Functions: Write a program to demonstrate that the derivative of the sine function is the cosine function.

C++ program on visual studio.

C++ program on visual studio. 2. Using Math Functions: Write a program

to demonstrate that the derivative of the sine function is the cosine

2. Using Math Functions: Write a program to demonstrate that the derivative of the sine function is the cosine function. The derivative of a function gives you the slope of the function, and Cifyou haven't had calculus yet, the slope of the sine(x) is equal to the cosine(x). So to do this, we'll generate 100 values of sin(x) and cos(x) for x between 0 & 2 PI, then calculate the slope of the sine values and see how close they are to the cosine values. You'll need several arrays of doubles, length 100 for this. Use C++'s sin(), cos( 0, abs(), min() and max() for this exercise. The sample program sample trig.cpp will help with this part of the assignment. Assignment 2 1) Generate 100 x-values between 0 & 2 PI. Use the following code: (Put #define USE MATH DEFINES at the top of your program, before you include any header files double x[100] double delta 2.0*M PI/ 100.0 for (int i 0 i 100; it x [i] i delta 2) Calculate sin(x and cos(x), and store them in 2 arrays, sines [100] and cosines 100 3) Estimate the cos(x by calculating the slope of the sin(x). For each value of x, use the slope from the previous point to the next point: est cos [i] (sines [it1 sines [i-11) (2 *delta) note: for i 0, use the last sines value as the previous point, and for i 99, use the first sines value as the next point. 4) Calculate the difference between your cosine estimates and your calculated cosines

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!