]> gitweb.factorcode.org Git - factor.git/commitdiff
remove redundant inv word; exp-int word from FSL
authorSlava Pestov <slava@factorcode.org>
Mon, 31 Oct 2005 06:10:09 +0000 (06:10 +0000)
committerSlava Pestov <slava@factorcode.org>
Mon, 31 Oct 2005 06:10:09 +0000 (06:10 +0000)
contrib/math/TODO.txt
contrib/math/analysis.factor
contrib/math/utils.factor

index c394efa7ec4d0a744bbeaa3c0fc63019e72d1045..1bc32992f9d291e12dd0cea59b789aaf52dc74da 100644 (file)
@@ -9,7 +9,7 @@ Nice to have:
   - elliptic functions
   - numerical integration
   - numerical differentiation
-  - infinite limits, sums, products
+  - infinite limits, sums, products (all done using a limit combinator)
   - finding roots with Newton's method
   - solving ODEs with Runge-Kutta
   - matrices: singular value decomposition, eigenvalues, LU decomposition,
@@ -17,10 +17,9 @@ Nice to have:
   - square root of a matrix, e^matrix
   - finding roots of polynomials
 - Algebra:
-  - polynomial derivative
-  - ^mod for polynomials
-  - mod-inv for polynomials
-  - arithmetic modulo a+sqrt(b)
+  - p^
+  - p^mod for polynomials
+  - pmod-inv for polynomials
   - matrices: row reduction, integer row reduction, matrix inverse,
     determinant
   - probablistic primality tests
@@ -33,15 +32,11 @@ Nice to have:
   - minimal and characteristic polynomials of algebraic numbers
   - norm and trace of algebraic numbers
   - minimal and characteristic polynomials of matrices
-- Graphs:
-  - minimum spanning trees
 - Logic:
   - tautology checker
   - CNF, DNF
   - natural deduction proof checker
-  - symbolic rewriting of expression trees
 - Statistics:
-  - mean, median, range, standard deviation
   - linear regression
 - Geometry:
   - regions
@@ -56,6 +51,7 @@ Nice to have:
   - symbolic differentiation
   - differential forms
   - wedge product
+  - power series
 - Graphics:
   - 2D, 3D plots
   - y=f(x), implicit, parametric
index a5fb6a2c957378e27ee86c90d53749cf4b74c69a..fae767205301842f727aaf618068eb7f4576246e 100644 (file)
@@ -56,5 +56,56 @@ IN: math-contrib
     ] if ;
 
 : nth-root ( n x -- )
-    log >r inv r> * e swap ^ ;
+    log >r recip r> * e swap ^ ;
 
+! Forth Scientific Library Algorithm #1
+!
+! Evaluates the Real Exponential Integral,
+!     E1(x) = - Ei(-x) =   int_x^\infty exp^{-u}/u du      for x > 0
+! using a rational approximation
+!
+! Collected Algorithms from ACM, Volume 1 Algorithms 1-220,
+! 1980; Association for Computing Machinery Inc., New York,
+! ISBN 0-89791-017-6
+!
+! (c) Copyright 1994 Everett F. Carter.  Permission is granted by the
+! author to use this software for any application provided the
+! copyright notice is preserved.
+
+: exp-int ( x -- y )
+    #! For real values of x only. Accurate to 7 decimals.
+    dup 1.0 < [
+        dup 0.00107857 * 0.00976004 -
+        over *
+        0.05519968 +
+        over *
+        0.24991055 -
+        over *
+        0.99999193 +
+        over *
+        0.57721566 -
+        swap log -
+    ] [
+        dup 8.5733287401 +
+        over *
+        18.059016973 +
+        over *
+        8.6347608925 +
+        over *
+        0.2677737343 +
+
+        over
+        dup 9.5733223454 +
+        over *
+        25.6329561486 +
+        over *
+        21.0996530827 +
+        over *
+        3.9584969228 +
+
+        nip
+        /
+        over /
+        swap -1.0 * exp
+        *
+    ] if ;
index 27d791a704cca0f59c457bedeee2c9e1c0321073..a27fc402d3824aabf8c55943ddada3dc35c1391f 100644 (file)
@@ -31,7 +31,3 @@ USING: errors kernel sequences math ;
 : c. ( v v -- x )
     #! Complex inner product.
     0 [ ** + ] 2reduce ;
-
-: inv
-    #! inverse
-    1 swap / ; inline