about summary refs log tree commit diff stats
path: root/chibi
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2025-01-06 17:16:13 -0500
committerelioat <elioat@tilde.institute>2025-01-06 17:16:13 -0500
commitb9440ce32de013237d61d2cccab229537ba19caa (patch)
treec8bfe2c5c224a12c99b051437a8dcba806a59567 /chibi
parent2cf744b31688582aa093c06942b8f0dbb6c32ed5 (diff)
downloadtour-b9440ce32de013237d61d2cccab229537ba19caa.tar.gz
*
Diffstat (limited to 'chibi')
-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