Real Madrid closed the gap on league leaders Barcelona to seven points by securing a routine 3-1 victory over Real Sociedad at the Santiago Bernabeu.