 
Anthony T. answered  10/27/21
Patient Science Tutor
The acid present in the stomach is HCl.
The balanced reactions for each are
NaHCO3 + HCl ======> H2CO3 + NaCl where H2CO3 is a weak acid.
Mg(OH)2 + 2HCl ======> MgCl2 + 2H2O
1 g of NaHCO3 has 1 / 84 = 0.012 moles which is equal to the moles of HCl neutralized.
1 g of Mg(OH)2 has 1 / 58 = 0.017 moles but neutralizes 2 x 0.017 moles HCl = 0.034 moles HCl
Mg(OH)2 is the more effective antacid per gram.
I rounded the formula weights of NaHCO3 and Mg(OH)2 to whole numbers.
 
     
             
                     
                    