For this homework assignment, use the golden section search function you developed in Lab #7 to solve the problem below. This homework is due Monday, 6 Apr.
If a water hose, with initial water velocity v, is aimed at an angle
α with respect to the ground to splash a flower at height h,
then the horizontal distance from nozzle to flower satisfies the
quadratic equation:
(g/(2v² cos² α)) x² - (tan α) x + h =
0,
where g = 9.81 m/s².
To do this it is a good idea to plot the
function first. So what function are we trying to plot? We want to
maximize x, but we're maximizing it with respect to α. We
first need to re-write our equation a bit. It's not directly the
one we're given in the
problem that we're optimizing; rather, it's the solutions to the
quadratic equation that we're optimizing! So we write a new
function:
x = ( -B ± (B² - 4AC)½ ) / 2A
where A = g/(2v² cos² α), B = tan α and C = h.
Since we're trying to maximize x w.r.t. α, and our golden section search gives us minima, we should optimize the oposite of the function. When we plot this function, notice that we don't get real roots until ~54°. The imaginary solutions correspond to the angles α at which the water never makes it to a height h. We can ignore the negative branch of the solutions, since -B + ... will always be larger than -B - .... Another way of looking at this is to see that the negative branch gives the range x for height h on the way up, and the positive branch for on the way down.
See the plot below (for the record, I give both the positive and negative branches of the solution) and code for details. From it we find that α ≈ 59.8°, giving xmax ≈ 23.7 m.