How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Action! 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 Action! 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 Action! programming language

Source code in the action! programming language

INT FUNC Horner(INT ARRAY coeffs INT count,x)
  INT v,i

  v=0 i=count-1
  WHILE i>=0
  DO
    v=v*x+coeffs(i)
    i==-1
  OD
RETURN (v)

PROC Main()
  INT ARRAY coeffs=[65517 7 65532 6]
  INT res,x=[3],i,count=[4]

  PrintF("x=%I%E",x)
  FOR i=0 TO count-1
  DO
    PrintI(coeffs(i))
    IF i=1 THEN
      Print("x")
    ELSEIF i>1 THEN
      PrintF("x^%I",i)
    FI
    IF i=0 THEN
      Print("+")
    FI
  OD
  res=Horner(coeffs,4,x)
  PrintF("=%I%E",res)
RETURN

  

You may also check:How to resolve the algorithm Permutations step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm Abundant odd numbers step by step in the REXX programming language
You may also check:How to resolve the algorithm Execute a system command step by step in the Wart programming language
You may also check:How to resolve the algorithm Undefined values step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Mutual recursion step by step in the PHP programming language