How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Rascal 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 Rascal 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 Rascal programming language
Source code in the rascal programming language
import List;
public int horners_rule(list[int] coefficients, int x){
acc = 0;
for( i <- reverse(coefficients)){
acc = acc * x + i;}
return acc;
}
public int horners_rule2(list[int] coefficients, int x) = (0 | it * x + c | c <- reverse(coefficients));
rascal>horners_rule([-19, 7, -4, 6], 3)
int: 128
rascal>horners_rule2([-19, 7, -4, 6], 3)
int: 128
You may also check:How to resolve the algorithm Poker hand analyser step by step in the Wren programming language
You may also check:How to resolve the algorithm Sort disjoint sublist step by step in the jq programming language
You may also check:How to resolve the algorithm Logical operations step by step in the Lua programming language
You may also check:How to resolve the algorithm OLE automation step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Euler method step by step in the C++ programming language