Loop with Taylor series


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
Please, rewrite formula. I see only empty squares and pluses.
@konstantin


void getTaylor()
{
double estimation;
cout << "enter the values for x and n:" << end;
cin >> x >> n;
cout << "Taylor series estimation is" <<
}

Topic archived. No new replies allowed.