Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Information / computing polynomial without EDP or CA



polynomial evaluation..
In lisp, horner's rule with error ...

(defun horne(A x)
  ;; evaluate polynomial A at x .  approximately. With error bounds.
  ;; return a list (p(x), e)  If the floating-point epsilon is eps,
  ;; the error in p  is bounded by e*eps .. that is, |A(x)-p|/eps <e
  ;; The polynomial A is a list (an ... a2 a1 a0)
  ;; representing an*x^n +...+a1*x +a0
  ;; The zero polynomial is either '(0) or '().

(let*((r (abs x))
        (p (or (first A) 0))
        (e (abs p)))
    (loop
     (pop A)
     (if (null A) (return (list p e))) ;poly,  error in poly
     (setf p (+ (first A) (* x p))
           e (+ (* r e) (abs (+ p p)))))))

If the error k= e*eps is too large, recompute in multiple-precision with a smaller eps.
The +, *, and abs operations can be generic.

I expect that the code in other contemporary languages would be of similar length. Multiple-precision software generally makes overflow a much more remote possibility.