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

Source code in the elena programming language

import extensions;
import system'routines;
 
horner(coefficients,variable)
{
    ^ coefficients.clone().sequenceReverse().accumulate(new Real(),(accumulator,coefficient => accumulator * variable + coefficient))
}
 
public program()
{
    console.printLine(horner(new real[]{-19.0r, 7.0r, -4.0r, 6.0r}, 3.0r))
}

  

You may also check:How to resolve the algorithm Draw a clock step by step in the GUISS programming language
You may also check:How to resolve the algorithm Terminal control/Inverse video step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the Julia programming language
You may also check:How to resolve the algorithm GUI component interaction step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the J programming language