Question
The value of sin(x) can be approximated as: Sin(x) = x - x^3/3! + x^5/5! - x^7/7! ... The expression becomes more accurate when more
The value of sin(x) can be approximated as:
Sin(x) = x - x^3/3! + x^5/5! - x^7/7! ...
The expression becomes more accurate when more terms are added. At some point, however, the soulution is "close enough for engineering purposes."
Create a C++ program called my_sin, using a midpoint break loop to approximate the value of sin(x). Determine convergence by comparing successive values of the summation as you add additional terms. These successive sums should be within an absolute value of 0.001 of each other.
The convergence criterion, epsilon ( * symbol looks like a backwards 3) is met when:
|sin(x)n - sin(x)n - 1| <= epsilon
where "n" is the number of terms:
Test your function by evaluating the my_sin(2 radians) and comparing it to the built-in C++ sine.
Have the program output:
1. The value of sin(2) using your code
2. The value of sin(2) using the C++ sine function
3. The number of terms needed in your summation to reach the conclusion
Note: The factorial function (!) is not included in the C++ library of functions. You must write it yourself in a user-defined function, which may be a value-returning function or a void function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started