Function: math-narrow-min
math-narrow-min is a byte-compiled function defined in calcalg3.el.gz.
Signature
(math-narrow-min EXPR A C INTV)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calcalg3.el.gz
(defun math-narrow-min (expr a c intv)
(let ((xvals (list a c))
(yvals (list (math-min-eval expr a)
(math-min-eval expr c)))
(levels 0)
(step (math-sub-float c a))
(found nil)
xp yp b)
(while (and (<= (setq levels (1+ levels)) 5)
(not found))
(setq xp xvals
yp yvals
step (math-mul-float step '(float 497 -3)))
(while (and (cdr xp) (not found))
(setq b (math-add-float (car xp) step))
(math-working "search" b)
(setcdr xp (cons b (cdr xp)))
(setcdr yp (cons (math-min-eval expr b) (cdr yp)))
(if (and (math-lessp-float (nth 1 yp) (car yp))
(math-lessp-float (nth 1 yp) (nth 2 yp)))
(setq found t)
(setq xp (cdr xp)
yp (cdr yp))
(if (and (cdr (cdr yp))
(math-lessp-float (nth 1 yp) (car yp))
(math-lessp-float (nth 1 yp) (nth 2 yp)))
(setq found t)
(setq xp (cdr xp)
yp (cdr yp))))))
(if found
(list (car xp) (car yp)
(nth 1 xp) (nth 1 yp)
(nth 2 xp) (nth 2 yp))
(or (if (math-lessp-float (car yvals) (nth 1 yvals))
(and (memq (nth 1 intv) '(2 3))
(let ((min (car yvals)))
(while (and (setq yvals (cdr yvals))
(math-lessp-float min (car yvals))))
(and (not yvals)
(list (nth 2 intv) min))))
(and (memq (nth 1 intv) '(1 3))
(setq yvals (nreverse yvals))
(let ((min (car yvals)))
(while (and (setq yvals (cdr yvals))
(math-lessp-float min (car yvals))))
(and (not yvals)
(list (nth 3 intv) min)))))
(math-reject-arg nil (format "*Unable to find a %s in the interval"
math-min-or-max))))))