(*			INTEGRALE DI RIEMANN                   *)

(* f(x) monotona crescente*)
(* partizione di [a,b] uniforme *)

f[x_]:=x^2+1

?Sum

riemann[f_,a_,b_,n_]:=
{(b-a)/n * Sum[f[a+(b-a)/n*(k-1)],{k,1,n}],
(b-a)/n * Sum[f[a+(b-a)/n*k],{k,1,n}]}

(*   (Subscript[x, k]) = ((b-a)/n)*k   *)

riemann[f,0,1,3]

?N

N[riemann[f,0,1,3],20]

?Manipulate

Manipulate[N[riemann[f,0,1,n],20],{n,1,1000,1}]

?Plot

Options[Plot]

Plot[f[x],{x,0,1},ImageSize->300,AspectRatio->0.8,PlotRange->{{0,1},{0,2}}]

?Epilog

graf1r[f_,a_,b_,n_]:=Block[{lsx=Table[a+(b-a)/n*k,{k,0,n}]},
Plot[f[x],{x,0,1},ImageSize->300,PlotRange->{0,3},Epilog->Table[Line[{{lsx[[k]],0},{lsx[[k]],f[lsx[[k]]]}}],{k,1,n+1}]]
]

Manipulate[graf1r[f,0,1,h],{{h,5},1,100}]

grafr[f_,a_,b_,n_]:=Block[{lsx=Table[a+(b-a)/n*k,{k,0,n}]},
Plot[f[x],{x,0,1},ImageSize->300,PlotRange->{0,2},Epilog->{Table[Line[{{lsx[[k]],0},{lsx[[k]],f[lsx[[k]]]},{lsx[[k+1]],f[lsx[[k]]]}}],{k,1,n}],Line[{{b,0},{b,f[b]}}]}]
]

Manipulate[grafr[f,0,1,h],{{h,5},1,100,1}]

grafr[f,0,1,10]