The first ship's trajectory and the second ship's trajectory actually form a right angle, since one leaves at 40° and one leaves at 130°, which are 90° apart. The ships' trajectories are therefore two legs of a right triangle. If we find the hypotenuse of the right triangle after 1.5 hours, we will find the distance between the two ships.
After 1.5 hours, the first ship has gone 1.5(18) = 27 nautical miles. The second ship has gone 1.5(26) = 39 nautical miles. So, plug a = 27 and b = 39 into the Pythagorean Theorem to solve for the hypotenuse, c:
c2 = (27)2 + (39)2
c2 = 729 + 1521
c2 = 2250
c = 47.43 nautical miles apart