factor/extra/math/derivatives/derivatives.factor

10 lines
458 B
Factor
Raw Normal View History

2008-07-22 04:31:11 -04:00
! Copyright © 2008 Reginald Keith Ford II
! Tool for computing the derivative of a function at a point
USING: kernel math math.points math.function-tools ;
2008-07-22 20:45:13 -04:00
IN: math.derivatives
2008-07-22 04:31:11 -04:00
: 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 ;
2008-07-22 20:45:13 -04:00
: derivative-func ( function -- function ) [ derivative ] curry ;