I'm looking to program a Python function that takes in 6 variables, a, b, c, d, e, f
, where a, b
is the interval to compute on (e.g. [1, 3]
, all real numbers), and c, d, e, f
are the coefficients of the cubic polynomial, i.e. f(x) = cx^3 + dx^2 + ex + f
, and returns the local min/max on the interval [a, b]
.
I have a rough idea (although the computing time would be bad) of how to program this, where I create a new list of steps 0.01
or something similarly small from a
to b
, evaluate f
at each value, then simply return the min/max of the list. This would take very long for a, b
values that are very far apart.
What is the best way to go about making this? Are there any outside libraries for scientific/mathematical computing? Thank you.
For cubic function you can find positions of potential minumum/maximums without optimization but using differentiation:
I think that differentiation should be in sympy
package
Also check whether problem statement assumes accounting for boundary values (as @Lakshay Garg notices in comments)