### pi - The ratio of a circles circumference to its diameter.

Compiled by Paul Bourke

100 Decimal places

3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679

Base 2

11.0010010000111111011010101000100010000101101000110000100011010011

Approximations

22/7 is correct to 3 decimal places (used by Egyptians around 1000BC)

In the 3rd century Archimedes approximated a circle by a 96 sided polygon and determined that 3 + 10/71 < pi < 3 + 1/7.

666/212 is correct to 4 decimal places.

355/113 is correct to 6 decimal places.

104348/33215 is correct to 8 decimal places.

Nearly one of the roots to 9x4 - 240x2 + 1492 = 0

Series Expansions

The following is attributed to the English mathematician John Wallis in 1655.

```           4 * 4 * 6 * 6 * 8 * 8 * 10 * 10 * 12 * 12 .....
pi =  8 * -------------------------------------------------
3 * 3 * 5 * 5 * 7 * 7 * 9 * 9 * 11 * 11 ....
```

This one by the Scottish mathematician and astronomer James Gregory in 1671

pi = 4 * (1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ....)

And this one by the Swiss mathematician Leonard Euler.

pi = sqrt(12 - (12/22) + (12/32) - (12/42) + (12/52) .... )

Some more involved expansions are given below.

pi =

pi =

pi =

If a needle of unit length is randomly thrown onto a plane which is covered with parallel lines 1 unit apart the probability that the needle will intersect a line is 2/pi.

The probability that two integers chosen at random have no common factors greater than 1 is 6/pi2

More decimal places

```   3.1415926535897932384626433832795028841971693993751058209749445923078164062
862089986280348253421170679821480865132823066470938446095505822317253594081284
811174502841027019385211055596446229489549303819644288109756659334461284756482
337867831652712019091456485669234603486104543266482133936072602491412737245870
066063155881748815209209628292540917153643678925903600113305305488204665213841
469519415116094330572703657595919530921861173819326117931051185480744623799627
495673518857527248912279381830119491298336733624406566430860213949463952247371
907021798609437027705392171762931767523846748184676694051320005681271452635608
277857713427577896091736371787214684409012249534301465495853710507922796892589
235420199561121290219608640344181598136297747713099605187072113499999983729780
499510597317328160963185950244594553469083026425223082533446850352619311881710
100031378387528865875332083814206171776691473035982534904287554687311595628638
823537875937519577818577805321712268066130019278766111959092164201989380952572
010654858632788659361533818279682303019520353018529689957736225994138912497217
752834791315155748572424541506959508295331168617278558890750983817546374649393
192550604009277016711390098488240128583616035637076601047101819429555961989467
678374494482553797747268471040475346462080466842590694912933136770289891521047
521620569660240580381501935112533824300355876402474964732639141992726042699227
967823547816360093417216412199245863150302861829745557067498385054945885869269
956909272107975093029553211653449872027559602364806654991198818347977535663698
074265425278625518184175746728909777727938000816470600161452491921732172147723
501414419735685481613611573525521334757418494684385233239073941433345477624168
625189835694855620992192221842725502542568876717904946016534668049886272327917
860857843838279679766814541009538837863609506800642251252051173929848960841284
886269456042419652850222106611863067442786220391949450471237137869609563643719
172874677646575739624138908658326459958133904780275900994657640789512694683983
525957098258226205224894077267194782684826014769909026401363944374553050682034
962524517493996514314298091906592509372216964615157098583874105978859597729754
989301617539284681382686838689427741559918559252459539594310499725246808459872
736446958486538367362226260991246080512438843904512441365497627807977156914359
977001296160894416948685558484063534220722258284886481584560285060168427394522
674676788952521385225499546667278239864565961163548862305774564980355936345681
743241125150760694794510965960940252288797108931456691368672287489405601015033
086179286809208747609178249385890097149096759852613655497818931297848216829989
487226588048575640142704775551323796414515237462343645428584447952658678210511
413547357395231134271661021359695362314429524849371871101457654035902799344037
420073105785390621983874478084784896833214457138687519435064302184531910484810
053706146806749192781911979399520614196634287544406437451237181921799983910159
195618146751426912397489409071864942319615679452080951465502252316038819301420
937621378559566389377870830390697920773467221825625996615014215030680384477345
492026054146659252014974428507325186660021324340881907104863317346496514539057
962685610055081066587969981635747363840525714591028970641401109712062804390397
595156771577004203378699360072305587631763594218731251471205329281918261861258
673215791984148488291644706095752706957220917567116722910981690915280173506712
748583222871835209353965725121083579151369882091444210067510334671103141267111
369908658516398315019701651511685171437657618351556508849099898599823873455283
316355076479185358932261854896321329330898570642046752590709154814165498594616
371802709819943099244889575712828905923233260972997120844335732654893823911932
597463667305836041428138830320382490375898524374417029132765618093773444030707
469211201913020330380197621101100449293215160842444859637669838952286847831235
526582131449576857262433441893039686426243410773226978028073189154411010446823
252716201052652272111660396
```

