For the purpose of answering this type of question I consider a chemical solution to consist of two materials in liquid form. Then I think of the materials as each being represented by a quantity of balls of the same colour. One of the balls (say, a quantity of white balls of water) is the solvent and the other, the solute, is represented by a quantity of black balls. The strength of the solution is the percentage of black balls in the mixture. Call the quantity of each w and b. A 10% solution consists of 9v/10 white balls and v/10 black balls, where v is the volume, so we can write 9vw/10+bv/10=v(9w/10+b/10) as the 10% solution of v gallons. We can also write 30(60w/100+40b/100)=30(3w/5+2w/5) as 30 gallons of the 40% solution, so 30(3w/5+2b/5)+v(9w/10+b/10)=(v+30)(3w/4+b/4), which is the 25% strength solution, where there is 75% solvent and 25% solute. This equation simplifies to 18w+12b+v(9w/10+b/10)=(v+30)(3w/4+b/4)
Multiply through by 20 to get rid of the fractions: 360w+240b+2v(9w+b)=5(v+30)(3w+b). This expands to 360w+240b+18vw+2vb=15vw+5vb+450w+150b. We're looking for v, so we get all the terms containing v together: 3vw-3vb=90w-90b, so v=90(w-b)/(3(w-b))=30. Therefore, 30 gallons of 10% solution are required to reduce the 30 gallons of 40% solution to 25% strength.