example 1

Clear[f,a,b,n,deltax,x,xPts]
f[x_]:= 7-x;
a=3.0;
b=5.0;

n=2;

deltax=(b-a)/n

Left endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Right endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+2) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Midpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{
{a+i deltax ,0},
{a+i deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+1.5) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{
{a+n  deltax,0},
{a+n* deltax,f[a+(n+.5)* deltax]} }] }]
  }]

example 2

Clear[f,a,b,n,deltax,x,xPts]
f[x_]:= 2x^2-2;
a=1.0;
b=4.0;

n=6;

deltax=(b-a)/n

Left endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Right endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+2) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Midpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{
{a+i deltax ,0},
{a+i deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+1.5) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{
{a+n  deltax,0},
{a+n* deltax,f[a+(n+.5)* deltax]} }] }]
  }]

example 3

Clear[f,a,b,n,deltax,x,xPts]
f[x_]:= 2x^2+2;
a=-4.0;
b=4.0;

n=12;

deltax=(b-a)/n

Left endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Right endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+2) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Midpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{
{a+i deltax ,0},
{a+i deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+1.5) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{
{a+n  deltax,0},
{a+n* deltax,f[a+(n+.5)* deltax]} }] }]
  }]

example 4

Clear[f,a,b,n,deltax,x,xPts]
f[x_]:= 2x^2+2;
a=-4.0;
b=4.0;

n=50;

deltax=(b-a)/n

Left endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+i deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Right endpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{{a+i deltax,0},{a+i deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+1) deltax]},{a+(i+1) deltax,f[a+(i+2) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{{a+n deltax,0},{a+n deltax,f[a+n deltax]} }] }]
  }]

Midpoint

Show[{Plot[f[x],{x,a,b},
PlotRange->{{a-1,b+1},{0,Automatic}},PlotStyle->{Thick,Blue}],

Table[Graphics[{Thick,Dashed,Red,Line[{
{a+i deltax ,0},
{a+i deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+.5) deltax]},{a+(i+1) deltax,f[a+(i+1.5) deltax]}}]}],{i,0,n-1}],

Graphics[{Thick,Dashed,Red,Line[{
{a+n  deltax,0},
{a+n* deltax,f[a+(n+.5)* deltax]} }] }]
  }]