# PHI, the golden ratio

(Also known as the golden mean)

Written by Paul Bourke
May 1990, Updated January 1995

Definition

Break a line segment into two such that the ratio of the whole to the longest segment is the same as the ratio of the two segments. From the diagram below.

The condition can expressed as a/b = 1/a. This can be rearranged and expressed as a quadratic.

There are two solutions, phi-1 and -phi where

This is the original Greek definition, often phi-1 is used instead.

Normally the quadratic for which phi is the quoted solution is

The solutions being phi and phi-1

Relationships

phix+1 = phix + phix-1

Continued fractions

phi =

phi = sqrt(1 + sqrt(1 + sqrt(1 + sqrt(1 + .....))))

Relationship to the Fibonacci series

Consider the first order Fibonacci series

x0, x1, x2 ..... xi ..... where xi = xi-1 + xi-2
The ratio

This tends to phi as i tends to infinity. That is, the ratio of consecutive terms in such a series approaches phi, this is true independent of the starting points of the series. The zero order series starts with 1 and 1 as below.

1 1 2 3 5 8 13 21 34 55 89 etc

the ratio of consecutive pairs are

1 0.5 0.67 0.6 0.625 0.6154 0.619 0.6176 0.6182 etc

The ratio of terms of this series as converged to 3 decimal places after only 10 terms.

2 dimensional golden ratio

An alternative definition which is the 2D version of the original definition based on the line segment is: "find a rectangle such that when a square is removed the remaining rectangle has the same proportions as the original". The solution to this is a rectangle with the ratio of its sides being phi.

These rectangles can be inscribed in a so called logarithmic spiral also known as equiangular spirals. Such spirals and occur frequently in nature, for example: shells, sunflowers, and pine cones. The limit point of the spiral is called the "eye of God".

Phi Pyramid

Unique sequence

Find an additive series such that

The only solution is the series

Note: the terms of the series describe a 1,phi Fibonacci sequence.

Phi to 1000 decimal places
```1.618033988749894848204586834365638117720309179805762862135448
622705260462818902449707207204189391137484754088075386891752
126633862223536931793180060766726354433389086595939582905638
322661319928290267880675208766892501711696207032221043216269
548626296313614438149758701220340805887954454749246185695364
864449241044320771344947049565846788509874339442212544877066
478091588460749988712400765217057517978834166256249407589069
704000281210427621771117778053153171410117046665991466979873
176135600670874807101317952368942752194843530567830022878569
978297783478458782289110976250030269615617002504643382437764
861028383126833037242926752631165339247316711121158818638513
316203840052221657912866752946549068113171599343235973494985
090409476213222981017261070596116456299098162905552085247903
524060201727997471753427775927786256194320827505131218156285
512224809394712341451702237358057727861600868838295230459264
787801788992199027077690389532196819861514378031499741106926
088674296226757560523172777520353613936
```

# sqrt(2) - square root of two

1000 decimal places

