El mar, 22-05-2007 a las 21:44 +0000, Wolfgang Lindner escribi?:
> dear group,
>
> AFAIK I have seen plots of Riemann sums using Maxima - but I don't know anymore where it
> was. I seek in the help file and the tutorials too, in vain.
> Could anyone help me, please.
>
Hi Wolfgang,
I have such a function somewhere in my web site; but it doesn't work due
to the latest changes made in plot2d. I have rewritten it so that now it
works with the draw package. I'm sure it can be improved in different
ways.
/* possible calls: */
/* riemann_sums(u^3,[u,0,5],10,'inf); */
/* riemann_sums(exp(-v^2),[v,-2,2],10,'sup); */
load(draw)$
riemann_sums(funcion,rango,n,tipo):=
block([abscisas,ordenadas,d,numer:true,ratprint:false,int,suma],
d: (rango[3]-rango[2])/n,
if not member(tipo,['sup,'inf])
then error("Incorrect type: must be 'sup or 'inf"),
abscisas: makelist(rango[2]+k*d-d/2,k,1,n),
if tipo = 'inf
then ordenadas:
makelist([k, min(ev(funcion,rango[1]=k-d/2),
ev(funcion,rango[1]=k+d/2))],k,abscisas)
else ordenadas:
makelist([k, max(ev(funcion,rango[1]=k-d/2),
ev(funcion,rango[1]=k+d/2))],k,abscisas),
apply(draw2d,
append( [color=blue,
fill_color=cyan],
makelist(rectangle([k[1]-d/2,0],[k[1]+d/2,k[2]]),
k,ordenadas),
[color=black,
line_width=3,
explicit(funcion,rango[1],rango[2],rango[3])] )),
int: integrate(funcion,rango[1],rango[2],rango[3]),
suma: apply("+",d*makelist(k[2],k,ordenadas)),
print(""),
print("Area beneath the curve ..=", int),
print("Total area rectangles ...=", suma),
print("Difference (int-sum) ....=", int-suma),
print("") )$
--
Mario Rodriguez Riotorto
www.biomates.net