Horner's rule for polynomial evaluation: Difference between revisions

Content deleted Content added
m →‎version 1: added/changed comments, indentations, and whitespace.
m →‎version 1: changed a comment.
Line 1,456: Line 1,456:
$= /*start with a clean slate equation. */
$= /*start with a clean slate equation. */
do deg=0 until poly=='' /*get the equation's coefficients. */
do deg=0 until poly=='' /*get the equation's coefficients. */
parse var poly c.deg poly /*get a equation coefficient. */
parse var poly c.deg poly; c.deg=c.deg/1 /*get equation coefficient & normalize.*/
c.deg=c.deg / 1 /*normalize it (by dividing by 1). */
if c.deg>=0 then c.deg= '+'c.deg /*if ¬ negative, then prefix with a + */
if c.deg>=0 then c.deg= '+'c.deg /*if ¬ negative, then prefix with a + */
$=$ c.deg /*concatenate it to the equation. */
$=$ c.deg /*concatenate it to the equation. */