The rule of three is a way to solve problems of proportionality between three known values and one unknown. This is an operation of finding the fourth term of a proportion knowing the other three.
We can use the rule of three to solve this problem in this way,
500 mL → 6 grams
40 mL → x
This is the same as saying: if in 500 mL there should be 6 grams of agarose powder then in 40 mL how many grams should there be?
So,
→ x = 0.48 g = 480 mg
Then, you need to dissolved 480 mg of agarose powder in 40 mL of water to meet the recipe.