# quadMin - if xc< L xMin= L xMax= R else xMin= R xMax= L...

This preview shows page 1. Sign up to view the full content.

% Script quadMin % Minimum and Maximum of a quadratic q(x) = x^2 + bx + c % [Use nested IFs] close all disp('Min and max of quadratic x^2 + bx + c over [L,R]') b = input('Enter b: '); c = input('Enter c: '); L = input('Enter L: '); R = input('Enter R (L<=R): '); xc = -b/2; % critical point if L<=xc && xc<=R % critical point is inside the interval xMin= xc; if (xc-L)>(R-xc) xMax= L; else xMax= R; end else % Minimum of q is at one of the endpoints
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if xc < L xMin= L; xMax= R; else xMin= R; xMax= L; end end qMin= xMin^2 + b*xMin + c; qMax= xMax^2 + b*xMax + c; fprintf('Min value is %.4f\n', qMin) fprintf('Max value is %.4f\n', qMax) % Plot a graph xvector= linspace(L, R, 100); qvector= xvector.^2 + b*xvector + c; plot(xvector,qvector, xMin,qMin,'o', xMax,qMax,'*') title('q(x) from x=L to x=R')...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern