From 0c3b464d3c73fcd1a6fde3f2f5882eddd5c79685 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 6 Aug 2024 01:53:19 +0200 Subject: Complex updates --- std/Math/Real.bruijn | 63 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-) (limited to 'std/Math/Real.bruijn') diff --git a/std/Math/Real.bruijn b/std/Math/Real.bruijn index 9a4b1bd..d334117 100644 --- a/std/Math/Real.bruijn +++ b/std/Math/Real.bruijn @@ -7,7 +7,7 @@ :import std/Math/Rational Q :import std/Math N -# a Real is just a Unary → Rational! +# a Real is just a Number → Rational! # converts a balanced ternary number to a real number number→real [[Q.number→rational 1]] ⧗ Number → Real @@ -18,7 +18,27 @@ number→real [[Q.number→rational 1]] ⧗ Number → Real approx-eq? [[[Q.eq? (1 2) (0 2)]]] ⧗ Number → Real → Real → Boolean # TODO: bigger value?? -…≈?… approx-eq? (+100u) +…≈?… approx-eq? (+100) + +# returns true if a real number is greater than another +gt? [[[Q.gt? (1 2) (0 2)]]] ⧗ Number → Real → Real → Boolean + +…>?… gt? + +# returns true if a real number is less than another +lt? [[[Q.lt? (1 2) (0 2)]]] ⧗ Number → Real → Real → Boolean + +…?‣ positive? + +# returns true if a real number is negative +negative? [\(lt? 0) (+0.0r)] ⧗ Number → Real → Boolean + +?0 (+1.0q) (-1.0q)) (π/2 1) + conj-atan atan* [Q.div (+1.0q) 1] 1 + fallback Q.lt? Q.|0 (+1.0) (atan* [1] 1) normal + +# 2-argument arctan +atan2 [[[[[go]] (2 0) (1 0)]]] ⧗ Real → Real → Real + go Q.add a (Q.mul b (Q.add c d)) + z (+0.0q) + a Q.=?0 z (atan [Q.div 2 1] 2) + b Q.sub (+1.0q) (Q.