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/f2...r/untitled.jpg
Code:
Restrictions:
1. Use at most 6 variables in the main function.
2. Create a separate function for power using recursion.
3. Create a separate function for factorial using iteration.
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!