diff options
author | James LewisMoss <dres@debian.org> | 1999-12-06 19:32:57 -0500 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:28 -0800 |
commit | c394920caedf3dac1981bb6b10eeb47fd6e4bb21 (patch) | |
tree | f21194653a3554f747dde3df908df993c48db5a0 /root.scm | |
parent | 926b1b647ac830660933a5e63eb52d4a2552e264 (diff) | |
parent | bd9733926076885e3417b74de76e4c9c7bc56254 (diff) | |
download | slib-c394920caedf3dac1981bb6b10eeb47fd6e4bb21.tar.gz slib-c394920caedf3dac1981bb6b10eeb47fd6e4bb21.zip |
Import Debian changes 2c7-1debian/2c7-1
slib (2c7-1) unstable; urgency=low
* New upstream.
* Add slibconfig back in.
slib (2c6-2) unstable; urgency=low
* Remove the slib$(VERSION).info file. Cut the diff back down to
size.
slib (2c6-1) unstable; urgency=low
* New upstream.
* Move docs to /usr/share. Up standards version. add /usr/doc symlink.
Move info files. Remove undocumented link.
slib (2c5-6) unstable; urgency=low
* Lowercase two vars in yasyn.scm (Fixes bug #37222)
slib (2c5-5) unstable; urgency=low
* Fix it so string-index isn't defined (now there is a
strsrch:string-index) (Fixes #38812)
slib (2c5-4) unstable; urgency=low
* Don't run slibconfig in postinst. (Fixes bug #38253, #37733, #37715,
#37746, #37809, #37917, #38123, #38462)
slib (2c5-3) unstable; urgency=low
* Run slibconfig in postinst. It was commented out there, but I don't
see any old bug reports on why it was commented out, so let's try
again. :) (Fixes bug #37221)
slib (2c5-2) unstable; urgency=low
* Link mklibcat.scm to mklibcat. Fixes a problem with using slib with
guile.
slib (2c5-1) unstable; urgency=low
* New upstream.
slib (2c3-4) unstable; urgency=low
* New maintainer.
Diffstat (limited to 'root.scm')
-rw-r--r-- | root.scm | 66 |
1 files changed, 66 insertions, 0 deletions
@@ -149,3 +149,69 @@ df+sqrt-H df-sqrt-H))))) (loop next-z (f next-z)))))))) + +(define (secant:find-root-1 f x0 x1 prec must-bracket?) + (letrec ((stop? + (cond ((procedure? prec) prec) + ((and (integer? prec) (negative? prec)) + (lambda (x0 x1 fmax count) + (>= count (- prec)))) + (else + (lambda (x0 f0 x1 f1 count) + (and (< (abs f0) prec) + (< (abs f1) prec)))))) + (bracket-iter + (lambda (xlo flo glo xhi fhi ghi count) + (define (step xnew fnew) + (cond ((or (= xnew xlo) + (= xnew xhi)) + (let ((xmid (+ xlo (* 1/2 (- xhi xlo))))) + (if (= xnew xmid) + xmid + (step xmid (f xmid))))) + ((positive? fnew) + (bracket-iter xlo flo (if glo (* 0.5 glo) 1) + xnew fnew #f + (+ count 1))) + (else + (bracket-iter xnew fnew #f + xhi fhi (if ghi (* 0.5 ghi) 1) + (+ count 1))))) + (if (stop? xlo flo xhi fhi count) + (if (> (abs flo) (abs fhi)) xhi xlo) + (let* ((fflo (if glo (* glo flo) flo)) + (ffhi (if ghi (* ghi fhi) fhi)) + (del (- (/ fflo (- ffhi fflo)))) + (xnew (+ xlo (* del (- xhi xlo)))) + (fnew (f xnew))) + (step xnew fnew)))))) + (let ((f0 (f x0)) + (f1 (f x1))) + (cond ((<= f0 0 f1) + (bracket-iter x0 f0 #f x1 f1 #f 0)) + ((<= f1 0 f0) + (bracket-iter x1 f1 #f x0 f0 #f 0)) + (must-bracket? #f) + (else + (let secant-iter ((x0 x0) + (f0 f0) + (x1 x1) + (f1 f1) + (count 0)) + (cond ((stop? x0 f0 x1 f1 count) + (if (> (abs f0) (abs f1)) x1 x0)) + ((<= f0 0 f1) + (bracket-iter x0 f0 #f x1 f1 #f count)) + ((>= f0 0 f1) + (bracket-iter x1 f1 #f x0 f0 #f count)) + ((= f0 f1) #f) + (else + (let* ((xnew (+ x0 (* (- (/ f0 (- f1 f0))) (- x1 x0)))) + (fnew (f xnew)) + (fmax (max (abs f1) (abs fnew)))) + (secant-iter x1 f1 xnew fnew (+ count 1))))))))))) + +(define (secant:find-root f x0 x1 prec) + (secant:find-root-1 f x0 x1 prec #f)) +(define (secant:find-bracketed-root f x0 x1 prec) + (secant:find-root-1 f x0 x1 prec #t)) |