summaryrefslogtreecommitdiffstats
path: root/net/ricketyspace
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-02-10 20:29:38 +0000
committerrsiddharth <s@ricketyspace.net>2018-02-10 20:29:38 +0000
commitf7e6dbe6ff8fcbb69e27b9a01bd55f90d65c2642 (patch)
tree60b500b471bef81443aecf0631b00cdccec69089 /net/ricketyspace
parentea6a6b914f2d4d79a5cc819e1e29d461e9a211f3 (diff)
net: Add (net ricketyspace sicp one thirtyseven).
* net/ricketyspace/sicp/one/thirtynine.scm: New file.
Diffstat (limited to 'net/ricketyspace')
-rw-r--r--net/ricketyspace/sicp/one/thirtynine.scm24
1 files changed, 24 insertions, 0 deletions
diff --git a/net/ricketyspace/sicp/one/thirtynine.scm b/net/ricketyspace/sicp/one/thirtynine.scm
new file mode 100644
index 0000000..b85b632
--- /dev/null
+++ b/net/ricketyspace/sicp/one/thirtynine.scm
@@ -0,0 +1,24 @@
+;;;; Under Creative Commons Attribution-ShareAlike 4.0
+;;;; International. See
+;;;; <https://creativecommons.org/licenses/by-sa/4.0/>.
+
+(define-module (net ricketyspace sicp one thirtynine)
+ #:use-module (net ricketyspace sicp one thirtyseven)
+ #:export (tan-cf))
+
+(define (tan-cf x k)
+ (define (n i) (if (= 1 i) x (* -1 (expt x 2.0))))
+ (define (d i) (1- (* 2.0 i)))
+ (cont-frac-rec n d k))
+
+;;; GNU Guile REPL
+;;;
+;;; scheme@(guile-user)> ,use (net ricketyspace sicp one thirtynine)
+;;; scheme@(guile-user)> (tan-cf 45 1000)
+;;; $39 = 1.6197751905438595
+;;; scheme@(guile-user)> (tan-cf 90 1000)
+;;; $40 = -1.9952004122082423
+;;; scheme@(guile-user)> (tan-cf 135 1000)
+;;; $41 = -0.08871575677005962
+;;; scheme@(guile-user)> (tan-cf 180 1000)
+;;; $42 = 1.3386902103511542