Horner's rule for polynomial evaluation: Difference between revisions

no edit summary
No edit summary
Line 1,536:
 
result = 128</pre>
 
=={{header|Ring}}==
<lang ring>
coefficients = [-19, 7, -4, 6]
see "x = 3" + nl
see "degree = 3" + nl
see "equation = 6*x^3-4*x^2+7*x-19" + nl
see "result = " + horner(coefficients, 3) + nl
func horner coeffs, x
w = 0
for n = len(coeffs) to 1 step -1
w = w * x + coeffs[n]
next
return w
</lang>
Output:
<pre>
x = 3
degree = 3
equation = 6*x^3-4*x^2+7*x-19
result = 128
</pre>
 
=={{header|RLaB}}==
2,468

edits