Open Source Development Tutorials | Newsletter Signup | About Us
Search  

Go Back   Open Source Tutorials Forum > Programming Languages > C and C++ Programming
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-04-2007, 09:29 PM
abe31 abe31 is offline
Junior Member
 
Join Date: May 2007
Posts: 1 abe31 is on a distinguished road
Question help on c programming involving taylor series

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






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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 07:08 AM.


Powered by: vBulletin Version 3.0.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright 2004 - 2006 GrindingGears.com. All Rights Reserved.