The value of sin(x) can be approximated as: sin(x)=x-x^5/3!+x^5/5!+x^7/7!+... Cr
ID: 664533 • Letter: T
Question
The value of sin(x) can be approximated as: sin(x)=x-x^5/3!+x^5/5!+x^7/7!+... 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, E is met when: |xn+1-xn|= < = E Test your function by evaluating the my_sin(2) and comparing it to the built-in C++ sine. Note: the factorial function (!) is not included in the C++ library of functions. You must. write it. yourself.
Explanation / Answer
#include using namespace std; int main() { int i,j,n,fact,sign=-1; float x, p=1,sum=0; coutx; coutn; for(i=1;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.