I am trying to compute the zero of a function using fzero, but the system always says my function must be finite and real. How can I solve that? Thank you!
1 view (last 30 days)
Matt J on 24 Sep 2021
Edited: Matt J on 24 Sep 2021
Clearly, your function is non-finite at x=0. There is a factor of x^2 in its denominator.
Regardless, fzero() is the wrong tool for analyzing a rational function. Just use roots() to get the roots of the numerator polynomial.
r=[roots([1 0 4 -10]).' ,-4/3];
r=real( r( abs(imag(r))<1e-10 ))
And, of course, you must make sure that none of the numerator roots coincide with any denominator roots, but that is obvious here by inspection.