I am currently in the debugging process, and I found that this is happening, ruining everything. For reference, f = @(x)ax^3+bx^2+c*x+d (where in this specific case, a = 2, b = -7, c = -8, d = 16).
Also, I notice that temp == -1.6861 returns false..