erased extra vocabs, added inversed function support
parent
0e34b0259a
commit
2b2a91db0a
|
@ -1,8 +1,9 @@
|
|||
! Copyright © 2008 Reginald Keith Ford II
|
||||
! Tools for quickly comparing, transforming, and evaluating mathematical Factor functions
|
||||
|
||||
USING: kernel math arrays ;
|
||||
USING: kernel math arrays sequences sequences.lib ;
|
||||
IN: math.function-tools
|
||||
: difference-func ( func func -- func ) [ bi - ] 2curry ;
|
||||
: eval ( x func -- pt ) dupd call 2array ;
|
||||
: eval-inverse ( y func -- pt ) dupd call swap 2array ;
|
||||
: eval3d ( x y func -- pt ) [ 2dup ] dip call 3array ;
|
||||
|
|
|
@ -7,8 +7,8 @@ IN: math.secant-method
|
|||
<PRIVATE
|
||||
: secant-solution ( x1 x2 function -- solution ) [ eval ] curry bi@ linear-solution ;
|
||||
: secant-step ( x1 x2 func -- x2 x3 func ) 2dup [ secant-solution ] 2dip swapd ;
|
||||
: secant-precision ( -- n ) 11 ;
|
||||
: secant-precision ( -- n ) 15 ;
|
||||
PRIVATE>
|
||||
: secant-method ( left right function -- x ) secant-precision [ secant-step ] times drop v+ 2 v*n ;
|
||||
: secant-method ( left right function -- x ) secant-precision [ secant-step ] times drop + 2 / ;
|
||||
! : close-enough? ( a b -- t/f ) - abs tiny-amount < ;
|
||||
! : secant-method2 ( left right function -- x ) 2over close-enough? [ drop average ] [ secant-step secant-method ] if ;
|
Loading…
Reference in New Issue