Question: Why are there extra characters when using printf

I am playing around with a crude implementation of the bisection algorithm. I am using printf  to display some of the output, however there are a couple extra characters, namely, ()^2, at the end. When the very last line is removed, it goes away. What is causing this?

restart; f := proc (x) options operator, arrow; evalf(x^3-3*x^2+1) end proc; a := 0.; b := 1.0; count := 0; while abs(b-a) > 10^(-8) do count := 1+count; m := (a+b)*(1/2); print([a, m, b]); if f(a)*f(m) < 0 then b := m else a := m end if end do; fval := f(m); printf("\n The function value at %10.10g is %10.10g.\n", m, fval)*printf("\n Number of interations: %d.\n", count)

()^2

(1)

restart; f := proc (x) options operator, arrow; evalf(x^3-3*x^2+1) end proc; a := 0.; b := 1.0; count := 0; while abs(b-a) > 10^(-8) do count := 1+count; m := (a+b)*(1/2); print([a, m, b]); if f(a)*f(m) < 0 then b := m else a := m end if end do; fval := f(m); printf("\n The function value at %10.10g is %10.10g.\n", m, fval)


 The function value at 0.6527036502 is   -1.5e-08.

 

``


Download bisect.mw

Please Wait...