How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Icon and Unicon programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Icon and Unicon programming language

Table of Contents

Problem Statement

A fast scheme for evaluating a polynomial such as: when is to arrange the computation as follows: And compute the result from the innermost brackets outwards as in this pseudocode: Task Description Cf. Formal power series

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Icon and Unicon programming language

Source code in the icon programming language

procedure poly_eval (x, coeffs)
  accumulator := 0
  every index := *coeffs to 1 by -1 do 
    accumulator := accumulator * x + coeffs[index]
  return accumulator
end

procedure main ()
  write (poly_eval (3, [-19, 7, -4, 6]))
end


  

You may also check:How to resolve the algorithm Create an object at a given address step by step in the D programming language
You may also check:How to resolve the algorithm Strip a set of characters from a string step by step in the Racket programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the Pascal programming language
You may also check:How to resolve the algorithm Pythagorean triples step by step in the Clojure programming language
You may also check:How to resolve the algorithm Flatten a list step by step in the Quackery programming language