f[x_]:=x^2;
p:=Module[{},a=1;b=3;
    h=(b-a)/n;
    t=Table[ListPlot[{{a+h(i-1),0},{a+h i,0},{a+h i,f[a+h (i-0.5)]},
               {a+h(i-1),f[a+h (i-0.5)]},{a+h(i-1),0}},
                PlotJoined->True,DisplayFunction->Identity],{i,1,n}];
    bild1=Show[t];
    bild2=Plot[f[x],{x,a,b},PlotStyle->Dashing[{0.01}],
           DisplayFunction->Identity];
    abb=Show[{bild1,bild2},Ticks->None]
];
n=4;p;abb1=abb;
n=8;p;abb2=abb;
n=16;p;abb3=abb;
n=32;p;abb4=abb;
bild=Show[GraphicsArray[{{abb1,abb2},{abb3,abb4}},
          DisplayFunction->$DisplayFunction,
          ImageSize->{400,300}]];