  First-principles calculations are presented for the layered perovskite
Ca$_3$Mn$_2$O$_7$. The results reveal a rich set of coupled structural,
magnetic and polar domains in which oxygen octahedron rotations induce
ferroelectricity, magnetoelectricity and weak-ferromagnetism. The key point is
that the rotation distortion is a combination of two non-polar modes with
different symmetries. We use the term "hybrid" improper ferroelectricity to
describe this phenomenon and discuss how control over magnetism is achieved
through these functional antiferrodistortive octahedron rotations.
