Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2c. A quadratic function of the form f(x) x 2 bx c attains its minimum value at

ID: 3814212 • Letter: 2

Question

2c. A quadratic function of the form f(x) x 2 bx c attains its minimum value at the critical point minx -b/2. Computing the minimum of f(x) on an interval [L,R] requires some checking. If minX is in the interval, then f(minX) is the answer. Otherwise f(x) is minimized either at x Lor x R. Write a function called minValue that takes 4 arguments, (b, c, L, R), and returns the minimum value of the quadratic function f(x) x 2 bx c on the interval [L,RJ You can assume all the arguments to the function are correct, all scalar real numbers (no vectors), and L R Create a test table and write matlab function to solve the problem. Design will be done in lecture or lab. Expected Result Test Case Reason Sample Data Verified? (manually calculate)

Explanation / Answer

There will be two matlab scripts:-

One as Main.m and other as minVal.m

1) Main.m ->

%There are 4 possible test cases and all the cases are verified
%The parameters passed in the function minVal is of the form (b,c,L,R)


%If -b/2 is in the range [L,R] then f(-b/2) is the answer = 3 (Expected Result -> Manually Calculated)
val = minVal(2,4,-2,5);
disp(val);

%If -b/2 is less than L and f(L) is the answer = 19 (Expected Result -> Manually Calculated)
val = minVal(2,4,3,7);
disp(val);

%If -b/2 is greater than R and f(L) is the answer = 20 (Expected Result -> Manually Calculated)
val = minVal(-10,-4,-3,-2);
disp(val);

%If -b/2 is greater than R and f(R) is the answer = 7 (Expected Result -> Manually Calculated)
val = minVal(-2,4,-3,-1);
disp(val);

2) minVal.m ->
function val = minVal(b,c,L,R)
   if -b/2 <= R && -b/2 >= L
       val = ((b*b)/4) - ((b*b)/2) + c;
   else
       v1 = ((L*L) + (b*L) + c);
       v2 = ((R*R) + (b*R) + c);
       if v1 < v2
           val = v1;
       else
           val = v2;
       end
   end
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote