Function: math-newton-multi

math-newton-multi is a byte-compiled function defined in calcalg3.el.gz.

Signature

(math-newton-multi EXPR JACOB N GUESS ORIG-GUESS LIMIT)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calcalg3.el.gz
(defun math-newton-multi (expr jacob n guess orig-guess limit)
  (let ((m -1)
	(p guess)
	p2 expr-val jacob-val next)
    (while (< (setq p (cdr p) m (1+ m)) n)
      (set (nth 2 (aref math-root-vars m)) (car p)))
    (setq expr-val (math-evaluate-expr expr)
	  jacob-val (math-evaluate-expr jacob))
    (unless (and (math-constp expr-val)
		 (math-constp jacob-val))
      (math-reject-arg guess "*Newton's method encountered a singularity"))
    (setq next (math-add guess (math-div (math-float (math-neg expr-val))
					 (math-float jacob-val)))
	  p guess p2 next)
    (math-working "newton" next)
    (while (and (setq p (cdr p) p2 (cdr p2))
		(math-nearly-equal (car p) (car p2))))
    (if p
	(if (Math-lessp (math-abs-approx (math-sub next orig-guess))
			limit)
	    (math-newton-multi expr jacob n next orig-guess limit)
	  (math-reject-arg nil "*Newton's method failed to converge"))
      (list 'vec next expr-val))))