reset; with(LinearAlgebra):
<Text-field style="Heading 1" size="16" layout="Heading 1"><Font size="18">Use "solve" to solve a system of linear or nonlinear equations</Font></Text-field>Use "solve" to solve a system of equations. In this case there are more unknowns that equations so this homogeneous system has many solutions. [Solve can also work with systems of nonlinear equations]solve({x + 2*z - w =0, x + y + w=0, 2*x + y + 2*z=0});This solved for w and y in terms of x and z. You can also specify which variables to solve for:
solve({x + 2*z - w =0, x + y + w=0, 2*x + y + 2*z=0},{x,w});
You can also solve nonlinear equations.solve({2*x - w = 0, x^2 - w = 3});
<Text-field style="Heading 1" layout="Heading 1">Volcano</Text-field>z := (x,y) ->(x^2+3*y^2)*exp(-x^2-y^2);First you might plot it:with(plots):
plot3d(z(x,y), x=-2..2,y=-2..2, scaling=constrained);
plot3d(z(x,y), x=-2..2,y=-2..2);For more understanding you might seek all the local max, min, and saddle points.z_x := diff(z(x,y),x);
z_y := diff(z(x,y),y);
solve({z_x=0, z_y=0});
We thus see that there are 5 critical points:
{x = 0, y = 0}, {x = 0, y = 1}, {x = 0, y = -1}, {y = 0, x = 1},
{y = 0, x = -1}
With a bit more work we could classify them as to maxs, mins, and saddles.
<Text-field style="Heading 1" layout="Heading 1">A Torus (s, t)</Text-field>r:= s->a + b*cos(s);a:=3; b:=1;with(plots):plot3d([r(s)*cos(t), r(s)*sin(t), b*sin(s)], s=0..2*Pi, t=0..2*Pi, scaling=constrained );JSFH
<Text-field style="Heading 1" layout="Heading 1">A Torus (phi, theta)</Text-field>r:= phi->a + b*cos(phi);a:=3; b:=1;with(plots):
a:=3; b:=1;plot3d([r(phi)*cos(theta), r(phi)*sin(theta), b*sin(phi)], phi=0..2*Pi, theta=0..2*Pi, scaling=constrained)JSFH
<Text-field style="Heading 1" layout="Heading 1">Example: 2 minima, one saddle</Text-field>w:= (x,y) -> (x^2 + (y+2)^2)*(x^2 + (y-2)^2);with(plots):plot3d(w(x,y), x=-2..2,y=-3.2..3.2,view=-.5..50, axes=normal, labels=[x, "y", "z"]);JSFH
<Text-field style="Heading 1" layout="Heading 1">Strip with no twist</Text-field>with(plots):
phi:=-2*Pi/3: s:='s': t:='t': a:=10;
plot3d([(a+cos(phi)*t)*cos(s), (a+cos(phi)*t)*sin(s), sin(phi)*t], s=0..2*Pi, t=-2..2, color=[sin(1+t),sin(1+t),1], scaling=constrained, grid=[25,10], style=patch, orientation=[-55, 75]);
<Text-field style="Heading 1" layout="Heading 1">Strip with a full twist</Text-field>Next we twist this band by having the angle phi (which determines the slope) depend on s, say phi = s.phi:=s:plot3d([(a+cos(phi)*t)*cos(s), (a+cos(phi)*t)*sin(s), sin(phi)*t], s=0..2*Pi, t=-2..2, color=[sin(1+t),sin(1+t),1],scaling=constrained, grid=[25,10], style=patch, orientation=[-25, 80]);
<Text-field style="Heading 1" layout="Heading 1">Strip with a half-twist (Mobius band)</Text-field>In the picture we just saw, the band was given a full twist. Next we give it a half-twist: phi = s/2.phi:=s/2:plot3d([(a+cos(phi)*t)*cos(s), (a+cos(phi)*t)*sin(s), sin(phi)*t], s=0..2*Pi, t=-2..2, color=[sin(1+t),sin(1+t),1],scaling=constrained, grid=[25,10], style=patch, orientation=[-80, 75], title=`Mobius Band`, font=[TIMES, BOLD, 20]);This is a Mobius band. It has only one side. If you begin walking on one side, then where the band is joined you observe that you are on the "other" side. This is made explicit by the coloring since where the band is joined, the top on one part becomes the bottom on the other.