help on c programming involving taylor series


Read With Formatting | Free Open Source Tutorials Account

C and C++ Programming
Thread: help on c programming involving taylor series


abe31
Create a program that will approximate the error function erf(x) and erfc(x). Use the following Taylor series expansion:


http://i49.photobucket.com/albums/f287/j_evenstar/untitled.jpg



Restrictions:
1. Use at most 6 variables in the main function.
2. Create a separate function for factorial using iteration.
3. Create a separate function for power using recursion.
4. Calculate the approximation until the 100th term of the Taylor series and print out approximation up to 4 decimal places.

*I have accomplished numbers 2 and 3.
2.)
int power(int b, int e){
if(b==0 && e==0){
printf("Invalid.\n");
main();
}
if(e==1){
return b;
}
if(e==0){
return 1;
}
else{
return b*power(b,e-1);
}
}

3.)
double factorial(double value){
int ctr;
double fact;
if(fact<0){
printf("Invalid.\n");
main();
}
else{
fact=1;
for(ctr=1;ctr<=value;ctr++){
fact*=ctr;
}
return fact;
}
}


***Any help will be appreciated. Thanks!

toshiniru
Can someone post a C++ program code on how to implement an approximation of taylor series expansion of sin(pi/2) and cos(pi/2) with epsilon sub s conforming to 4 significant figures? :confused:

This is urgent. I humbly beg for your kind souls. Please help me on this..Please..much thanks in advance!

-Toshiniru