Now with statistically unbiased approx.

db4
Rex Ford 2008-08-02 13:57:59 -04:00
parent 5ddb166caa
commit 0e34b0259a
1 changed files with 4 additions and 3 deletions

View File

@ -3,7 +3,8 @@
USING: kernel math math.points math.function-tools ;
IN: math.derivatives
: small-amount ( -- n ) 1.0e-12 ;
: near ( x -- y ) small-amount + ;
: derivative ( x function -- m ) 2dup [ near ] dip [ eval ] 2bi@ slope ;
: small-amount ( -- n ) 1.0e-14 ;
: some-more ( x -- y ) small-amount + ;
: some-less ( x -- y ) small-amount - ;
: derivative ( x function -- m ) [ [ some-more ] dip eval ] [ [ some-less ] dip eval ] 2bi slope ;
: derivative-func ( function -- function ) [ derivative ] curry ;