Use MATLAB. Include both the main script and function script. There should be two scripts, not one.
Create a primary function that uses a function handle with a nested function to compute the minimum of the function e^(3.1x) - 20.2x^3 - 0.3x^2 + 22.7 - 40 over the range 0 < x < 10.