内接・外接する正多角形の辺の合計からの円周率計算を Squeak Smalltalk で

▼正“3の倍数”角形の場合

| m a b c |
m := 9.
c := 3.
b := (Float pi / c) tan.
a := (Float pi / c) sin.
World findATranscript: nil.
0 to: m do: [:n |
   | d |
   d := c * (1 << n).
   Transcript cr; show: d -> ({a. b} * d).
   b := a * b / (a + b).
   a := (a * b / 2) sqrt]
3->#(2.598076211353316 5.19615242270663)
6->#(3.0 3.464101615137753)
12->#(3.105828541230248 3.215390309173472)
24->#(3.132628613281237 3.1596599420975)
48->#(3.139350203046866 3.146086215131434)
96->#(3.14103195089051 3.142714599645368)
192->#(3.14145247228546 3.141873049979823)
384->#(3.141557607911857 3.141662747056848)
768->#(3.141583892148318 3.14161017660469)
1536->#(3.14159046322805 3.141597034321526)

▼正“4の倍数”角形の場合

| m a b c |
m := 9.
c := 4.
b := (Float pi / c) tan.
a := (Float pi / c) sin.
World findATranscript: nil.
0 to: m do: [:n |
   | d |
   d := c * (1 << n).
   Transcript cr; show: d -> ({a. b} * d).
   b := a * b / (a + b).
   a := (a * b / 2) sqrt]
4->#(2.82842712474619 4.0)
8->#(3.061467458920718 3.31370849898476)
16->#(3.121445152258052 3.182597878074528)
32->#(3.13654849054594 3.151724907429256)
64->#(3.140331156954753 3.144118385245904)
128->#(3.141277250932773 3.142223629942457)
256->#(3.1415138011443 3.141750369168967)
512->#(3.141572940367092 3.141632080703182)
1024->#(3.14158772527716 3.14160251025681)
2048->#(3.1415914215112 3.14159511774959)


http://squab.no-ip.com/collab/uploads/2012051201.png
a、b は、それぞれ円に内接、外接する正多角形の一辺の長さ(の半分)。辺の数が倍になったときの an+1、bn+1 を、ひとつ前の an、bn で表わすには…

http://squab.no-ip.com/collab/uploads/2012051203.png
△ACD ≡ △RFD, △OAP ∽ △OBR, △OCP ∽ △OFR, an : bn = an - bn+1 : bn+1  ∴ bn+1 = an bn / (an + bn)
△OEQ ≡ △ORD, △APR ∽ △ADC, an : 2an+1 = an+1 : bn+1  ∴ an+1 = √(an bn+1 / 2)