A shortcoming to the bisection method is that, in dividing the interval x l to x u into equal halves, no account is taking of the magnitudes of f(x_l ) and f(x_u ). For example if f(x_l ) is closer to zero than f(x_u ), then it is more likely that the root will be closer to f(x_l ). An alternative method is join f(x_l ) and f(x_u ) by a straight line. The intersection of this line with the x-axis represents and improved estimate of the root.
In this code we solve the following example (you can change it to your example easily):