Thread: Taylor series regarding E^x

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    25

    Taylor series regarding E^x

    okay my main problem right now is trying to convert this:
    exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + x^4/4! + ....

    into programming language. the part that seems to confuse me is the factorial part.
    the problem is that i am really confused and dnt know how to start

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Factorial is not built into C++. You'll have to write it yourself.

  3. #3
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    Did you search "How to calculate factorial in c++"? Were you simply overwhelmed by the sheer number of pages that tell you exactly how to do it?
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    25
    yea i understand that i am not sure how to tho. the top part i can but not sure about the n! part

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    25
    yea im searching now but sometimes i do not really understand some of the things they put up.

  6. #6
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    Well if you don't understand something, feel free to ask a question.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  7. #7
    Registered User
    Join Date
    Apr 2010
    Posts
    43
    The factorial function goes like this:
    Code:
    int f(int x)
    {
        if(x == 1)
        return 1;
        else
        return x * f(x - 1);
    }

  8. #8
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Actually you shouldn't post the code here, it's his job to figure out.

  9. #9
    ...and never returned. StainedBlue's Avatar
    Join Date
    Aug 2009
    Posts
    168
    Yea dont let em circumvent the jfgi and stfw
    goto( comeFrom() );

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. d/dx e^x
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 11-04-2003, 06:09 PM