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 

a = [ 1, -3, 2, 0 ];
r = roots(a);
% let's print it
for i = 1:3
  n = polyval(a, r(i));
  printf("x%d = %f (%f", i, r(i), n);
  if (n != 0.0)
    printf(" not");
  endif
  printf(" exact)\n");
endfor