According to the formula:
$$M = m/MV$$
where:
- M is the molarity of the solution (in mol/L)
- m is the mass of the solute (in g)
- V is the volume of the solution (in L)
Let's solve the equation for m:
$$m = MV$$
$$m = (0.4 \text{ mol/L})(500 \text{ mL})$$
$$m = (0.4 \text{ mol/L})(0.5 \text{ L})$$
$$m = 0.2 \text{ mol}$$
Finally, we convert moles to grams:
$$m = (0.2 \text{ mol})(40 \text{ g/mol})$$
$$m = 8 \text{ g}$$
Therefore, 8 grams of solid NaOH are needed to prepare 500mL of a 0.4M solution.