In: Mechanical Engineering
At a relative maximum of a curve y(x), the slope dy/dx is zero. Use the following data to estimate the values of x and y that correspond to a maximum point.
Consider the following data:
x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
y | 0 | 2 | 5 | 7 | 9 | 10 | 8 | 7 | 6 | 8 | 10 |
The objective is to estimate the values of x and y that correspond to maximum point.
From the given data, find the first order derivative for all intervals using backward difference method.
When the first order derivative is zero, it implies at a relative maximum.
So, find the interval where this derivative becomes zero and then obtain the values of x and y by linear interpolation.
Mat-lab code for above problem is provided below.
Save this program as ‘Required problem’.
% Find out the maximum point using dy/dx data
clc; clear;
x = 0:10;
y = [0 2 5 7 9 10 8 7 6 8 10];
d1 = diff(y)./diff(x);
for i=1:9
if d1(i)*d1(i+1)<0
d=d1(i)-d1(i+1);
r=d1(i)/d;
x1=x(i)+r*(x(i+1)-x(i)); % Linear interpolation
y1=y(i)+r*(y(i+1)-y(i)); % in the interval
break;
end
end
disp(\'X-value at maximum point\');
disp(x1);
disp(\'Y-value at maximum point\');
disp(y1);
The output of the code ‘Required problem’ in the command window is shown below:
X-value at maximum point
4.3333
Y-value at maximum point
9.3333
X-value at maximum point is 4.3333
Y-value at maximum point is 9.3333