MATLAB: Find all the roots of the following function in the interval 0.5<=x<=5. f(x)=(2/x-​x)cos(x)+0​.0119. Each root must be accurate to a minimum of six significant figures. I really can't figure it out.

roots

I need to write a code using bisect or false position to find all the roots of this function. I am lost. Don't know how to do it.

Best Answer

Plot the graph for f(x) in [0.5:5], choose intervals that contain only one of the roots and use MATLAB's fzero together with the intervals as initial condition to locate the roots exactly.
Best wishes
Torsten.