]> gitweb.factorcode.org Git - factor.git/commitdiff
math.functions: rename exp to e^ to be consistent with 2^ and 10^. update things.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 2 May 2012 16:59:09 +0000 (09:59 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 2 May 2012 17:22:23 +0000 (10:22 -0700)
basis/inverse/inverse.factor
basis/math/complex/complex-tests.factor
basis/math/functions/functions-docs.factor
basis/math/functions/functions-tests.factor
basis/math/functions/functions.factor
basis/math/libm/libm-docs.factor
basis/random/random.factor
extra/math/analysis/analysis.factor
extra/math/derivatives/derivatives.factor
extra/math/extras/extras.factor

index 1f72abffcf9c28a70a8000aabb8195b2266d8514..3e1f88abe2a7937e6df71d0c5f276879587eb7c7 100644 (file)
@@ -156,7 +156,7 @@ MACRO: undo ( quot -- ) [undo] ;
 \ undo 1 [ ] define-pop-inverse
 \ map 1 [ [undo] '[ dup sequence? assure _ map ] ] define-pop-inverse
 
-\ exp \ log define-dual
+\ e^ \ log define-dual
 \ sq \ sqrt define-dual
 
 ERROR: missing-literal ;
index 5c41d6219ef95a5a7646f3f64ee8c455a5ca46eb..d7fe54b201eb9caecd812d2de0f76384a11f7ae1 100644 (file)
@@ -70,8 +70,8 @@ IN: math.complex.tests
 [ ] [ C{ 1 4 } coth drop ] unit-test
 [ ] [ C{ 1 4 } cot drop ] unit-test
 
-[ t ] [ 0.0 pi rect> exp C{ -1 0 } 1.0e-7 ~ ] unit-test
-[ t ] [ 0 pi rect> exp C{ -1 0 } 1.0e-7 ~ ] unit-test
+[ t ] [ 0.0 pi rect> e^ C{ -1 0 } 1.0e-7 ~ ] unit-test
+[ t ] [ 0 pi rect> e^ C{ -1 0 } 1.0e-7 ~ ] unit-test
 
 10 number-base [
     [ "C{ 1/2 2/3 }" ] [ C{ 1/2 2/3 } unparse ] unit-test
index 765f99c9b9ac28c4f9fd8af4e8446f3639aea74e..43188d94c3d2668ce11492441f2b9fdf1f9281e3 100644 (file)
@@ -49,7 +49,7 @@ ARTICLE: "power-functions" "Powers and logarithms"
 "Squares:"
 { $subsections sq sqrt }
 "Exponential and natural logarithm:"
-{ $subsections exp cis log }
+{ $subsections e^ cis log }
 "Other logarithms:"
 { $subsections log1+ log10 }
 "Raising a number to a power:"
@@ -108,13 +108,13 @@ HELP: align
 { $description "Outputs the least multiple of " { $snippet "w" } " greater than " { $snippet "m" } "." }
 { $notes "This word will give an incorrect result if " { $snippet "w" } " is not a power of 2." } ;
 
-HELP: exp
+HELP: e^
 { $values { "x" number } { "y" number } }
 { $description "Exponential function, " { $snippet "y=e^x" } "." } ;
 
 HELP: frexp
 { $values { "x" number } { "y" float } { "exp" integer } }
-{ $description "Break the number " { $snippet "x" } " into a normalized fraction " { $snippet "y" } " and an integral power of 2 " { $snippet "exp" } "." $nl "The function returns a number " { $snippet "y" } " in the interval [1/2, 1) or 0, and a number " { $snippet "exp" } " such that " { $snippet "x = y*(2**exp)" } "." } ;
+{ $description "Break the number " { $snippet "x" } " into a normalized fraction " { $snippet "y" } " and an integral power of 2 " { $snippet "e^" } "." $nl "The function returns a number " { $snippet "y" } " in the interval [1/2, 1) or 0, and a number " { $snippet "exp" } " such that " { $snippet "x = y*(2**exp)" } "." } ;
 
 HELP: log
 { $values { "x" number } { "y" number } }
@@ -242,9 +242,9 @@ HELP: >polar
 
 HELP: cis
 { $values { "arg" "a real number" } { "z" "a complex number on the unit circle" } }
-{ $description "Computes a point on the unit circle using Euler's formula for " { $snippet "exp(arg*i)" } "." } ;
+{ $description "Computes a point on the unit circle using Euler's formula for " { $snippet "e^(arg*i)" } "." } ;
 
-{ cis exp } related-words
+{ cis e^ } related-words
 
 HELP: polar>
 { $values { "abs" "a non-negative real number" } { "arg" real } { "z" number } }
@@ -275,10 +275,6 @@ HELP: 10^
 { $values { "x" number } { "y" number } }
 { $description "Raises 10 to the power of " { $snippet "x" } ". If " { $snippet "x" } " is an integer the answer is computed exactly, otherwise a floating point approximation is used." } ;
 
-HELP: e^
-{ $values { "x" number } { "y" number } }
-{ $description "Raises " { $link e } " to the power of " { $snippet "x" } "." } ;
-
 HELP: gcd
 { $values { "x" integer } { "y" integer } { "a" integer } { "d" integer } }
 { $description "Computes the positive greatest common divisor " { $snippet "d" } " of " { $snippet "x" } " and " { $snippet "y" } ", and another value " { $snippet "a" } " satisfying:" { $code "a*y = d mod x" } }
index 19565b5d842935d8b81e505f49bda20f165b981b..2a235adfaa4631cc56a3ebcb9e9e6c7fae1c5b13 100644 (file)
@@ -72,11 +72,11 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11
 [ 4.0 ] [ 10000.0 log10 ] unit-test
 [ $ log10-factorial-1000 t ] [ 1000 factorial [ log10 ] [ bignum? ] bi ] unit-test
 
-[ t ] [ 1 exp e 1.e-10 ~ ] unit-test
-[ f ] [ 1 exp 0/0. 1.e-10 ~ ] unit-test
-[ f ] [ 0/0. 1 exp 1.e-10 ~ ] unit-test
-[ t ] [ 1.0 exp e 1.e-10 ~ ] unit-test
-[ t ] [ -1 exp e * 1.0 1.e-10 ~ ] unit-test
+[ t ] [ 1 e^ e 1.e-10 ~ ] unit-test
+[ f ] [ 1 e^ 0/0. 1.e-10 ~ ] unit-test
+[ f ] [ 0/0. 1 e^ 1.e-10 ~ ] unit-test
+[ t ] [ 1.0 e^ e 1.e-10 ~ ] unit-test
+[ t ] [ -1 e^ e * 1.0 1.e-10 ~ ] unit-test
 [ f ] [ 1/0. 1/0. 1.e-10 ~ ] unit-test
 [ f ] [ 1/0. -1/0. 1.e-10 ~ ] unit-test
 [ f ] [ 1/0. 0/0. 1.e-10 ~ ] unit-test
@@ -241,6 +241,4 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11
 
 { t } [ 3 15 roots [ 15 ^ 3 .01 ~ ] all? ] unit-test
 
-{ t } [ 1 e^ e .0000000001 ~ ] unit-test
-{ 1 } [ 0 e^ ] unit-test
-{ 1/2 } [ 0 sigmoid ] unit-test
+{ .5 } [ 0 sigmoid ] unit-test
index 993e9ad1a56ece34cbec1e429ae432015b3e2f65..4bbdb0ec4322a6a03935934ef3b452c90ebb6362 100644 (file)
@@ -57,20 +57,20 @@ PRIVATE>
 
 : polar> ( abs arg -- z ) cis * ; inline
 
-GENERIC: exp ( x -- y )
+GENERIC: e^ ( x -- y )
 
-M: float exp fexp ; inline
+M: float e^ fexp ; inline
 
-M: real exp >float exp ; inline
+M: real e^ >float e^ ; inline
 
-M: complex exp >rect [ exp ] dip polar> ; inline
+M: complex e^ >rect [ e^ ] dip polar> ; inline
 
 <PRIVATE
 
 : ^mag ( w abs arg -- magnitude )
     [ >float-rect swap ]
     [ >float swap >float fpow ]
-    [ rot * exp /f ]
+    [ rot * e^ /f ]
     tri* ; inline
 
 : ^theta ( w abs arg -- theta )
@@ -223,8 +223,6 @@ M: float log1+ dup -1.0 >= [ flog1+ ] [ 1.0 + 0.0 rect> log ] if ; inline
 
 : 10^ ( x -- y ) 10 swap ^ ; inline
 
-: e^ ( x -- y ) e swap ^ ; inline
-
 GENERIC: log10 ( x -- y ) foldable
 
 M: real log10 >float flog10 ; inline
@@ -361,8 +359,8 @@ M: real atan >float atan ; inline
 : lerp ( a b t -- a_t ) [ over - ] dip * + ; inline
 
 : roots ( x t -- seq )
-    [ [ log ] [ recip ] bi* * exp ]
-    [ recip 2pi * 0 swap complex boa exp ]
+    [ [ log ] [ recip ] bi* * e^ ]
+    [ recip 2pi * 0 swap complex boa e^ ]
     [ iota [ ^ * ] with with map ] tri ;
 
 : sigmoid ( x -- y ) neg e^ 1 + recip ; inline
index 9b3930f346d6a19ac7e3d02400724d35a709495c..f0730f3f6add92454d3e6dc8e5857c016cda8ff7 100644 (file)
@@ -69,7 +69,7 @@ HELP: fsinh
 
 HELP: fexp
 { $values { "x" real } { "double" real } }
-{ $description "Calls the exponential function (" { $snippet "y=e^x" } ") from the C standard library. User code should call " { $link exp } " instead." } ;
+{ $description "Calls the exponential function (" { $snippet "y=e^x" } ") from the C standard library. User code should call " { $link e^ } " instead." } ;
 
 HELP: flog
 { $values { "x" real } { "double" real } }
index a13f4065d7d3485c43aedc123e6475aa55b70ed5..a4ec1ea090b1c2b57058fea96a82348e626c9044 100644 (file)
@@ -116,7 +116,7 @@ ERROR: too-many-samples seq n ;
     (cos-random-float) (log-sqrt-random-float) * * + ;
 
 : lognormal-random-float ( mean sigma -- n )
-    normal-random-float exp ;
+    normal-random-float e^ ;
 
 : exponential-random-float ( lambda -- n )
     random-unit log neg swap / ;
@@ -149,7 +149,7 @@ ERROR: too-many-samples seq n ;
         random-unit :> u2
 
         u1 1. u1 - / log ainv / :> v
-        alpha v exp *           :> x
+        alpha v e^ *           :> x
         u1 sq u2 *              z!
         bbb ccc v * + x -       r!
 
@@ -168,7 +168,7 @@ ERROR: too-many-samples seq n ;
         p 1.0 > [
             random-unit x alpha 1 - ^ >
         ] [
-            random-unit x neg exp >
+            random-unit x neg e^ >
         ] if
     ] [
         random-unit b * p!
@@ -204,7 +204,7 @@ ERROR: too-many-samples seq n ;
         0 :> c! 0 :> _f! ! initialize locals
         [
             random-unit {
-                [ 2. c - c * < ] [ 1. c - exp c * <= ]
+                [ 2. c - c * < ] [ 1. c - e^ c * <= ]
             } 1|| not
         ] [
             random-unit pi * cos :> z
@@ -252,7 +252,7 @@ ERROR: too-many-samples seq n ;
     random-unit dup 1 swap - / log * + ;
 
 : power-random-float ( alpha -- n )
-    [ random-unit log exp 1 swap - ] dip recip ^ ;
+    [ random-unit log e^ 1 swap - ] dip recip ^ ;
 
 {
     { [ os windows? ] [ "random.windows" require ] }
index e4052836b4ffca8662be7df633c198233b6f3746..94e4bc8fdc92795b2f6e643a3844b9ced0f9f7b1 100644 (file)
@@ -27,7 +27,7 @@ CONSTANT: gamma-p6
 
 : gamma-lanczos6 ( x -- gamma[x] )
     #! gamma(x) = gamma(x+1) / x
-    [ (gamma-lanczos6) exp ] keep / ;
+    [ (gamma-lanczos6) e^ ] keep / ;
 
 : gammaln-lanczos6 ( x -- gammaln[x] )
     #! log(gamma(x)) = log(gamma(x+1)) - log(x)
@@ -104,7 +104,7 @@ PRIVATE>
         nip
         /
         over /
-        swap -1.0 * exp
+        swap -1.0 * e^
         *
     ] if ;
 
index c6a9d1a357504eab5226b7b40fd0710d216eb7f0..ee30d534bb093d0c1bcc176033539138afc92b7d 100644 (file)
@@ -30,7 +30,7 @@ DERIVATIVE: abs
 
 DERIVATIVE: sqrt [ sqrt 2 * / ]
 
-DERIVATIVE: exp [ exp * ]
+DERIVATIVE: e^ [ e^ * ]
 DERIVATIVE: log [ / ]
 
 DERIVATIVE: sin [ cos * ]
index 787367620f74541c29d39a90a3885bf3594a7335..d2cf314ac90bf9681ead4c890cfb0582d9aa22c8 100644 (file)
@@ -45,7 +45,7 @@ MEMO: bernoulli ( p -- n )
     even? [ "odd degrees of freedom" throw ] unless ;
 
 : (chi2P) ( chi/2 df/2 -- p )
-    [1,b) dupd n/v cum-product swap neg exp [ v*n sum ] keep + ;
+    [1,b) dupd n/v cum-product swap neg e^ [ v*n sum ] keep + ;
 
 PRIVATE>