File:Level grad.svg
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Size of this PNG preview of this SVG file: 512 × 512 pixels. Other resolutions: 240 × 240 pixels | 480 × 480 pixels | 768 × 768 pixels | 1,024 × 1,024 pixels | 2,048 × 2,048 pixels.
Original file (SVG file, nominally 512 × 512 pixels, file size: 249 KB)
File information
Structured data
Captions
Summary[edit]
DescriptionLevel grad.svg |
English: Consider a function f whose graph looks like a hill. The blue curves are the level sets; the red curves follow the direction of the gradient. The cautious hiker follows the blue paths; the bold hiker follows the red paths. Note that blue and red paths always cross at right angles.
Source code: Lx1=-1.7; Lx2=2.3; Ly1=-2; Ly2=2; % box dimensions N=60; % split the box into N x N grid [X, Y]=meshgrid(Lx1:1/N:Lx2, Ly1:1/N:Ly2); % the grid f=inline('-((y+1).^4/25+(x-1).^4/10+x.^2+y.^2-1)'); % draw the level sets of f fx=inline('-2/5*(x-1).^3-2*x'); fy=inline('-4/25*(y+1).^3-2*y'); % partial deriv Z=f(X, Y); % the function value figure(1); clf; hold on; axis equal; axis off; % pop up a figure h=0.5; % spacing between heights v=[-20:h:0.8 0.85]; % the heights [c,h] = contour(X, Y, Z, v, 'b'); % the level sets at those heights x0=0.1333; y0=-0.0666; % coordinates of the top of the hill delta=0.01; % descend from the top of the hill with this step size Angles=linspace(0, 2*pi, 20); % will draw 19 descent curves with Angles(i) for i=1:length(Angles) x=x0+0.1*cos(Angles(i)); y=y0+0.1*sin(Angles(i)); % starting point Curve_x=[x]; Curve_y=[y]; % will hold a descent curve following the gradient % descend from the hill for j=1:500 x=x-delta*fx(x); y=y-delta*fy(y); Curve_x=[Curve_x x]; Curve_y=[Curve_y y]; % append the updated values if max(abs(x), abs(y)) > 5 % stop when going beyond the picture frame break; end end plot(Curve_x, Curve_y, 'r') % plot the curve of steepest descent end axis([Lx1 Lx2 Ly1 Ly2]); % the picture frame plot2svg('level_grad.svg',gcf); % Download plot2svg from Matlab central% |
Date | |
Source | File:Level_grad.png |
Author | Oleg Alexandrov |
Other versions | File:Level_grad.png |
Source code modified by me to output SVG directly from Matlab
Licensing[edit]
Public domainPublic domainfalsefalse |
I, the copyright holder of this work, release this work into the public domain. This applies worldwide. In some countries this may not be legally possible; if so: I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law. |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 08:49, 25 August 2010 | 512 × 512 (249 KB) | GyroMagician (talk | contribs) | Fixed page size to image size (using Inkscape) | |
08:48, 25 August 2010 | 512 × 384 (249 KB) | GyroMagician (talk | contribs) | {{Information |Description={{en|1=Source code: Lx1=-1.7; Lx2=2.3; Ly1=-2; Ly2=2; % box dimensions N=60; % split the box into N x N grid [X, Y]=meshgrid(Lx1:1/N:Lx2, Ly1:1/N:Ly2); % the grid f=inline('-((y+1).^4/25+(x-1).^4/10+x.^2+y.^2-1)'); |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on fa.wikipedia.org
- Usage on ro.wikipedia.org
- Usage on ru.wikipedia.org
- Usage on ug.wikipedia.org
- Usage on uk.wikipedia.org
- Usage on vi.wikipedia.org