I'm working on this part of my homework and I am having trouble writing this loop.
Write a function that computes the Taylor series expansion of ex using the following formula, where x is the exponent, and n is the number of discrete trials to run:
ππ₯=1+π₯+π₯2+π₯3+π₯4+β―+π₯π =βπ π₯π 2! 3! 4! π! π=0 π!
NOTE: This formula will NOT work if you calculate the numerator and denominator separately and then add the division result. You must use your knowledge of algebra to make sure youβre not calculating the entire exponent and factorial, but rather their factors per loop iteration.
Input prompt
Enter the values for x and n:
Output Prompt
Taylor series estimation is XXXX.XXXX
This is what I have so far for the function:
void getTaylor()
{
double estimation
cout << "Enter the values for x and n:" << endl;
cin >> x >> n;
cout << "Taylor series estimation is" <<
}
I now need to create the loop so that I can enter in for my function