# set terminal svg size 600,400 dynamic enhanced font 'arial,10' mousing name "bivariat_4" butt dashlength 1.0 # set output 'bivariat.4.svg' set key fixed right bottom vertical Right noreverse enhanced autotitle nobox set samples 50, 50 set style data lines set title "approximate the integral of functions (upper and lower limits)" integral_f(x) = (x>0)?int1a(x,x/ceil(x/delta)):-int1b(x,-x/ceil(-x/delta)) int1a(x,d) = (x<=d*.1) ? 0 : (int1a(x-d,d)+(f(x-d)+4*f(x-d*.5)+f(x))*d/6.) int1b(x,d) = (x>=-d*.1) ? 0 : (int1b(x+d,d)+(f(x+d)+4*f(x+d*.5)+f(x))*d/6.) f(x)=sin(x-1)-.75*sin(2*x-1)+(x**2)/8-5 integral2_f(x,y) = (xy-d*.5) ? 0 : (int2(x+d,y,d) + (f(x)+4*f(x+d*.5)+f(x+d))*d/6.) NO_ANIMATION = 1 delta = 0.2 plot [-10:10] f(x) title "f(x)=sin(x-1)-0.75*sin(2*x-1)+(x**2)/8-5", integral2_f(x,1)