diff --git a/basis/inverse/inverse.factor b/basis/inverse/inverse.factor index 1f72abffcf..3e1f88abe2 100644 --- a/basis/inverse/inverse.factor +++ b/basis/inverse/inverse.factor @@ -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 ; diff --git a/basis/math/complex/complex-tests.factor b/basis/math/complex/complex-tests.factor index 5c41d6219e..d7fe54b201 100644 --- a/basis/math/complex/complex-tests.factor +++ b/basis/math/complex/complex-tests.factor @@ -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 diff --git a/basis/math/functions/functions-docs.factor b/basis/math/functions/functions-docs.factor index 765f99c9b9..43188d94c3 100644 --- a/basis/math/functions/functions-docs.factor +++ b/basis/math/functions/functions-docs.factor @@ -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" } } diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 19565b5d84..2a235adfaa 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -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 diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 993e9ad1a5..4bbdb0ec43 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -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 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 diff --git a/basis/math/libm/libm-docs.factor b/basis/math/libm/libm-docs.factor index 9b3930f346..f0730f3f6a 100644 --- a/basis/math/libm/libm-docs.factor +++ b/basis/math/libm/libm-docs.factor @@ -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 } } diff --git a/basis/random/random.factor b/basis/random/random.factor index a13f4065d7..a4ec1ea090 100644 --- a/basis/random/random.factor +++ b/basis/random/random.factor @@ -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 ] } diff --git a/extra/math/analysis/analysis.factor b/extra/math/analysis/analysis.factor index e4052836b4..94e4bc8fdc 100644 --- a/extra/math/analysis/analysis.factor +++ b/extra/math/analysis/analysis.factor @@ -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 ; diff --git a/extra/math/derivatives/derivatives.factor b/extra/math/derivatives/derivatives.factor index c6a9d1a357..ee30d534bb 100644 --- a/extra/math/derivatives/derivatives.factor +++ b/extra/math/derivatives/derivatives.factor @@ -30,7 +30,7 @@ DERIVATIVE: abs DERIVATIVE: sqrt [ sqrt 2 * / ] -DERIVATIVE: exp [ exp * ] +DERIVATIVE: e^ [ e^ * ] DERIVATIVE: log [ / ] DERIVATIVE: sin [ cos * ] diff --git a/extra/math/extras/extras.factor b/extra/math/extras/extras.factor index 787367620f..d2cf314ac9 100644 --- a/extra/math/extras/extras.factor +++ b/extra/math/extras/extras.factor @@ -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>