Skip to main content
guest
Join | Help | Sign In
Liberty BASIC Programmer's Encyc Home
guest| Join | Help | Sign In
Liberty BASIC Programmer's Encyc
  • Wiki Home
  • Recent Changes
  • Pages and Files
  • Members

Home

General Tutorials
Advanced Tutorials
GUI Programming
Graphics and Games
Strings and Text
Numbers and Math
Using Files
Windows API
Communications
Programmer's Tools

Articles by Date
FAQs
Rosetta Code
General Articles
Newsletters Contents

Table of Contents
Demos

Submit Articles
TOS and License

Calculating the Value of PI

Edit 6 …
  • 1 Tags
    • math
  • Notify
  • RSS
  • Backlinks
  • Source
  • Print
  • Export (PDF)
Older Version Newer Version

frankdwest frankdwest May 28, 2007

Using Liberty Basic to Calculate Pi with the Bailey-Borwein-Plouffe Algorythm


An interesting excersize (and useful in technical calculations) is the determination of pi to a high degree of precision. One of the simplest of the algorythms for the calculation of pi is the Bailey-Borwein-Plouffe Algorythm.

This code segment calculates the value of pi with accurate precision to 100 places. The more iterations performed, the deeper into the irrational number the precision may extend. With 100 places of precision the pi value may be considered accurate for any form of practical engineering or technical calculation.
 'Program to calculate PI using the Bailey-Borwein-Plouffe Algorithm 
Print "How many iterations to calculate (0-100)"input iterationspi = 0
if iterations > 100 then goto [end]for n = 0 to iterations
pi = pi + (4/((8*n) + 1) - 2/((8*n)+4) - 1/((8*n)+5) - 1/((8*n)+6))*(1/16)^n
next n
print using ("#.#############################################################", pi)
[end]input done


Frank West
frankdwest@yahoo.com
Help · About · Pricing · Privacy · Terms · Support · Upgrade
Contributions to https://lbpe.wikispaces.com/ are licensed under a Custom License.
Portions not contributed by visitors are Copyright 2018 Tangient LLC
TES: The largest network of teachers in the world
Turn off "Getting Started"
  1. Home
  2. ...
Loading...