Did you know you can use CCalc to derive pi?Â Of course CCalc already includes the variable “pi” which is accurate to 100+ decimal places, but what fun is there in that?Â We will use the infinite series discovered by 14th century mathematician and astronomer Madhava of Sangamagrama.Â The first series does not converge very quickly (takes almost 300 terms to get pi to two decimal places):

So we will use this variant, which converges much faster.

To use CCalc to test this out, first set up the initial conditions:

k=0; p=sqrt(12)

Then enter the line which will be calculated repeatedly:

k=k+1; p=p+sqrt(12)*((-3)^(-k))/(2*k+1)

Then hold down enter for a few seconds, and watch p converge towards Pi!

> k=0; p=sqrt(12)

p = 3.464101615137754587054893> k=k+1; p=p+sqrt(12)*((-3)^(-k))/(2*k+1)

p = 3.079201435678004077382127

p = 3.15618147156995417931668

p = 3.137852891595680345522739

p = 3.142604745663084672802649

p = 3.141308785462883492635401

p = 3.141674312698837671656933

p = 3.141568715941784242161824

p = 3.14159977381150583907215

p = 3.141590510938080099642754

p = 3.141593304503081513121461

p = 3.141592454287646300323594

p = 3.141592715020379765581606

p = 3.141592634547313881242713

p = 3.141592659521713638451335

p = 3.141592651733997585128217

p = 3.141592654172575339199092

p = 3.141592653406165187919674

p = 3.141592653647826046431202

p = 3.141592653571403381773711

p = 3.141592653595634958372427

p = 3.141592653587933449530975

p = 3.141592653590386522717512

p = 3.141592653589603627019681

p = 3.141592653589853940610144

p = 3.141592653589773774819734

p = 3.141592653589799488375148

p = 3.14159265358979122886947

p = 3.141592653589793885435624

p = 3.141592653589793029931269

p = 3.141592653589793305749613

p = 3.141592653589793216728878

p = 3.141592653589793245489423

p = 3.141592653589793236188749

p = 3.141592653589793239199112

p = 3.141592653589793238223924

p = 3.141592653589793238540081

p = 3.141592653589793238437506

p = 3.141592653589793238470809

p = 3.141592653589793238459989

p = 3.141592653589793238463507

p = 3.141592653589793238462362

p = 3.141592653589793238462735

p = 3.141592653589793238462614

p = 3.141592653589793238462653

p = 3.141592653589793238462640

p = 3.141592653589793238462644

p = 3.141592653589793238462643

## 1 Comment

## Hawker · May 18, 2010 at 7:11 pm

This was fun, thanks 🙂

I was unavare that the semicolon could allow you to do multiple calculation in a single line and also supress result.