I was wondering if anyone would be able to help me out with this.. I need to use a function M file to determine the local minimum of a parabola where the critical points can also qualify as a minimum. Here is my code. Currently it is returning values without error but the values don't match any of my test data given by my instructor.
if true function c = myminimum(f, a, b)syms x v w;w=solve(diff(f(x)));v=subs(f(x), w);if (a<v && a<b); c=a;elseif (b<v && b<a); c=b; else c=v; endend
Here is the test data if that helps:
if truea = myminimum(@(x) x^2+1,-3,2)a = 1a = myminimum(@(x) x^2+6*x-3,-2,0)a = -11a = myminimum(@(x) -2*x^2+10*x,3,8)a = -48a = myminimum(@(x) -x^2+2*x+1,5,6)a = -23
Best Answer