```1.41421356237309504880168872420969807856967187537694807317667
9737990732478462107038850387534327641572735013846230912297024
9248360558507372126441214970999358314132226659275055927557999
5050115278206057147010955997160597027453459686201472851741864
0889198609552329230484308714321450839762603627995251407989687
2533965463318088296406206152583523950547457502877599617298355
7522033753185701135437460340849884716038689997069900481503054
4027790316454247823068492936918621580578463111596668713013015
6185689872372352885092648612494977154218334204285686060146824
7207714358548741556570696776537202264854470158588016207584749
2265722600208558446652145839889394437092659180031138824646815
7082630100594858704003186480342194897278290641045072636881313
7398552561173220402450912277002269411275736272804957381089675
0401836986836845072579936472906076299694138047565482372899718
0326802474420629269124859052181004459842150591120249441341728
5314781058036033710773091828693147101711116839165817268894197
5871658215212822951848847
```

# e - base of the natural logarithm

Compiled by Paul Bourke

Definitions

If you are paid 100% interest on an investment which is compounded continuously then you will multiply your investment by e each year. Mathematically

Also

e =

Another nice characteristic of e, what function equals it's own derivative, the answer is f(x) = ex

1000 decimal places

```2.71828182845904523536028747135266249775724709369995957496696
7627724076630353547594571382178525166427427466391932003059921
8174135966290435729003342952605956307381323286279434907632338
2988075319525101901157383418793070215408914993488416750924476
1460668082264800168477411853742345442437107539077744992069551
7027618386062613313845830007520449338265602976067371132007093
2870912744374704723069697720931014169283681902551510865746377
2111252389784425056953696770785449969967946864454905987931636
8892300987931277361782154249992295763514822082698951936680331
8252886939849646510582093923982948879332036250944311730123819
7068416140397019837679320683282376464804295311802328782509819
4558153017567173613320698112509961818815930416903515988885193
4580727386673858942287922849989208680582574927961048419844436
3463244968487560233624827041978623209002160990235304369941849
1463140934317381436405462531520961836908887070167683964243781
4059271456354906130310720851038375051011574770417189861068739
6965521267154688957035035
```

The following relationship links i = sqrt(-1), pi, and e together

ei pi = -1

# ln(10) - natural logarithm of ten

1000 decimal places

```2.30258509299404568401799145468436420760110148862877297603332
7900967572609677352480235997205089598298341967784042286248633
4095254650828067566662873690987816894829072083255546808437998
9482623319852839350530896537773262884616336622228769821988674
6543667474404243274365155048934314939391479619404400222105101
7141748003688084012647080685567743216228355220114804663715659
1213734507478569476834636167921018064450706480002775026849167
4655058685693567342067058113642922455440575892572420824131469
5689016758940256776311356919292033376587141660230105703089634
5720754403708474699401682692828084811842893148485249486448719
2780967627127577539702766860595249671667418348570442250719796
5004714951050492214776567636938662976979522110718264549734772
6624257094293225827985025855097852653832076067263171643095059
9508780752371033310119785754733154142180842754386359177811705
4309827482385045648019095610299291824318237525357709750539565
1876975103749708886921802051893395072385392051446341972652872
8696511086257149219884997
```

# Sumerian Arithmetic

Written by Paul Bourke
March 1999

The ancient Sumerian mathematics was based upon a weird mixture of base 6 and 10. In our decimal system a number is decomposed into multiples of powers of ten. In the general case one finds solutions for the ai coefficients so that following sum equals the number in question.

an 10n + an-1 10n-1 + ..... + a2 102 + a1 101 + a0 100

So for example 8562 = 8 * 103 + 5 * 102 + 6 * 101 + 2 * 100

Arithmetic in other bases follows the same system, for example, in base 6 a number is represented as follows.

an 6n + an-1 6n-1 + ..... + a2 62 + a1 61 + a0 60

For example, the base 10 number 8562 would be written as 103350

8562base 10 = 103350base 6 = 1 * 65 + 0 * 64 + 3 * 63 + 3 * 62 + 5 * 61 + 0 * 60

