Numerical Integration through Plotting
Lua, 219 chars

Done it all in 1 step, no need for an intermediate table. Plots the function too ;)

function I(f,x,X,y,Y,r,R)I=io.write N=0 for k=R-1,0,-1 do for l=0,r-1 do v=f(x+l*(X-x)/r) K=y+k*(Y-y)/R c=(K&lt;0 and K&gt;v)and'-'or(K&gt;0 and K&lt;v and'+')or' 'N=c=="+"and N+1 or(c=="-"and N-1 or N)I(c)end I'\n'end return N end


Test code:

assert(I(math.sin,1.0,8.0,-1,1,30,15)==19)