Jump to content

File:Lagrange simple.jpg

From Wikipedia, the free encyclopedia

Lagrange_simple.jpg (678 × 596 pixels, file size: 78 KB, MIME type: image/jpeg)

Source Code

[edit]

The graph was made in Matlab with the following source code

% Function data
[X,Y] = meshgrid(-2:0.01:2, -2:0.01:2);
Z = (X.^2).*Y;

% Constraint data
t = -pi:0.01:pi;
xc = sqrt(3)*cos(t);
yc = sqrt(3)*sin(t);
zc = xc.^2 .* yc;

% Plot graph and constraint
figure();
meshc(X,Y,Z);
hold on;
plot3(xc, yc, zc, 'k', 'LineWidth', 2);
plot3(xc, yc ,-10*ones(1,length(t)), 'k', 'LineWidth', 1);
set(gcf, 'Color', [1 1 1]);
set(gcf, 'Position', [46 107 767 682]);
% Axis labels
text(0.2, -3, -10, 'x');
text(2.5, -.5, -10, 'y');
text(-2.4, -2, 0, 'z');

% Annotations of the max and min points
% Point indicating max #1
plot3(sqrt(2), 1, 2, 'kx', 'MarkerSize', 14, 'LineWidth', 2);
plot3(sqrt(2), 1, -10, 'kx', 'MarkerSize', 10, 'LineWidth', 2);
text('Interpreter', 'latex',...
	'String', '$$(\sqrt{2}, 1, 2)$$',...
	'Position', [1.1 .1 2.1],...
	'FontSize', 20);
% Point indicating max #2
plot3(-sqrt(2), 1, 2, 'kx', 'MarkerSize', 14, 'LineWidth', 2);
plot3(-sqrt(2), 1, -10, 'kx', 'MarkerSize', 10, 'LineWidth', 2);
text('Interpreter', 'latex',...
	'String', '$$(-\sqrt{2}, 1, 2)$$',...
	'Position', [-1.6 .1 2.1],...
	'FontSize', 20);
% Point indicating min #1
plot3(sqrt(2), -1, -2, 'kx', 'MarkerSize', 14, 'LineWidth', 2);
plot3(sqrt(2), -1, -10, 'kx', 'MarkerSize', 10, 'LineWidth', 2);
plot3(0,1,-3,'kx')
text('Interpreter', 'latex',...
	'String', '$$(\sqrt{2}, -1, -2)$$',...
	'Position', [.5 -.8 -1.4],...
	'FontSize', 20);
% Point indicating min #2
plot3(-sqrt(2), -1, -2, 'kx', 'MarkerSize', 14, 'LineWidth', 2);
plot3(-sqrt(2), -1, -10, 'kx', 'MarkerSize', 10, 'LineWidth', 2);
text('Interpreter', 'latex',...
	'String', '$$(-\sqrt{2}, -1, -2)$$',...
	'Position', [-1.9 -.8 -1],...
	'FontSize', 20);
hold off;
view([25 18]);

Licensing

[edit]

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current09:50, 14 June 2007Thumbnail for version as of 09:50, 14 June 2007678 × 596 (78 KB)Jacobmelgaard (talk | contribs)
No pages on the English Wikipedia use this file (pages on other projects are not listed).

Metadata