Function: math-nlfit-find-qmaxhalf

math-nlfit-find-qmaxhalf is a byte-compiled function defined in calc-nlfit.el.gz.

Signature

(math-nlfit-find-qmaxhalf PDATA TDATA)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-nlfit.el.gz
;; Next, given the pdata and tdata, we can find the qdata if we know q0.
;; We first try to find q0, using the fact that when p takes on its largest
;; value, q is half of its maximum value.  So we'll find the maximum value
;; of q given various q0, and use bisection to approximate the correct q0.

;; First, given pdata and tdata, find what half of qmax would be if q0=0.

(defun math-nlfit-find-qmaxhalf (pdata tdata)
  (let ((pmax (math-max-list (car pdata) (cdr pdata)))
        (qmh 0))
    (while (math-lessp (car pdata) pmax)
      (setq qmh
            (math-add qmh
                      (math-mul
                       (math-mul
                        '(float 5 -1)
                        (math-add (nth 1 pdata) (nth 0 pdata)))
                       (math-sub (nth 1 tdata)
                                 (nth 0 tdata)))))
      (setq pdata (cdr pdata))
      (setq tdata (cdr tdata)))
    qmh))