Commit dce41413 authored by Liam M. Healy's avatar Liam M. Healy

Change default derivative-free root solver

parent 18c1533c
;; Minimize or maximize the function in one variable.
;; Liam Healy 2011-01-14 12:18:15EST minimize.lisp
;; Time-stamp: <2017-09-21 18:23:03CDT one-dim.lisp>
;; Time-stamp: <2017-12-16 16:09:19EST one-dim.lisp>
;; Copyright 2011, 2014, 2015, 2017 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -47,6 +47,20 @@
(until (and
(gsl:root-test-delta root oldroot absolute-error relative-error))))
(values (gsl:solution solver) (funcall function (gsl:solution solver)))))
(:method (function (lower t) (upper number)
&optional (absolute-error 0.0001d0) (relative-error 0.0001d0) (method gsl:+brent-fsolver+))
;; Root solver with no derivative; in this case initial=lower and derivative=upper
(let ((solver (gsl:make-one-dimensional-root-solver-f
method function lower upper)))
(iter:for count from 0)
(iter:for root = (gsl:solution solver))
(iter:for lower = (gsl:fsolver-lower solver))
(iter:for upper = (gsl:fsolver-upper solver))
(gsl:iterate solver)
(until (or (> count *maximum-iterations*)
(gsl:root-test-interval lower upper absolute-error relative-error))))
(values (gsl:solution solver) (funcall function (gsl:solution solver))))))
(defun minimize-1d
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment