When gender matters: a study of gender differences in mathematics