# herb miller

WordPress plugin specialist

• ## H2GD Part 49: Crocodile maths question – PHP solution

Here’s a little bit of PHP that helps you to solve the Crocodile maths question.

### Problem

A crocodile is stalking prey located 20 metres further upstream on the opposite bank of a river.

Crocodiles travel at different speeds in land and in water.

The time taken for the crocodile to reach its prey can be minimised if it swims to a particular point, P, x metres upstream on the other side of the river as shown in the diagram.

The time taken, T, measured in tenths of a second, is given by

`T(x) = 5 x sqrt( 36 + x squared ) + 4 ( 20 - x )`
a. i
Calculate the time taken if the crocodile does not travel on land.
a. ii
Calculate the time taken if the crocodile swims the shortest distance possible.
b.
Between these two extremes there is one value x which minimises the time taken. Find this value of x and calculate the minimum possible time.

You appear to be a bot. Output may be restricted

Sourcefile not defined for 19548bw_api cannot determine the funcname \$inc = 1; \$mint = 999; for ( \$x = 0; \$x <= 20; \$x += \$inc ) { \$t = ( 5 * sqrt( \$x*\$x + 36 )) + (4 * ( 20 - \$x )); echo number_format( \$x, 1) . " " . number_format( \$t, 2 ). PHP_EOL; if ( \$t < \$mint ) { \$mint = \$t; \$minx = \$x; } } echo "Minimum t: \$mint" . PHP_EOL; echo "for x: \$minx" . PHP_EOL; [/bw_api] Output [bw_geshi none] C:\apache\htdocs\wordpress\wp-content\plugins\play>php croc.php 0.0 110.00 1.0 106.41 2.0 103.62 3.0 101.54 4.0 100.06 5.0 99.05 6.0 98.43 7.0 98.10 8.0 98.00 9.0 98.08 10.0 98.31 11.0 98.65 12.0 99.08 13.0 99.59 14.0 100.16 15.0 100.78 16.0 101.44 17.0 102.14 18.0 102.87 19.0 103.62 20.0 104.40 Minimum t: 98 for x: 8 [/bw_geshi]

a. i
If the crocodile does not travel on land then it swims all the way. `x=20` so `t=104.4`
a. ii
The shortest distance to swim is straight across. `x=0` so `t=110.0`
b
The minimum value for t is `98.0` – when `x=8`.

• In this problem we ignore negative values for the square root
• We assume that either the stream is not flowing or the crocodile’s speed in water has been taken into account in the formula
• We assume the zebra is too stupid to run away
• I do hope I’ve got the answers right

BTW: I’ve not watched this video yet

#### A few minutes later…

OK, I’ve watched the video now.

• My answers are in tenths of a second
• I didn’t do the maths
• I just got a computer to do the sums
• In my opinion the program was easier than the maths

Published:

Last updated:

October 13, 2015

### Tide times from tidetimes.co.uk

Tide Times & Heights for Northney on
Friday, 15 October 2021

### Tide times from tidetimes.org.uk

Tide Times & Heights for Northney on
15th October 2021
00:53 Low Tide ( 1.54m )
08:03 High Tide ( 3.76m )
13:29 Low Tide ( 1.67m )
20:34 High Tide ( 3.66m )