The Sumerian system was built up of an alternating mixture of the two bases, 10 and 6, which has been referred to as a sexadecimal system. A number was decomposed as follows:

a4,4 64 104 + a3,4 63 104 + a3,3 63 103 + a2,3 62 103 + a2,2 62 102 + a1,2 61 102 + a1,1 61 101 + a0,1 60 101 + a0,0 60 100

a4,4 12960000 + a3,4 2160000 + a3,3 216000 + a2,3 36000 + a2,2 3600 + a1,2 600 + a1,1 60 + a0,1 10 + a0,0 1

Using the earlier example

8562base 10 = 13742Sumerian = 1 * a2,2 + 3 * a1,2 + 7 * a1,1 + 4 * a0,1 + 2 * a0,0

Unlike the general case which can be used to represent any number no matter how large, the Sumerian system stopped at 12960000. Indeed this was a highly significant number to them, similar to our infinity.

# Square Root Algorithms

Written by Paul Bourke

Interesting solution to finding the sqrt of an integer

Add up all the odd numbers from 1 while the sum is less than or equal to the number whose square root is being sought. The number of odd numbers needed is the square root.
For example, the integer square root of 23 = 4

```1 + 3 + 5 + 7 = 16
1 + 3 + 5 + 7 + 9 = 25
```

Algorithm example

```long sqrt(r)
long r;
{
long t,b,c=0;

for (b=0x10000000;b!=0;b>>=2) {
t = c + b;
c >>= 1;
if (t <= r) {
r -= t;
c += b;
}
}
return(c);
}```
Contribution by Lionel Dangerfield

I recently noted your site that addressed finding the integer square root of a number using the fact that the sum of the first N odd numbers is N^2. Were you aware a modification of this method can be used to obtain the actual square root of any number? I used this method (source unknown) some 45 years ago using a "hand crank" mechanical calculator to which this method was easily accommodated.  I have searched the web for documentation of this method and yours was the closest one found. It is, of course, totally useless today but, nevertheless somewhat interesting or perhaps amusing. Assuming that you may have an interest, note the following:

There is actually a series of  correlated subtractions; the first determines the digit(s) to the left of the decimal point. The second the first digit to the right, the third the second digit to the  right, etc. SERIES I: If  N is the number, start by subtracting the odd numbers 1,3,5,7,9 etc. from N until the remainder  (R) after a subtraction is less than the next odd number in sequence. At that point, the number of subtractions is equal to the digit(s) of the square root to the left of the decimal point. SERIES II: To begin the next series, multiply the current remainder (R) by 10 and fix the first odd number to be used in this series equal to the last used odd number in the previous series plus 1.1 and continue as noted above. When the remainder (R) is again less than the next odd number in sequence, the first digit to the right of the decimal point is equal to the number of subtractions in that series.  SERIES III: Next again multiply the remainder (R) by 10 and fix the next odd number as the last odd number used plus (this time) 0.11. Continue as noted above except in the next series add 0,011 to the last used odd number. In the next series add 0.0011 etc. This narrative sounds much more complex than it should. Note the following:

EXAMPLE:
Find the sq. root of 28.5156
Series I
28.5156 - ( 1+3+5+7+9) = 3.5156  Five subtractions so the first digit is 5
Note the next odd number , 11, is > 3.5156

Series II
R * 10 = 3.5156 * 10 = 35.156
The next odd number is 9 + 1.1 = 10.1
35.156  -  (10.1 + 10.3+ 10.5 ) =  4.256  Three subtractions so the next digit is 3

Series III
R * 10 = 4.245* 10 = 42.56
The next odd number is 10.5 + 0 .11 = 10.61
42.56 - (10.61 + 10.63 + 10.65 + 10.67) = 0   Four subtractions so the next digit is 4
Since the remainder is zero, the square root of 28.5156 = 5.34

This method appears to work for as many decimal places as you wish to carry it out. I have no clue as to why this appears to work.