I have my two mandarins in a 20 gallon long with plenty of live rock, established for 2 years, and given a cyclopeeze/ova shot two to three times a day. i change 10 % water two times a week because of the feeding routine.
So you can definitely have a pair in a 30g or 40. You just have to make sure they are eating, and that you feed them plenty of food that they eat, and you do lots of water changes. These fish need t a lot of work to keep well. mike