# source("http://macosa.dima.unige.it/r.R") dev.new(width=8, height=4); rowcol(1,2) a=0; b=15; c=0; d=50; a1=a; b1=b; c1=0; d1=250; x1=3; x2=5; x3=10 h = function(x) ifelse(x < 3,10,ifelse(x < 5,10+20*(x-3),ifelse(x < 10,50-10*(x-5),0))) k = function(t) integral(h, 0,t) Box_(a,b, c,d); GRAPH2(h, a,x1, "black"); type(2.5,45,"F") Box_(a1,b1, c1,d1); type(2.5,225,"area") for(x in seq(a,x1,0.05)) Dot2(x,integral(h, a,x),"seagreen") wait(3) Box_(a,b, c,d); GRAPH2(h, a,x2, "black"); type(2.5,45,"F") Box_(a1,b1, c1,d1); type(2.5,225,"area") for(x in seq(a,x2,0.05)) Dot2(x,integral(h, a,x),"seagreen") wait(3) Box_(a,b, c,d); GRAPH2(h, a,x3, "black"); type(2.5,45,"F") Box_(a1,b1, c1,d1); type(2.5,225,"area") for(x in seq(a,x3,0.05)) Dot2(x,integral(h, a,x),"seagreen") wait(3) Box_(a,b, c,d); GRAPH2(h, a,b, "black"); type(2.5,45,"F") Box_(a1,b1, c1,d1); type(2.5,225,"area") for(x in seq(a,b,0.05)) Dot2(x,integralB(h, a,x),"seagreen") # for "integralB" see here) # Or (in 2 windows): graphics.off() # <- if you want shut down all open graphics devices a=0; b=15; c=0; d=50; a1=a; b1=b; c1=0; d1=250; x1=3; x2=5; x3=10 A=10; D=A+305 h = function(x) ifelse(x < 3,10,ifelse(x < 5,10+20*(x-3),ifelse(x < 10,50-10*(x-5),0))) k = function(t) integral(h, 0,t) P = function(x) dev.set(dev.prev()); R = function(x) replayPlot(x); S = function(x) recordPlot() dev.new(width=3, height=3, xpos=A, ypos=A); Box_(a,b, c,d); type(2.5,45,"F"); fig01 = S() dev.new(width=3, height=3, xpos=D, ypos=A); Box_(a1,b1, c1,d1); type(2.5,225,"area"); fig02 = S() P(); R(fig01); for(x in seq(a,x1,0.05)) Dot2(x,h(x),"black"); fig01=S() P(); R(fig02); for(x in seq(a,x1,0.05)) Dot2(x,integral(h, a,x),"seagreen"); fig02=S() wait(2) P(); R(fig01); for(x in seq(x1,x2,0.025)) Dot2(x,h(x),"black"); fig01=S() P(); R(fig02); for(x in seq(x1,x2,0.05)) Dot2(x,integral(h, a,x),"seagreen"); fig02=S() wait(2) P(); R(fig01); for(x in seq(x2,x3,0.05)) Dot2(x,h(x),"black"); fig01=S() P(); R(fig02); for(x in seq(x2,x3,0.05)) Dot2(x,integral(h, a,x),"seagreen"); fig02=S() wait(2) P(); R(fig01); for(x in seq(x3,b,0.05)) Dot2(x,h(x),"black"); fig01=S() P(); R(fig02); for(x in seq(x3,b,0.05)) Dot2(x,integralB(h, a,x),"seagreen") ## dev.set(dev.prev()) returns the previous device