Write a MATLAB code to Find the maxima and minima of two variable function f(x,y)=x^4+y^4-4xy+1
81 ビュー (過去 30 日間)
表示 古いコメント
Find the maxima and minima of two variable function f(x,y)=x^4+y^4-4xy+1
2 件のコメント
John D'Errico
2021 年 12 月 15 日
Please stop posting your homework assignment questions. Answers is not a service where we do your homework.
回答 (2 件)
Yusuf Suer Erdem
2021 年 12 月 13 日
Hi Akinchay, try these codes below please;
clc;
clear;
close all;
xMin = -2;
xMax = 2;
yMin = -2;
yMax = 2;
numPoints = 200;
xv = linspace(xMin, xMax, numPoints);
yv = linspace(yMin, yMax, numPoints);
[x, y] = meshgrid(xv, yv);
% f(x,y) = x.^4 + y.^4 - 4.*x.*y + 1
fprintf('Creating function.\n');
f = x.^4 + y.^4 - 4.*x.*y + 1;
fprintf('Creating surface plot.\n');
surf(x, y, f, 'LineStyle', 'none');
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
zlabel('f', 'FontSize', 20);
title('f(x,y) = x.^4 + y.^4 - 4.*x.*y + 1', 'FontSize', 20);
colorbar;
maxValue = max(abs(f(:)));
minValue = min(abs(f(:)));
fprintf('The max of f = %f.\nThe min of f = %f.\n', maxValue, minValue);

2 件のコメント
Torsten
2021 年 12 月 13 日
Not in your case because some solutions of p=0 and q=0 will be complex-valued.
参考
カテゴリ
Find more on Matrix Indexing in Help Center and File Exchange
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!