Find two positive numbers whose sum is 300 and whose product is a maximum

2 ビュー (過去 30 日間)
Vansh
Vansh 2021 年 11 月 2 日
コメント済み: Mathieu NOE 2021 年 11 月 2 日
How do i present this maximum condition?

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 11 月 2 日
hello
simply write the mathematical equations given in the task description and solve it like this :
% equations are
% 1/ a + b = 300
% 2/ maximise P = a*b
a = 1:300;
b = 300-a;
P = a.*b; % can be rewritten as P = a.*(300-a) which is the equation of a parabola (as can be seen on the plot)
[Pmax,ind] = max(P); % find max value of P and corresponding value for a and b
a_max = a(ind);
b_max = 300-a_max;
plot(a,P)
  2 件のコメント
Vansh
Vansh 2021 年 11 月 2 日
Thanks
Mathieu NOE
Mathieu NOE 2021 年 11 月 2 日
my pleasure !
would you accept my answer ?
all the best

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by