How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the OCaml 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 OCaml 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 OCaml programming language
Source code in the ocaml programming language
# let horner coeffs x =
List.fold_left (fun acc coef -> acc * x + coef) 0 (List.rev coeffs) ;;
val horner : int list -> int -> int = <fun>
# let coeffs = [-19; 7; -4; 6] in
horner coeffs 3 ;;
- : int = 128
You may also check:How to resolve the algorithm Word wrap step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Queue/Definition step by step in the ALGOL W programming language
You may also check:How to resolve the algorithm Primality by Wilson's theorem step by step in the Sidef programming language
You may also check:How to resolve the algorithm Non-decimal radices/Input step by step in the Elixir programming language
You may also check:How to resolve the algorithm Calendar - for REAL programmers step by step in the AutoHotkey programming language