What is the minimum slope of y=x^3-9*x^2+15*x? matlab code

2 ビュー (過去 30 日間)
Busra Tabak
Busra Tabak 2018 年 12 月 16 日
コメント済み: Image Analyst 2018 年 12 月 16 日
What is the minimum slope of y=x^3-9*x^2+15*x?
  2 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 16 日
what have you tried so far?
Busra Tabak
Busra Tabak 2018 年 12 月 16 日
syms x
f=x^3-9*x^2+15*x;
fprime=diff(f,x);
fdprime=diff(fprime,x);
xstar=double(solve(fprime==0,x));
xstar=unique(xstar);
for i=1:numel(xstar)
if subs(fdprime,x,xstar(i))>0
disp('min')
double(subs(f,x,xstar(i)))
end
end
I wrote this code and got this solution. Is it correct?
min
ans =
-25

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2018 年 12 月 16 日
Hint:
slope = 3 * x .^ 2 - 18 * x + 15; % Derivative.
minSlope = min(slope)
minAbsSlope = min(abs(slope))
Plot it, using linspace() for x, and see what you see. Of course since it's a parabola, the min absolute value of the slope will be zero and the min slope will depend on how far negative you want to evaluate x. For x that is more negative, the slope will be steeper.
  2 件のコメント
Busra Tabak
Busra Tabak 2018 年 12 月 16 日
I do not understand and I can not write the code. Did you find -25 as answer?
Image Analyst
Image Analyst 2018 年 12 月 16 日
No, of course not. Did you just plot the function and see it? Nowhere does it turn downwards and have a negative slope:
x = linspace(-50, 50, 100000);
y = x.^3-9*x.^2+15*x;
subplot(2, 1, 1);
plot(x, y, 'b-')
grid on;
fontSize = 20;
title('y = x .^ 3 - 9 * x .^ 2 + 15 * x', 'FontSize', fontSize, 'Interpreter', 'none');
xlabel('x', 'FontSize', fontSize, 'Interpreter', 'none');
ylabel('y', 'FontSize', fontSize, 'Interpreter', 'none');
slope = 3 * x .^ 2 - 18 * x + 15; % Derivative.
minSlope = min(slope)
minAbsSlope = min(abs(slope))
subplot(2, 1, 2);
plot(x, slope, 'b-')
xlabel('x', 'FontSize', fontSize, 'Interpreter', 'none');
ylabel('Slope of y', 'FontSize', fontSize, 'Interpreter', 'none');
title('slope = 3 * x .^ 2 - 18 * x + 15', 'FontSize', fontSize, 'Interpreter', 'none');
grid on;
0000 Screenshot.png
It's a parabola so what do you think the min absolute slope would be? And don't you see and understand that the min slope (most negative) will depend on how far out into the negative x territory you want to go?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by