MapleTwinPeaks.mws

The Skier's Path

Adapted from the Maple 8 Getting Started Guide

A skier is close to the top of one of the two peaks of a mountain.  She wants to take the steepest path down.  This worksheet investigates finding this path.

The height at a point on the mountain is given by f.  She starts from the point (x1,y1).

Picture of the Mountain

>    with(plots):

>    x:='x';

>    y:='y';

x := 'x'

y := 'y'

>    f:=(1/2-x^2+y^2)*exp(1-x^2-y^2);

f := (1/2-x^2+y^2)*exp(1-x^2-y^2)

>    fx:=diff(f,x);

fx := -2*x*exp(1-x^2-y^2)-2*(1/2-x^2+y^2)*x*exp(1-x^2-y^2)

>    fy:=diff(f,y);

fy := 2*y*exp(1-x^2-y^2)-2*(1/2-x^2+y^2)*y*exp(1-x^2-y^2)

Approximating the Peak of the Mountain

>    HighPt:=fsolve({fx=0,fy=0},{x,y},{x=-0.2..0.2,y=0.2..1});

HighPt := {x = 0., y = .7071067812}

>    assign(%);

>    x1:=x+0.05;

x1 := .5e-1

>    y1:=y+0.05;

y1 := .7571067812

>    x:='x';

>    y:='y';

x := 'x'

y := 'y'

>    z1:=eval(f,{x=x1,y=y1});

z1 := 1.636585296

Picturing the Mountain and the Starting Point

>    start1:=pointplot3d([x1,y1,z1],symbol=cross,symbolsize=50,color=yellow):

>    Mountain:=plot3d(f,x=-2.5..2.5,y=-3..3,numpoints=2500,axes=boxed,orientation=[35,60],contours=20):

>    display(Mountain,start1);

[Maple Plot]

Contour Plot

>    contourplot(f,x=-2.5..2.5,y=-3..3,contours=8,filled=true);

[Maple Plot]

Approximating the Path the Skier Would Take Down the Mountain

>    g:=eval(f,{x=P[1],y=P[2]});

g := (1/2-P[1]^2+P[2]^2)*exp(1-P[1]^2-P[2]^2)

>    gx:=eval(fx,{x=P[1],y=P[2]});

gx := -2*P[1]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[1]*exp(1-P[1]^2-P[2]^2)

>    gy:=eval(fy,{x=P[1],y=P[2]});

gy := 2*P[2]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[2]*exp(1-P[1]^2-P[2]^2)

>    point3d:=Array(1..25);

point3d := Array(%id = 21227456)

>    route3d:=Array(1..25);

route3d := Array(%id = 21216324)

>    timestep:=0.1;

timestep := .1

>    point3d[1]:=<x1,y1,z1>;

point3d[1] := Vector(%id = 21202708)

>    for i from 1 to 24 do
route3d[i]:=LinearAlgebra[Normalize](eval(<-gx,-gy,0>,P=point3d[i]));
point3d[i+1]:=eval(<P[1],P[2],g>,P=point3d[i]+timestep*route3d[i]);
end do:

>    listpoints3d:=[seq(convert(point3d[i],list),i=1..25)]:

>    path3d1:=pointplot3d(listpoints3d,style=line,color=red,thickness=3):

>    display(Mountain,start1,path3d1);

[Maple Plot]

The Path of the Skier Projected onto the Contour Plot

>    LevelContour:=contourplot(f,x=-2.5..2.5,y=-3..3,contours=8,filled=true):

>    gx:=eval(fx,{x=P[1],y=P[2]});

gx := -2*P[1]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[1]*exp(1-P[1]^2-P[2]^2)

>    gy:=eval(fy,{x=P[1],y=P[2]});

gy := 2*P[2]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[2]*exp(1-P[1]^2-P[2]^2)

>    point2d1:=Array(1..25);

point2d1 := Array(%id = 21202748)

>    route2d1:=Array(1..25);

route2d1 := Array(%id = 21203788)

>    timestep:=0.1;

timestep := .1

>    point2d1[1]:=<x1,y1>;

point2d1[1] := Vector(%id = 21204788)

