re write equations to compile with templates