The mathematics of finite elements and applications