The context can be modelled by a general equation:

#% "alcohol"="gal alcohol"/"gal solution"#

Using the example, #40% "alcohol"=("2 gal alcohol")/("5 gal")*100%#, we can set up another equation to solve for the number of galloons added.

Let #x# be the number of gallons added.

#25% "alcohol"=("2 gal alcohol")/("5 gal water"+"x gal water")*100%#

#25% "alcohol"color(red)(-:100%)=("2 gal alcohol")/("5 gal water"+"x gal water")*100%color(red)(-:100%)#

#0.25# #"alcohol"=("2 gal alcohol")/("5 gal water"+"x gal water")#

#0.25# #"alcohol"*("5 gal water"+"x gal water")="2 gal alcohol"#

#0.25# #"alcohol"color(red)(-:0.25)##color(red)("alcohol")*("5 gal water"+"x gal water")="2 gal alcohol"color(red)(-:0.25)##color(red)("alcohol")#

#"5 gal water+"x"# #"water"# #"gal"="8# #"gal"#

#"x gal water"##=## "3 gal water"#

#:.#, #3# gallons of water must be added.