>    for i from 1 to 24 do
route2d1[i]:=LinearAlgebra[Normalize](eval(<-gx,-gy>,P=point2d1[i]));
point2d1[i+1]:=eval(<P[1],P[2]>,P=point2d1[i]+timestep*route2d1[i]);
end do:

>    listpoints2d1:=[seq(convert(point2d1[i],list),i=1..25)]:

>    path2d1:=pointplot(listpoints2d1,style=line,color=blue,thickness=3):

>    display(LevelContour,path2d1);

[Maple Plot]

The Path of the Skier Projected onto the Contour Plot   with a Different Starting Point

>    x:='x';

>    y:='y';

x := 'x'

y := 'y'

>    HighPt:=fsolve({fx=0,fy=0},{x,y},{x=-0.2..0.2,y=0.2..1});

HighPt := {x = 0., y = .7071067812}

>    assign(%);

>    x1:=x-0.01;

x1 := -.1e-1

>    y1:=y-0.01;

y1 := .6971067812

>    x:='x';

>    y:='y';

x := 'x'

y := 'y'

>    z1:=eval(f,{x=x1,y=y1});

z1 := 1.648225158

x := 'x'

y := 'y'

>    gx:=eval(fx,{x=P[1],y=P[2]});

gx := -2*P[1]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[1]*exp(1-P[1]^2-P[2]^2)

>    gy:=eval(fy,{x=P[1],y=P[2]});

gy := 2*P[2]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[2]*exp(1-P[1]^2-P[2]^2)

>    point2d2:=Array(1..25);

point2d2 := Array(%id = 21204828)

>    route2d2:=Array(1..25);

route2d2 := Array(%id = 21298272)

>    timestep:=0.1;

timestep := .1

>    point2d2[1]:=<x1,y1>;

point2d2[1] := Vector(%id = 21288348)

>    for i from 1 to 24 do
route2d2[i]:=LinearAlgebra[Normalize](eval(<-gx,-gy>,P=point2d2[i]));
point2d2[i+1]:=eval(<P[1],P[2]>,P=point2d2[i]+timestep*route2d2[i]);
end do:

>    listpoints2d2:=[seq(convert(point2d2[i],list),i=1..25)]:

>    path2d2:=pointplot(listpoints2d2,style=line,color=blue,thickness=3):

>    display(LevelContour,path2d2);

[Maple Plot]

The Path of the Skier with the New Starting Point

>    start2:=pointplot3d([x1,y1,z1],symbol=cross,symbolsize=50,color=green):

>    g:=eval(f,{x=P[1],y=P[2]});

g := (1/2-P[1]^2+P[2]^2)*exp(1-P[1]^2-P[2]^2)

>    gx:=eval(fx,{x=P[1],y=P[2]});

gx := -2*P[1]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[1]*exp(1-P[1]^2-P[2]^2)

>    gy:=eval(fy,{x=P[1],y=P[2]});

gy := 2*P[2]*exp(1-P[1]^2-P[2]^2)-2*(1/2-P[1]^2+P[2]^2)*P[2]*exp(1-P[1]^2-P[2]^2)

>    point3d:=Array(1..25);

point3d := Array(%id = 21284332)

>    route3d:=Array(1..25);

route3d := Array(%id = 21289388)

>    timestep:=0.1;

timestep := .1

>    point3d[1]:=<x1,y1,z1>;

point3d[1] := Vector(%id = 21265748)

>    for i from 1 to 24 do
route3d[i]:=LinearAlgebra[Normalize](eval(<-gx,-gy,0>,P=point3d[i]));
point3d[i+1]:=eval(<P[1],P[2],g>,P=point3d[i]+timestep*route3d[i]);
end do:

>    listpoints3d:=[seq(convert(point3d[i],list),i=1..25)]:

>    path3d2:=pointplot3d(listpoints3d,style=line,color=red,thickness=3):

Change the View of the Mountain

>    Mountain:=plot3d(f,x=-3.3..2,y=-4..2,numpoints=2500,axes=boxed,orientation=[-100,60],contours=20):

>    display(Mountain,start2,path3d2);

[Maple Plot]

>    display(Mountain,start1,start2,path3d1,path3d2);

[Maple Plot]

>    display(LevelContour,path2d1,path2d2);

[Maple Plot]

>