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
Next revision Both sides next revision
repository:triathlete_s_dilemma [2021/01/27 01:50]
porcaro1 [Activity]
repository:triathlete_s_dilemma [2021/01/27 01:55]
porcaro1 [Answer Key]
Line 29: Line 29:
 You will examine your total time results graphically. Notice in the code, that the graph commands are already there, but the graph won't be generated until you produce some data. Your "​while"​ loop should include a calculation for the swim time, run time, and total time for each half-meter position along the beach. Your graph will plot corresponding shore positions versus total time. You will examine your total time results graphically. Notice in the code, that the graph commands are already there, but the graph won't be generated until you produce some data. Your "​while"​ loop should include a calculation for the swim time, run time, and total time for each half-meter position along the beach. Your graph will plot corresponding shore positions versus total time.
  
-Extension ​Questions:+Extension ​questions:
   - How could you modify your code to get greater precision in your answer? What specific changes would you make?   - How could you modify your code to get greater precision in your answer? What specific changes would you make?
   - What happens to the critical shore point if you swim faster?   - What happens to the critical shore point if you swim faster?
Line 83: Line 83:
 ====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.
 +
 +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=""​]>​
  • repository/triathlete_s_dilemma.txt
  • Last modified: 2021/02/16 23:53
  • by porcaro1