Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
repository:triathlete_s_dilemma [2021/01/27 00:40]
porcaro1 created
repository:triathlete_s_dilemma [2021/02/16 23:53] (current)
porcaro1 [See Also]
Line 18: Line 18:
 ===Handout=== ===Handout===
 ** Triathlete'​s Dilemma **  ** Triathlete'​s Dilemma ** 
 +
 +{{ :​repository:​triathlete.png?​nolink&​600|}}
  
 You are a triathlete in the water and you need to get to your bike parked in a rack at a specific location on the shore in the shortest amount of time possible. You can run faster than you can swim. Do you swim directly to the shore, then run to your bike? Do you swim to a point closer to your bike, then run? How do you solve this dilemma? Here are the specific parameters: You are a triathlete in the water and you need to get to your bike parked in a rack at a specific location on the shore in the shortest amount of time possible. You can run faster than you can swim. Do you swim directly to the shore, then run to your bike? Do you swim to a point closer to your bike, then run? How do you solve this dilemma? Here are the specific parameters:
Line 33: Line 35:
   - What happens to the critical shore point if you swim faster?   - What happens to the critical shore point if you swim faster?
   - What happens if you change this situation? Suppose it's a sea lion in the water trying to get to the bike! Reverse your original speeds—Make the swim speed 9 m/s and the run speed 2 m/s. What is the new shore point for the fastest travel time now?   - What happens if you change this situation? Suppose it's a sea lion in the water trying to get to the bike! Reverse your original speeds—Make the swim speed 9 m/s and the run speed 2 m/s. What is the new shore point for the fastest travel time now?
 +  - Use the accompanying picture below to help answer this question. The distance from the shoreline to the swimmer (a) is 65 m. The distance from the shoreline to the bike (b) is 83 m. The sum of (x) and (y) is 135 m. The person can swim at 1.56 m/s and can run at 8.75 m/s. Solve for (x) to produce the shortest time possible to get your starting point in the water to your bike.
 +
 +{{ :​repository:​triathletemod.png?​nolink&​600 |}}
  
 ===Code=== ===Code===
Line 51: Line 56:
 starttext = text(pos=vec(-65,​130,​0),​ text='​Start',​ depth=2, height=10, color=color.green) starttext = text(pos=vec(-65,​130,​0),​ text='​Start',​ depth=2, height=10, color=color.green)
 endtext = text(pos=vec(90,​-70,​0),​ text='​End',​ depth=2, height=10, color=color.red) ​ endtext = text(pos=vec(90,​-70,​0),​ text='​End',​ depth=2, height=10, color=color.red) ​
-  
    
 #Initial swim speed and run speed #Initial swim speed and run speed
Line 63: Line 67:
  
 #this draws a line from start to shore point and from shore point to end #this draws a line from start to shore point and from shore point to end
-shorepoint ​= 0 +target ​= 0 
-swimroute = cylinder(pos=vec(start.pos.x,​start.pos.y,​1),​ axis=vector(shorepoint-start.pos.x,​0-start.pos.y,​1),​ radius=1, color=color.green) +swimroute = cylinder(pos=vec(start.pos.x,​start.pos.y,​1),​ axis=vector(target-start.pos.x,​0-start.pos.y,​1),​ radius=1, color=color.green) 
-runroute = cylinder(pos=vec(end.pos.x,​end.pos.y,​1),​ axis=vec(shorepoint-end.pos.x,​0-end.pos.y,​1),​ radius=1, color=color.red)+runroute = cylinder(pos=vec(end.pos.x,​end.pos.y,​1),​ axis=vec(target-end.pos.x,​0-end.pos.y,​1),​ radius=1, color=color.red)
  
 ##graph total time vs shore point position ##graph total time vs shore point position
Line 71: Line 75:
 TimeOpt = gcurve(color=color.red,​ label='​Optimal Path') TimeOpt = gcurve(color=color.red,​ label='​Optimal Path')
  
- +while target<0:
-while shorepoint<0:+
     rate(120)     rate(120)
     swimtime =      swimtime = 
     runtime =      runtime = 
     totaltime = swimtime+runtime     totaltime = swimtime+runtime
-    swimroute.axis = vec(shorepoint-start.pos.x,​0-start.pos.y,​1) +    swimroute.axis = vec(target-start.pos.x,​0-start.pos.y,​1) 
-    runroute.axis = vec(shorepoint-end.pos.x,​0-end.pos.y,​1)+    runroute.axis = vec(target-end.pos.x,​0-end.pos.y,​1)
     TimeOpt.plot(target,​totaltime)     TimeOpt.plot(target,​totaltime)
     target = target + dt </​code>​     target = target + dt </​code>​
Line 84: Line 87:
 ====Answer Key==== ====Answer Key====
 ===Handout=== ===Handout===
 +Our first modifications to the code are defining the variables "​target"​ (line 22), and "​final"​ (line 24). This represents at which x-coordinate you reach the shore and the x-coordinate of the bike rack, respectively. We add the variable "​dt"​ (line 23) which is a miniscule increment in time, and used later in our while loop. We then create equations for the "​swimtime"​ and "​runtime"​ variables (lines 25 & 26); these equations are just a rearranged form of the Pythagorean Theorem solved for the length of the hypotenuse and divided by the swim speed and run speed variables—remember that distance divided by speed is time. Finally, the limits of the while loop are defined (line 35) and the swim time and run time equations are reentered (lines 37 & 38). Looking at the output graph, the optimal x-coordinate along the shore line is equal to -24.5.
 +
 +{{ :​repository:​triathlete_graph.png?​nolink&​600 |}}
 +
 +Extension Solutions:
 +  - In order to increase the precision of your answer, you can decrease the size of the "​dt"​ variable. The smaller this variable, the more points along the graph the program will plot, and thus the more precise you can be with your answer. An exact answer, however, requires calculus to solve.
 +  - The faster the swim speed, the further in the positive x-direction your critical shore point will be
 +  - For the theoretical sea lion situation where the speeds are flipped, the new shore point is the x-coordinate equal to 91.0, with a total travel time of 45.97 seconds. You can find this by simply modifying lines 18 and 19.
 +  - To solve this question graphically,​ you simply have to modify the "​start"​ and "​end"​ variables (lines 12 & 13) to match the new distances provided in the problem statement. As well, you have to adjust the "​swimv"​ and "​runv"​ variables to the new given speeds. Depending on how small you make your "​dt"​ variable, the optimal shore critical point (x) approaches 9.77 meters.
 +
 ===Code=== ===Code===
-<code Python [enable_line_numbers="​true",​ highlight_lines_extra=""​]>​+<code Python [enable_line_numbers="​true",​ highlight_lines_extra="​22,​23,​24,​25,​26,​35,​37,​38"]>
 GlowScript 2.8 VPython GlowScript 2.8 VPython
  
 +#scene attributes
 scene.width = 750 scene.width = 750
 scene.height = 568 scene.height = 568
 scene.fov = .3 scene.fov = .3
 scene.align = "​left"​ scene.align = "​left"​
 +
 ## Objects for the lake and beach ## Objects for the lake and beach
 lake = box(pos=vector(0,​100,​0),​ size=vector(300,​200,​2),​ axis=vector(1,​0,​0),​ color=color.cyan,​ texture=textures.rough) lake = box(pos=vector(0,​100,​0),​ size=vector(300,​200,​2),​ axis=vector(1,​0,​0),​ color=color.cyan,​ texture=textures.rough)
Line 100: Line 115:
 endtext = text(pos=vec(90,​-70,​0),​ text='​End',​ depth=2, height=10, color=color.red) endtext = text(pos=vec(90,​-70,​0),​ text='​End',​ depth=2, height=10, color=color.red)
    
-  +#Initial swim speed and run speed 
- ##The next calculations involve moving a test charge around the fixed charges ​to find the position where the force acting on the test charge is zero:+swimv = 2 
 +runv = 9 
 + 
 +#Calculations ​to determine ​the amount of time for swim and amount of time for run--think distance/​speed...
 target = -50 target = -50
 dt = 0.5 dt = 0.5
 final = 100 final = 100
-swimv = 2 
-runv = 9 
-#For the shoreline on the y-axis: 
 swimtime = sqrt(start.pos.y**2 + (target-start.pos.x)**2)/​swimv swimtime = sqrt(start.pos.y**2 + (target-start.pos.x)**2)/​swimv
 runtime = sqrt(end.pos.y**2 + (end.pos.x-target)**2)/​runv runtime = sqrt(end.pos.y**2 + (end.pos.x-target)**2)/​runv
Line 113: Line 128:
 swimroute = cylinder(pos=vec(start.pos.x,​start.pos.y,​1),​ axis=vector(target-start.pos.x,​0-start.pos.y,​1),​ radius=1, color=color.green) swimroute = cylinder(pos=vec(start.pos.x,​start.pos.y,​1),​ axis=vector(target-start.pos.x,​0-start.pos.y,​1),​ radius=1, color=color.green)
 runroute = cylinder(pos=vec(end.pos.x,​end.pos.y,​1),​ axis=vec(target-end.pos.x,​0-end.pos.y,​1),​ radius=1, color=color.red) runroute = cylinder(pos=vec(end.pos.x,​end.pos.y,​1),​ axis=vec(target-end.pos.x,​0-end.pos.y,​1),​ radius=1, color=color.red)
 +
 ##graph net force vs position ##graph net force vs position
- 
 Grph1 = graph(title='​Finding Optimal Path', xtitle='​Shoreline Coordinate (m)', ytitle='​Total Time (s)', fast=False, align="​right",​ ymin=0, ymax=300, xmin=-50, xmax=100) Grph1 = graph(title='​Finding Optimal Path', xtitle='​Shoreline Coordinate (m)', ytitle='​Total Time (s)', fast=False, align="​right",​ ymin=0, ymax=300, xmin=-50, xmax=100)
 TimeOpt = gcurve(color=color.red,​ label='​Optimal Path') TimeOpt = gcurve(color=color.red,​ label='​Optimal Path')
- 
  
 while target<​final:​ while target<​final:​
Line 131: Line 145:
 ---- ----
 ====See Also==== ====See Also====
-  *+  *[[inner_tube_river_crossing | Inner Tube River Crossing]]
   ​   ​
  • repository/triathlete_s_dilemma.1611708037.txt.gz
  • Last modified: 2021/01/27 00:40
  • by porcaro1