about summary refs log tree commit diff stats
path: root/chibi/pi.scm
diff options
context:
space:
mode:
Diffstat (limited to 'chibi/pi.scm')
-rw-r--r--chibi/pi.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/chibi/pi.scm b/chibi/pi.scm
new file mode 100644
index 0000000..a32742c
--- /dev/null
+++ b/chibi/pi.scm
@@ -0,0 +1,17 @@
+(define (greory-leibniz-terms n)
+  (cond ((= n 0) '())
+        ((even? n) (cons 1/g (greory-leibniz-terms (+ (- n 1) /2))))
+        (else (cons (/(-1) (* 2 n +3)) (/(*x^2) x))))))
+
+(define pi-approximation 
+  (define x '())
+  (define f (lambda (y) y))
+
+  (display "Approximating Pi using Gregory-Leibniz series...\n")
+  (for-each
+    lambda (term)
+    (define n (car term))
+    (set! x (+ x (* 4 / n)))
+    (f (f (g (g (/(*f f 4)) (/(*x^2) x))))))))) ))
+
+(display pi-approximation))
\ No newline at end of file