Mathematica Pearls

Problems and Solutions					Vol 7  No 2

by Don Piele

Welcome back to Mathematica Pearls, the column devoted to examining interesting Mathematica solutions to an assortment of simple yet appealing problems. During our Spring break in March, my wife and I took off for our first trip to the Grand Canyon. We drove to the South Rim in a rented car from Las Vegas –  a four hour scenic trip that crosses over the Hoover Dam and miles of sage brush. For a variety of reasons, this part of the United States had never been on our way to anything before so we decided it was time to see what the fuss was all about. We arrived at the canyon in time to make it over to the backcountry office and secure a number for the que that would form at 8:00 am the next morning. That was when the office distributed a limited number of permits to camp at the bottom on the canyon. Much to our surprise, we got exactly what we wanted - a trip down the Kibab trail to Bright Angel campground, followed by a night at Indian Garden campground and returning to the South Rim on the Bright Angel trail.

With clear skys and a welcome sun, we began our treck down the next morning from the trail head.were temperature hovered at 40 degrees. The trail was solid ice for the first mile but we had been warned to bring cramp on's.  The trail certainly lived up to its billing. At every switch back the a new panaromic view appeared, revealing new spires, buttes,  and mesa's showered in a different light. When we reached the bottom, our legs were a bit wobbly from breaking eash step for six hours. From then on, any small stretch of up hill was a welcome relief. We set up camp at Bright Angel campgroud beside a the rushing ..... creek and a very welcome 72 degree temperature. 

You are probably wondering about this time, "Is this guy just going to ramble on about his hiking trip or give us a problem?"
OK, you're right, let me get to the problem. It is motivated this time by the hike into the Grand Canyon.

THE PROBLEM -- Grand Canyon Hikes

\(TextForm
    \`\(\(\(\(This\ problem\ is\ about\ designing\ a\ \ hike\ over\ an\ \ 
                  irregular\ landscape\ like\ the\ Grand\ Canyon.\ \ The\ 
                  properties\ \ that\ characterize\ an\ easy\ hike\ are\ 

                as\ \(follows : \ 
1\))\)\ \ An\ easy\ hike\ is\ one\ that
              \ \ avoids\ \ peaks\ and\ valleys.\ A\ hard\ hike\ goes\ down\ 
              the\ deepest\ valleys\ and\ over\ the\ highest\ peaks.
2)\)\ An
          \ easy\ hike\ is\ one\ that\ avoids\ any\ steep\ steps\ either\ up\ 
          or\ down.\ A\ hard\ hike\ seeks\ out\ the\ steepest\ steps.
3)\)\ 
      All\ \ hikes\ try\ to\ get\ to\ the\ \ destination\ is\ the\ fewest\ 
      number\ of\ steps.\ 
Your\ job\ is\ to\ find\ the\ easiest\ and\ 
      hardest\ hike\ through\ the\ Grand\ \(Canyon.\)\ 
		\)\)

The Grand Canyon is a square array, GC, of elevations. A Hike from one corner to the opposite corner of the GrandCanyon, is a list of coordinates {i,j} starting at {1,1} ending at {n,n}and connected by East-West or North-South steps.   Here is the formal definition of properties of a hike according to the description above.

1) peak= Max[GC[[#[[1]],#[[2]]]]- GC[[1,1]] & /@ Hike]
    valley=  Min[GC[[#[[1]],#[[2]]]]- GC[[1,1]] & /@ Hike]
  An easy hike should have the lowest possible (Max[peak,Abs[valley]])
  A hard hike should have the highest possible peak and lowest possible valley.  
  
2) If more than one hike has the same value for 1), then check for steepness.   
     steepness =Max[Abs[#[[1]]-#[[2]]]&/@ Partition[GC[[#[[1]],#[[2]]]]& /@ Hike ,{2},{1}]]
     An easy hike has the smallest value for steepness as possible. A hard hike has the highest value.
     
3) If more than one hike scores the same on 1) and 2) then check the hike length.
     Make Length[Hike] as small as possible for both the easy and the hard hike.

If there is more than one hike that is easy ( or hard)  in  the sense of 1, 2,and 3 then pick one. Report the Hike, and its degree of difficulty.
{Hike, peak, valley, steepness,  length}. Find the easiest and hardest hike in the Grand Canyon.

Use the following topological map for the Grand Canyon with n=30.

f[x_, y_] := 5*(Sin[3.*x + y]*Cos[x - 4.*y] + Sin[x*y]*Cos[3.*x/y])
GC = Transpose[Table[Floor[f[x, y]], {x, 1, 30}, {y, 1, 30}]];

Plot3D[f[x, y], {x, 1, 30}, {y, 1, 30}, PlotPoints -> 12]

ContourPlot[f[x, y], {x, 1, 30}, {y, 1, 30}]

ListDensityPlot[GC, Frame -> False]

peak = Max[(GC[[#1[[1]],#1[[2]]]] - GC[[1,1]] & ) /@ Hike]

valley = Min[(GC[[#1[[1]],#1[[2]]]] - GC[[1,1]] & ) /@ Hike]

steepness = Max[(Abs[#1[[1]] - #1[[2]]] & ) /@ 
    Partition[(GC[[#1[[1]],#1[[2]]]] & ) /@ Hike, {2}, {1}]]

Here is a random hike through the Grand Canyon.

Length[Hike]

An incentive.

To add a some incentive to you hikers out there, I will award a book on great hikes in the Grand Canyon to the person who submits the best solution  --  a function than finds one of the easiest hikes and does it the fastest. The deadline, is one month after this issue appears. Enjoy the walk.

A PREVIOUS PROBLEM

Show me the pearls!

Have you got a Mathematica Pearl burried in your  files?  I invite you to share them in this column and add them to our string. If you have the goods, then send them along to piele@uwp.edu.