How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Lambdatalk 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 Lambdatalk 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 Lambdatalk programming language
Source code in the lambdatalk programming language
{def horner
{def horner.r
{lambda {:p :x :r}
{if {A.empty? :p}
then :r
else {horner.r {A.rest :p} :x {+ {A.first :p} {* :x :r}}}}}}
{lambda {:p :x}
{horner.r {A.reverse :p} :x 0}}}
{horner {A.new -19 7 -4 6} 3}
-> 128
{def φ {/ {+ 1 {sqrt 5}} 2}} = 1.618033988749895
{horner {A.new -1 -1 1} φ}
-> 2.220446049250313e-16 ~ 0
You may also check:How to resolve the algorithm File size step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Perfect totient numbers step by step in the Ruby programming language
You may also check:How to resolve the algorithm Guess the number/With feedback (player) step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Generic swap step by step in the Scheme programming language
You may also check:How to resolve the algorithm Read a specific line from a file step by step in the Frink programming language