factor/extra/math/derivatives/derivatives.factor

9 lines
387 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-12 ;
: near ( x -- y ) small-amount + ;
2008-07-22 20:45:13 -04:00
: derivative ( x function -- m ) 2dup [ near ] dip [ eval ] 2bi@ slope ;
: derivative-func ( function -- function ) [ derivative ] curry ;