Find minimum of a generic polynomial
3 views (last 30 days)
Show older comments
Hi,
I have to write a script that involves expanding a polynomyc series up to a given degree and then find its minimum(s). What would be an efficient and fast way of computing it? Not sure how I would do it with a generic-degree polynomy.
As an example:
Given a series like
I'd like to program the script that expands the series up to a given degree N and then find its minima, probably derivating the function and evaluating on the points, but maybe there's a faster built-in solution.
Thank!
0 Comments
Answers (1)
Matt J
on 16 Jan 2023
Edited: Matt J
on 16 Jan 2023
roots(polyder(p)) will find the roots of the derivative of p. You can then evaluate the polynomial at all the roots to see where the smallest value is attained.
Example:
p=poly([0 3 4]);
r=roots(polyder(p));
x=linspace(-1,5,1000);
plot(x,polyval(p,x),r,polyval(p,r),'rx')
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!