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

Source code in the pascal programming language

Program HornerDemo(output);

function horner(a: array of double; x: double): double;
  var
    i: integer;
  begin
    horner := a[high(a)];
    for i := high(a) - 1 downto low(a) do
      horner := horner * x + a[i];
  end;

const
  poly: array [1..4] of double = (-19.0, 7.0, -4.0, 6.0);

begin
  write ('Horner calculated polynomial of 6*x^3 - 4*x^2 + 7*x - 19 for x = 3: ');
  writeln (horner (poly, 3.0):8:4);
end.


  

You may also check:How to resolve the algorithm CUSIP step by step in the BASIC programming language
You may also check:How to resolve the algorithm Binary strings step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Undefined values step by step in the C# programming language
You may also check:How to resolve the algorithm Case-sensitivity of identifiers step by step in the Lasso programming language
You may also check:How to resolve the algorithm Product of min and max prime factors step by step in the Draco programming language