File Exchange

image thumbnail


version (6.16 KB) by Matthew Kelly
Find all roots of polynomial and derivative on a bounded interval

1 Download

Updated 09 Jul 2016

View License

% getPolyRoots(C,tBnd)
% Given a vector of polynomial coefficients in C, and a bounded interval
% tBnd, getPolyRoots() finds the roots of this polynomial and all of its
% derivatives on the given interval.
% C = vector of polynomial coefficients, see >>help polyval for format
% tBnd = [tLow, tUpp] = time interval of interest
% R = cell array
% R{1} = vector of roots of the polynomial C, including tBnd
% R{2} = vector of roots of the derivative of C, including tBnd
% ...
% R{n} = vector of roots of the (n-1)th derivative of C
% 1) Why this function? There is clearly the matlab command roots().
% --> The implementation of this function is efficient for medium-order
% polynomials that have many roots which are not inside of the interval.
% In particular, it performs one root-solve per root found in R, not
% counting the boundary points. Thus, if there are no roots, then there
% is no root solve. Matlab's roots() command computes eigen-values to
% find the roots, and then you need to trim any roots not in the
% interval. This is the method that I use to validate the result of this
% function.
% 2) Matlab's roots() command should still be faster because they have an
% awesome vectorized implementation of eig().
% --> True. In many cases I suspect that the roots() method will actually
% be faster, since this code is not vectorized. My motivation is that I'm
% using this code to prototype the implementation, which I will later be
% writing up in C++ for other applications. In C++, the for loops in this
% implementation will run quickly.

Cite As

Matthew Kelly (2021). getPolyRoots(C,tBnd) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!