Results 1 to 6 of 6

Math Help - Techniques for perserving long decimals in programs?

  1. #1
    Member mfetch22's Avatar
    Joined
    Feb 2010
    From
    Columbus, Ohio, USA
    Posts
    168

    Techniques for perserving long decimals in programs?

    I'm trying to write a program for a project which approximates the values of e and \pi in the visual basic langue. Lets just look at \pi, I'm approximating it with the two following integrals:

    \pi = 4\int_0^1\sqrt{1-x^2} dx which is based off of the area of a quarter of a circle with radius one and center (0, 0). And I used:

    \pi = 2\int_0^1\sqrt{1 + \frac{x^2}{1-x^2} } dx which is based of the integral distance formula and the relationship \pi = \frac{Circumferance}{Diameter}

    Which integral is best to use in approximating pi in a computer program? And also, visual basic rounds off calculations (after a considerable decimal place), but I would like to be able to display many correct decimal places of \pi and e. When I plug in large numbers of rectangles my computer freezes for a few seconds and on larger inputs it simply states "overload". Is there a way to break up the rectangles into parts and express the decimal as a further extended expansion by some seperate technique? So I can approximate to an even greater accuracy without my computer freezing and without visual basic rounding it off?

    Thanks in advance
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    Off the top of my head, I'd say your first formula is better. Addition and multiplication preserves or increases sig figs, but division and subtraction decreases sig figs. Do you have to approximate \pi with those formulas, or can you choose whichever one you want? For example, there are some arctan approximations that are really nice, if I remember correctly.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    I haven't programmed in VB, but it looks like if you are using VB .NET then you can import Extreme.Mathematics and then use the BigFloat class for arbitrary precision floating-points. If you can't import this, then maybe you can find a package online to do the same thing.

    Also I don't have experience with approximating pi, but I believe Taylor expansion is better than Riemann sums. You could try Wikipedia or MathWorld or just internet searches for other ideas on how to approximate.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member mfetch22's Avatar
    Joined
    Feb 2010
    From
    Columbus, Ohio, USA
    Posts
    168
    Quote Originally Posted by Ackbeet View Post
    Off the top of my head, I'd say your first formula is better. Addition and multiplication preserves or increases sig figs, but division and subtraction decreases sig figs. Do you have to approximate \pi with those formulas, or can you choose whichever one you want? For example, there are some arctan approximations that are really nice, if I remember correctly.
    I do not have to use these formulas, these are just the only formulas I could come up with that would return an approximation of pi (short of constructing a 96 sided-regular polygon). Could you give me this arctan formula and just give a short description of how pi arises from it (unless pi is a directly equated, as in pi = arctan formula)

    Thanks
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    Quote Originally Posted by mfetch22 View Post
    I do not have to use these formulas, these are just the only formulas I could come up with that would return an approximation of pi (short of constructing a 96 sided-regular polygon). Could you give me this arctan formula and just give a short description of how pi arises from it (unless pi is a directly equated, as in pi = arctan formula)

    Thanks
    See here. Also here. The internet is your friend..
    Follow Math Help Forum on Facebook and Google+

  6. #6
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    One of the ones I was thinking of is Equations 16 and 17 on this page.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Long Division with Remainder or Decimals
    Posted in the Math Software Forum
    Replies: 11
    Last Post: March 9th 2011, 08:05 PM
  2. TI-89 Programs and resources
    Posted in the Calculators Forum
    Replies: 1
    Last Post: March 5th 2011, 03:59 PM
  3. Replies: 2
    Last Post: January 20th 2010, 02:43 PM
  4. how many different programs can a band have?
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: July 12th 2009, 08:50 PM
  5. Ti Programs
    Posted in the Calculators Forum
    Replies: 12
    Last Post: November 17th 2008, 09:54 PM

Search Tags


/mathhelpforum @mathhelpforum