A physics-based Lagrangian for the heat-diffusion equation