20 L at 20% implies that there is 20 * .2 = 4 L of pure in your bottle.

You want to have 20 * .4 = 8 L of pure in the bottle to get 40%.

let x = amount of solution to drain and y = amount of pure to add.

20L solution * (.2 pure/solution) - xL solution*(.2 pure/solution) + yL solution(1 pure/solution) = 20L solution * .4 pure/solution.

4 - 1/5x + y = 8

-1/5 x + y = 4

y = 1/5x + 4

This formula does not take into account that we want to have 20L of solution at the end. We need to solve for x and y such that x = y, so that the end volume is the same as the start volume.

y = 1/5x + 4

-y = -x

-----------------

0 = -4/5x + 4

4/5x = 4

x = 5

So drain 5 liters and add 5 liters of pure.

verification:

start with 4 L pure in 20 L solution. Drain 5 liters, resulting in 4 - 5 * .2 = 3 L pure in 15 L of solution. Add 5 L pure resulting in 8 L pure in 20 L solution.

High school algebra in the hizouse!