Thread: Approximating PI using the Taylor Series - Help!

  1. #31
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I don't care - would just do 4 * arctan(1.0) anyway.
    I'd just use a constant.

    Soma

  2. #32
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Quote Originally Posted by phantomotap View Post
    I'd just use a constant.
    Soma
    Solution found

  3. #33
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by phantomotap View Post
    I'd just use a constant.

    Soma
    I like M_PI from math.h.
    But, so far I have never needed it and had the compiler I was using supply it at the same time.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #34
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    I might do the loop more like this:

    Code:
    double numerator = -1.0
    double taylor = 1.0;
    for (int i = 3; i < terms; i+=2, numerator *= -1)
    {
        taylor += numerator/i;
    }
    but to each his own.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Taylor series regarding E^x
    By rafacnsoccer in forum C++ Programming
    Replies: 8
    Last Post: 05-05-2010, 11:08 AM
  2. taylor series using only stdio.h
    By b0ss139 in forum C Programming
    Replies: 4
    Last Post: 07-25-2009, 10:32 PM
  3. help on c programming involving taylor series
    By harlow23 in forum C Programming
    Replies: 4
    Last Post: 05-04-2007, 10:03 PM
  4. taylor series using only stdio.h
    By faruque in forum C Programming
    Replies: 1
    Last Post: 02-13-2003, 12:50 PM
  5. taylor series expansion
    By noor_mirza in forum C++ Programming
    Replies: 1
    Last Post: 10-23-2002, 10:02 PM

Tags for this Thread