A ship leaves port and travels 21km on a bearing of 032° and then 45km on a bearing of 287°.

(a) calculate the distance from the port
(b) calculate the bearing of the port from the ship

First, let's sketch the situation:

```
032°
|
|
21 km |____________
| 287°
|
|
|
```

(a) To find the distance from the port, we can use the Pythagorean theorem to add up the horizontal and vertical distances traveled:

```
^
21 km | 45 km
---------+--------->
|
| | |
| A | B |
| | |
v-------+-------v
```

In triangle A, we have:
- Angle C = 90° (as a right angle)
- Angle A = 90° - 32° = 58° (angles in a triangle add up to 180°)
- Side a = 21 km (given)

We can use the sine function to find side b:

sin A = b / c
sin 58° = b / c
b = c * sin 58°

In triangle B, we have:
- Angle D = 90° (as a right angle)
- Angle E = 180° - 287° = 93° (angles in a triangle add up to 180°)
- Side e = 45 km (given)

We can use the sine function to find side d:

sin E = d / f
sin 93° = d / f
d = f * sin 93°

Now, we can add up the horizontal distances (b + d) and the vertical distances (a + e) to find the total distance:

distance = √((b + d)² + (a + e)²)
distance = √((21 * sin 58° + 45 * sin 93°)² + (21 * cos 58° + 45 * cos 93°)²)
distance ≈ 55.5 km

Therefore, the ship is about 55.5 km away from the port.

(b) To find the bearing of the port from the ship, we can use the inverse tangent function to find the angle between the ship's position and the port:

```
^
21 km | 45 km
---------+--------->
|
| | θ |
| A | B |
| | |
v-------+-------v
```

In triangle A, we have:
- Angle C = 90° (as a right angle)
- Angle A = 90° - 32° = 58° (angles in a triangle add up to 180°)
- Side a = 21 km (given)
- Side b = distance from part - 45km

We can use the inverse tangent function to find angle θ:

tan θ = a / b
θ = atan(a / b)

θ = atan(21 / (55.5 - 45))
θ ≈ 50.3°

Therefore, the bearing of the port from the ship is approximately 50.3°.

To solve this problem, we can break it down into two parts: calculating the coordinates of the ship after each leg of the journey, and then using those coordinates to find the distance and bearing.

Step 1: Calculating the coordinates after each leg
For the first leg, traveling 21km on a bearing of 032°:
- We can use trigonometry to calculate the change in coordinates.
- The x-coordinate will change by 21km × cos(32°), and the y-coordinate will change by 21km × sin(32°).
- Let's assume the initial coordinates of the ship are (0,0), so after the first leg, the coordinates will be (21 × cos(32°), 21 × sin(32°)).

For the second leg, traveling 45km on a bearing of 287°:
- Again, we can use trigonometry to calculate the change in coordinates.
- The x-coordinate will change by 45km × cos(287°), and the y-coordinate will change by 45km × sin(287°).
- Adding the changes from both legs to the initial coordinates, we get the final coordinates of the ship.

Step 2: Calculating the distance and bearing
- Using the final coordinates of the ship, we can calculate the distance from the port using the distance formula (d = sqrt((x2-x1)^2 + (y2-y1)^2)).
- To find the bearing of the port from the ship, we can use trigonometry again. The bearing is the angle between the positive x-axis and the line connecting the ship and the port.

Let's calculate the coordinates and then the distance and bearing:

Coordinates after the first leg:
x1 = 21 × cos(32°) ≈ 17.86 km
y1 = 21 × sin(32°) ≈ 11.31 km

Coordinates after the second leg:
x2 = x1 + 45 × cos(287°) ≈ 41.61 km
y2 = y1 + 45 × sin(287°) ≈ 7.68 km

Distance from the port:
d = sqrt((x2-x1)^2 + (y2-y1)^2)
= sqrt((41.61-17.86)^2 + (7.68-11.31)^2)
≈ sqrt(622.81 + 14.32)
≈ sqrt(637.13)
≈ 25.23 km

Bearing of the port from the ship:
- We can use the arctan2 function to find the angle between the positive x-axis and the line connecting the ship and the port.
- The bearing is given as an angle clockwise from the north, so we need to adjust the angle accordingly.
- Let's call the angle between the positive x-axis and the line connecting the ship and the port as θ.
- θ = arctan2(y2-y1, x2-x1) ≈ arctan2(7.68-11.31, 41.61-17.86)
- Now we adjust θ by adding 90° to get the bearing.
- Bearing = (θ + 90°) ≈ (68.95° + 90°) ≈ 158.95°

Therefore:
(a) The distance from the port is approximately 25.23 km.
(b) The bearing of the port from the ship is approximately 158.95°.