double and triple integrals the expression looks somewhat different from ( )but that is because of the notationsince we integrate in the direction and will have to work with both and as coordinateswe must use ny for nhy for hand the counter is more naturally called when integrating in integrals in the direction will use hx and nx for and nand as counter rb the double integral is /dxwhich can be approximated by the midpoint methodzb nx /dx hx xi /xi hx ihx putting the formulas togetherwe arrive at the composite midpoint method for double integralzb zd xy/dydx hx nx ny hy xi yj hy hx hx hy ac ihx hy nx ( direct derivation the formula ( can also be derived directly in the twodimensional case by applying the idea of the midpoint method we divide the rectangle oeaboecd into nx ny equal-sized cells the idea of the midpoint method is to approximate by constant over each celland evaluate the constant at the midpoint cell ij occupies the area oea ihx /hx oec hy /hy and the midpoint is xi yj with xi ihx hx yj hy hy the integral over the cell is therefore hx hy xi yj /and the total double integral is the sum over all cellswhich is nothing but formula ( programming double sum the formula ( involves double sumwhich is normally implemented as double for loop python function implementing ( may look like def midpoint_double (fabcdnxny)hx ( )/float(nxhy ( )/float(nyi for in range(nx)for in range(ny)xi hx/ *hx yj hy/ *hy +hx*hy* (xiyjreturn