File:Lagrange simple.svg
From formulasearchengine
Jump to navigation
Jump to search
Original file (SVG file, nominally 512 × 450 pixels, file size: 5.6 MB)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionLagrange simple.svg |
English: derivative of https://en.wikipedia.org/wiki/File:Lagrange_simple.jpg |
| Date | |
| Source | Own work based on: Lagrange simple.svg en:File:Lagrange simple.jpg |
| Author |
Original: Jacobmelgaard Vector: |
| SVG development InfoField |
Source Code
The graph was made in Matlab with the following source code
% Function data
[X,Y] = meshgrid(-2:0.1:2, -2:0.1: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();
surface = surfc(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;
shading interp;
view([25 18]);
%plot2svg must be retrieved from http://www.zhinst.com/blogs/schwizer/
plot2svg;
Corresponding Mathematica code:
Block[{x, y, f = #^2 #2 &, g = #^2 + #2^2 &, c = 3},
sol = With[{max = MaxValue[{f[x, y], g[x, y] == c}, {x, y}]},
Solve[{f[x, y] == max, g[x, y] == c}, {x, y}, Reals]
];
Show[
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, Mesh -> {{c}},
MeshFunctions -> g, PlotRange -> All, Boxed -> False,
AspectRatio -> 1, PlotPoints -> 30, MeshStyle -> Cyan,
PerformanceGoal -> "Quality", ColorFunction -> "DeepSeaColors"],
Graphics3D[{Red, PointSize[Large], Point[{x, y, f[x, y]} /. sol]}]
]
]
Licensing
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
7 August 2012
5,869,505 byte
image/svg+xml
7023feebbf54f3e97f63c7dbbabb2da224ce0a07
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 18:52, 7 August 2012 | 512 × 450 (5.6 MB) | wikimediacommons>Zerodamage | Optimized, layers and text relocated |
File usage
There are no pages that use this file.
Retrieved from "https://en.formulasearchengine.com/wiki/File:Lagrange_simple.svg"