Real roots on interval

Find all real roots of an arbitrary function over an arbitrary interval
Updated 29 May 2007

View License

This routine uses an analytical method to find all the real roots of an arbitrary function over an arbitrary interval. The approach used is to approximate the function by a series of Chebyshev polynomials, and then to find the roots of the approximation using a very efficient analytical method due to J.P. Boyd [see Appl. Num. Math. 56 pp.1077-1091 (2006)].

In the form given here, the function for which roots must be found is supplied as a MATLAB anonymous function. For example:

FindRealRoots(@(x) besselj(1,x),a,b,n)

...will find all the real roots of the function besselj(1,x) over the interval [a,b] based on an n-element Chebyshev expansion. At the end of the routine, as well as the calculated roots, the routine gives the time taken plus a plot of the original function and its approximation over the required interval: if the two do not coincide then the user should try again with a larger value of 'n'.

Cite As

Stephen Morris (2024). Real roots on interval (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Polynomials in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes