Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
repository:triathlete_s_dilemma [2021/01/27 18:26]
porcaro1 [Activity]
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 86: Line 88:
 ===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. 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: Extension Solutions:
Line 94: Line 98:
  
 ===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
  
Line 141: Line 145:
 ---- ----
 ====See Also==== ====See Also====
-  *+  *[[inner_tube_river_crossing | Inner Tube River Crossing]]
   ​   ​
  • repository/triathlete_s_dilemma.1611772008.txt.gz
  • Last modified: 2021/01/27 18:26
  • by porcaro1