Help on C++ Programming.

Discussion in 'C' started by meyup, Mar 25, 2010.

1. meyupNew Member

Joined:
Feb 15, 2010
Messages:
102
0
Trophy Points:
0
Create a program that will approximate the error function erf(x) and erfc(x). Use the following Taylor series expansion:

2. pankaj.seaNew Member

Joined:
Apr 6, 2009
Messages:
461
13
Trophy Points:
0
Occupation:
Web Developer
Location:
Kolkata
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!

3. techinspirationNew Member

Joined:
Feb 14, 2010
Messages:
54
0
Trophy Points:
0
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?

Joined:
Feb 15, 2010
Messages:
102