Task

Create a program that finds and outputs the roots of a given function, range and (if applicable) step width.

The program should identify whether the root is exact or approximate.



For this task, use:      ƒ(x)   =   x3 - 3x2 + 2x 

F f(x)
   R x^3 - 3 * x^2 + 2 * x
 
-V step = 0.001
-V start = -1.0
-V stop = 3.0
 
V sgn = f(start) > 0
V x = start
 
L x <= stop
   V value = f(x)
 
   I value == 0
      print(‘Root found at ’x)
   E I (value > 0) != sgn
      print(‘Root found near ’x)
 
   sgn = value > 0
   x += step