A boat goes 12 km upstream and 40 km downstream in 8 hours. It can go 16 km upstream and 32 km downstream is the same time. Find the speed of the boat in still water and the speed of the stream.

if the bot has speed b, and the stream has speed s, then since time=distance/speed,

12/(b-s) + 40/(b+s) = 8
16/(b-s) + 32/(b+s) = 8
b=6
s=2

check:
12/4 + 40/8 = 3+5 = 8
16/4 + 32/8 = 4+4 = 8

To solve this problem, let's assume the speed of the boat in still water is "b" km/h and the speed of the stream is "s" km/h.

When the boat travels upstream, the effective speed is reduced by the speed of the stream, so its speed relative to the shore is (b - s) km/h. On the other hand, when the boat travels downstream, the speed is increased by the speed of the stream, so its speed relative to the shore is (b + s) km/h.

Now, let's analyze the information given in the problem.

For the first scenario:
- The boat goes 12 km upstream and 40 km downstream in a total of 8 hours.
- The time spent going upstream is 12/(b - s), and the time spent going downstream is 40/(b + s).
- The total time spent is 8 hours, so we can set up the equation: 12/(b - s) + 40/(b + s) = 8.

For the second scenario:
- The boat goes 16 km upstream and 32 km downstream in the same amount of time as the first scenario.
- The time spent going upstream is 16/(b - s), and the time spent going downstream is 32/(b + s).
- The total time spent is also 8 hours, so we can set up the equation: 16/(b - s) + 32/(b + s) = 8.

Now, we can solve these two equations to find the values of "b" and "s".

By simplifying the first equation, we get:
12(b + s) + 40(b - s) = 8(b^2 - s^2).
Expanding and rearranging the terms, we get:
12b + 12s + 40b - 40s = 8b^2 - 8s^2.
Simplifying further, we have:
52b - 28s = 8b^2 - 8s^2.

Similarly, by simplifying the second equation, we get:
16(b + s) + 32(b - s) = 8(b^2 - s^2).
Expanding and rearranging the terms, we get:
16b + 16s + 32b - 32s = 8b^2 - 8s^2.
Simplifying further, we have:
48b - 16s = 8b^2 - 8s^2.

Now, we have a system of equations with two variables:
52b - 28s = 8b^2 - 8s^2 ................(1)
48b - 16s = 8b^2 - 8s^2 ................(2)

To solve this system of equations, we can subtract equation (2) from equation (1):
(52b - 28s) - (48b - 16s) = (8b^2 - 8s^2) - (8b^2 - 8s^2)
4b - 12s = 0
4b = 12s
b = 3s

Now, we substitute the value of "b" in terms of "s" into either equation (1) or (2). Let's use equation (1):
52(3s) - 28s = 8(9s^2) - 8s^2
156s - 28s = 72s^2 - 8s^2
128s = 64s^2
8s = 4s^2
2 = s

Finally, substituting the value of "s" into either equation (1) or (2), we can find the value of "b":
b = 3s
b = 3(2)
b = 6

Therefore, the speed of the boat in still water is 6 km/h, and the speed of the stream is 2 km/h.