How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the jq 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 jq 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 jq programming language
Source code in the jq programming language
# Input: an array of coefficients specifying the polynomial
# to be evaluated at $x, where .[0] is the constant
def horner($x):
. as $coefficients
| reduce range(length-1; -1; -1) as $i (0; . * $x + $coefficients[$i]);
# Example
[-19, 7, -4, 6] | horner(3)
You may also check:How to resolve the algorithm Knuth shuffle step by step in the CMake programming language
You may also check:How to resolve the algorithm Accumulator factory step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the Maxima programming language
You may also check:How to resolve the algorithm ABC problem step by step in the Miranda programming language
You may also check:How to resolve the algorithm N-queens problem step by step in the IS-BASIC programming language