Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By JosAH

Thread: Calculate PI

  1. #1
    Join Date
    Jun 2014
    Location
    Dhaka
    Posts
    5
    Rep Power
    0

    Default Calculate PI

    will u pls help me with this problem?
    Write a program called ComputePi to compute the value of pi using the following series expansion. you have to decide on the termination criterion used in the computation(such as number of terms used or the magnitude of an additional term). Is this series suitable for compute pi?
    PI=4*(1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11)+(1/13)-(1/15)+.......)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Calculate PI

    What have you tried?

    Notice that the sign changes from term to term and that the denominator increase by 2 in every term. Using that you should be able to write a loop to do the summing of terms.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default Re: Calculate PI

    Quote Originally Posted by Nasima Ferdous Tripti View Post
    will u pls help me with this problem?
    Write a program called ComputePi to compute the value of pi using the following series expansion. you have to decide on the termination criterion used in the computation(such as number of terms used or the magnitude of an additional term). Is this series suitable for compute pi?
    PI=4*(1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11)+(1/13)-(1/15)+.......)
    Yep, it's suitable, although it converges a bit slow though ... find the 'regularity' in that series: the numerator stays equal to one, while the denominator is odd and changes it sign for every next value ...

    kind regards,

    Jos

    edit: I should've read the entire thread before replying; Norm was first, by far ... ;-)
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Join Date
    Jun 2014
    Location
    Dhaka
    Posts
    5
    Rep Power
    0

    Default Re: Calculate PI

    I tried bt it was not the right way.. so I shared the problem..

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Calculate PI

    Do you have code that you need help with? Please post it and ask some questions about the problems you are having.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Calculate GPA
    By thessler1 in forum New To Java
    Replies: 22
    Last Post: 06-27-2012, 05:13 AM
  2. Need help to calculate avg
    By vavavoom1 in forum New To Java
    Replies: 2
    Last Post: 04-02-2011, 07:42 PM
  3. fastest way to calculate the sum of 1 to x
    By imorio in forum New To Java
    Replies: 5
    Last Post: 11-07-2010, 10:47 PM
  4. calculate fft
    By ram.west in forum Advanced Java
    Replies: 2
    Last Post: 08-27-2008, 03:05 AM
  5. Calculate what e1 and e2 should be
    By Legoland in forum New To Java
    Replies: 11
    Last Post: 07-02-2007, 06:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •