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'; |
> | f:=(1/2-x^2+y^2)*exp(1-x^2-y^2); |
> | fx:=diff(f,x); |
> | fy:=diff(f,y); |
Approximating the Peak of the Mountain
> | HighPt:=fsolve({fx=0,fy=0},{x,y},{x=-0.2..0.2,y=0.2..1}); |
> | assign(%); |
> | x1:=x+0.05; |
> | y1:=y+0.05; |
> | x:='x'; |
> | y:='y'; |
> | z1:=eval(f,{x=x1,y=y1}); |
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); |
Contour Plot
> | contourplot(f,x=-2.5..2.5,y=-3..3,contours=8,filled=true); |
Approximating the Path the Skier Would Take Down the Mountain
> | g:=eval(f,{x=P[1],y=P[2]}); |
> | gx:=eval(fx,{x=P[1],y=P[2]}); |
> | gy:=eval(fy,{x=P[1],y=P[2]}); |
> | point3d:=Array(1..25); |
> | route3d:=Array(1..25); |
> | timestep:=0.1; |
> | point3d[1]:=<x1,y1,z1>; |
> | 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); |
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]}); |
> | gy:=eval(fy,{x=P[1],y=P[2]}); |
> | point2d1:=Array(1..25); |
> | route2d1:=Array(1..25); |
> | timestep:=0.1; |
> | point2d1[1]:=<x1,y1>; |
> | 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); |
The Path of the Skier Projected onto the Contour Plot with a Different Starting Point
> | x:='x'; |
> | y:='y'; |
> | HighPt:=fsolve({fx=0,fy=0},{x,y},{x=-0.2..0.2,y=0.2..1}); |
> | assign(%); |
> | x1:=x-0.01; |
> | y1:=y-0.01; |
> | x:='x'; |
> | y:='y'; |
> | z1:=eval(f,{x=x1,y=y1}); |
> | gx:=eval(fx,{x=P[1],y=P[2]}); |
> | gy:=eval(fy,{x=P[1],y=P[2]}); |
> | point2d2:=Array(1..25); |
> | route2d2:=Array(1..25); |
> | timestep:=0.1; |
> | point2d2[1]:=<x1,y1>; |
> | 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); |
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]}); |
> | gx:=eval(fx,{x=P[1],y=P[2]}); |
> | gy:=eval(fy,{x=P[1],y=P[2]}); |
> | point3d:=Array(1..25); |
> | route3d:=Array(1..25); |
> | timestep:=0.1; |
> | point3d[1]:=<x1,y1,z1>; |
> | 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); |
> | display(Mountain,start1,start2,path3d1,path3d2); |
> | display(LevelContour,path2d1,path2d2); |
> |