I am a beginner to programming. I need help please. I am supposed to write my own function named myExp to compute exponential functions without using the library function Exp. The prototype should be
double myExp(double);
I am not supposed to use the pow function either. Instead I am supposed to use the series expansion:
e^x = 1 + x/1! + x^2/2! + x^3/3! + x^n/n!
From this I am supposed to notice that the nth term in the series may be obtained from the (n-1)th term by multiplying by x/n. Also, I have to write a loop that generates one term on each pass and adds it to the sum of all previous terms, and exit the loop when the term is less than 0.0000001. In addition to myExp funtion, the program should contain a main function to prompt the user enter real number x and then compares the value that the function call myExp(x) returns with the value returned by the library function call exp(x).
Your help is appreciated, thank you so much.



LinkBack URL
About LinkBacks



