The background is that I'm solving a problem in Numerical Analysis which I asked about here: Is my derivate correctly programmed?
Now if I use the new code, then I get a result that is along the expectations ("You should find that the depth at xf = 25 nautical miles is close to 2500 feet.") but why is the sound wave changing direction, it seems like it is first travelling downward, then upward and then changing direction again. Is that really realistic for a sound wave under the water or do I have an error somewhere in my model?

I have validated your solution with the following code:
As far as it being physically meaningful, I do not know. Nevertheless, the code above matches your paper and the solution it yields matches as well.