Lower Sum

Author

Eric W. Weisstein
April 14, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Calculus/LowerSum.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/LowerSum.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

LowerSum::usage="LowerSum[f,{x,a,b,dx}] plots the lower sum of the function f[x] between
x=a and b for a step size of dx."

Off[FindMinimum::fmgz,FindMinimum::fmlim,FindMinimum::regex];

Off[FindMinimum::"reged"];

MinValue[f_,{x_,a_,b_}]:=Module[{min=Check[FindMinimum[f,{Global`x,a,a,b}],$Failed]},If[ListQ[min],Min[f/.Global`x->a,f/.Global`x->b,min[[1]]],Min[f/.Global`x->a,f/.Global`x->b]]]

MaxValue[f_,{x_,a_,b_}]:=Module[{},-MinValue[-f,{x,a,b}]]

MinCoords[f_,{a_,n_,dx_}]:=Module[{m=MinValue[f,{x,a+n dx,a+(n+1)dx}]},{{a+n dx,0},{a+n dx,m},{a+(n+1) dx,m},{a+(n+1)dx,0}}]

line[l_List]:=Module[{},Line[Append[l,l[[1]]]]]

LowerBlocks[f_,{x_,a_,b_,dx_}]:=Module[{n},Table[{{GrayLevel[.5],Polygon[MinCoords[f,{a,n,dx}]]},line[MinCoords[f,{a,n,dx}]]},{n,0,(b-a)/dx-1}]]

LowerSum[f_,{x_,a_,b_,dx_}]:=Module[{},Plot[f,{x,a,b},PlotRange->All,Ticks->None,Prolog->LowerBlocks[f,{x,a,b,dx}]]]

Notes

This code should be slightly cleaned up

Plots

LowerSum[1+x^4-3x^2,{x,-1,1.9,.1}]

Show[GraphicsArray[Partition[Table[
		LowerSum[1+x^4-3x^2,{x,-1,1.9,.2/n}],{n,4}],2]]]