Total parts in the 1:3 ratio = 1 + 3 = 4 parts
One part = 12 liters / 4 parts = 3 liters
Initial apple juice: 1 part * 3 liters/part = 3 liters
Initial carrot juice: 3 parts * 3 liters/part = 9 liters
Let 'x' be the amount of mixture to be replaced.
After replacing 'x' liters of the mixture with 'x' liters of apple juice, we have:
Apple juice: 3 - (x/4) + x = 3 + (3x/4)
(We subtract x/4 because the removed mixture contains 1/4 apple juice. We add x because we're adding pure apple juice.)
Carrot juice: 9 - (3x/4) (We subtract 3x/4 because the removed mixture contains 3/4 carrot juice.)
The new ratio of apple juice to carrot juice is 3:1, so:
[3 + (3x/4)] / [9 - (3x/4)] = 3/1
Simplify and solve for 'x':
3 + (3x/4) = 27 - (9x/4)
3x + 9x = 108 - 12
12x = 96
x = 8