1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help on C++ Programming.

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

  1. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    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.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    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. techinspiration

    techinspiration New Member

    Joined:
    Feb 14, 2010
    Messages:
    54
    Likes Received:
    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?

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

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    Thanks Pankaj!
    :)
     

Share This Page