0% found this document useful (0 votes)
8 views1 page

Question 2 Psed

The document contains a MATLAB function that calculates the critical point, function value at that point, and whether it is a maximum or minimum for a quadratic function defined by coefficients a, b, and c. Two specific quadratic functions are evaluated using this function, and the results are displayed, indicating the critical points and their corresponding function values. The function also handles cases where the quadratic nature is undefined.

Uploaded by

Viking CubesAts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Question 2 Psed

The document contains a MATLAB function that calculates the critical point, function value at that point, and whether it is a maximum or minimum for a quadratic function defined by coefficients a, b, and c. Two specific quadratic functions are evaluated using this function, and the results are displayed, indicating the critical points and their corresponding function values. The function also handles cases where the quadratic nature is undefined.

Uploaded by

Viking CubesAts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

3/5/25 2:23 PM C:\Users\veerm\OneDrive\Desktop\exam2.

m 1 of 1

function [x, y, type] = fun(a, b, c)


% Input: a, b, c (coefficients of the quadratic function)
% Output: x (critical point), y (function value at x), type (max/min)

% Compute the critical point (vertex) x = -b / (2a)


x = -b / (2 * a);

% Compute the function value at x


y = a * x^2 + b * x + c;

% Determine whether it's a maximum or minimum


if a > 0
type = 'Minimum';
elseif a < 0
type = 'Maximum';
else
type = 'Undefined (not a quadratic function)';
end
end

% Given functions
[a1, b1, c1] = deal(3, -18, 48); % f(x) = 3x² - 18x + 48
[a2, b2, c2] = deal(-5, -10, -3); % f(x) = -5x² - 10x - 3

% Compute maxima/minima using the function


[x1, y1, type1] = fun(a1, b1, c1);
[x2, y2, type2] = fun(a2, b2, c2);

% Display results
disp(['For f(x) = 3x² - 18x + 48:']);
disp(['Critical point at x = ', num2str(x1)]);
disp(['Function value at critical point y = ', num2str(y1)]);
disp(['This is a ', type1]);
disp('----------------');

disp(['For f(x) = -5x² - 10x - 3:']);


disp(['Critical point at x = ', num2str(x2)]);
disp(['Function value at critical point y = ', num2str(y2)]);
disp(['This is a ', type2]);

You might also like