MATLAB: Polynomial Anonymous function degree

anonymous functiondegree

How can I find the degree of a given "anonymous function" like f=@(x) x^2+2x; given the functions are only polynomials?

Best Answer

Build a vector
X = realmax.^(1./(1:50));
Evaluate the function at X. The first result that is finite is probably the degree. However, it is possible for a polynomial with sufficiently large coefficients to generate an infinity "early", or for with sufficiently small leading coefficient to be "late" relative to this, so you should use that as a starting point to do more cross-checking.
Related Question