From 2b2a91db0adc08c8465d00f02a4c68a0b5f6821a Mon Sep 17 00:00:00 2001 From: Rex Ford Date: Sat, 2 Aug 2008 14:02:33 -0400 Subject: [PATCH] erased extra vocabs, added inversed function support --- extra/math/function-tools/function-tools.factor | 3 ++- extra/math/secant-method/secant-method.factor | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extra/math/function-tools/function-tools.factor b/extra/math/function-tools/function-tools.factor index 042b5f0897..802bf9e14e 100644 --- a/extra/math/function-tools/function-tools.factor +++ b/extra/math/function-tools/function-tools.factor @@ -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 ; diff --git a/extra/math/secant-method/secant-method.factor b/extra/math/secant-method/secant-method.factor index 2089dde848..e039b42bbd 100644 --- a/extra/math/secant-method/secant-method.factor +++ b/extra/math/secant-method/secant-method.factor @@ -7,8 +7,8 @@ IN: math.secant-method -: 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 ; \ No newline at end of file