• 03-11-2002
Unregistered
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.
• 03-11-2002
Unregistered
wow wow..
ok send your script so far.. or simplify your question, you dont need to send all the details yet.. what exactly do you want this function to do? (simplified, i dont want to have to think that much)
• 03-11-2002
JasonLikesJava
Maybe something like this would work for starters:

int total=1;
int term;
int i=1;
while (term>0.0000001)
{
term=input^i/factoral(i);
total+=
{

int factoral(int x)
{
int total=x;
for (int i=x;i>0;i++)
{
total*=(x-1);
}