\[\int_{0}^{2e} ln(x)dx = \lim_{b \to 0}\int_{b}^{2e} ln(x)dx\]
curve(log(x),from = 0, to = 2*exp(1),col = "orange", main = " Grafica de ln(X)", ylab = "ln(x)", xlab = "x", xlim = c(0,5), ylim = c(-3,2) )
text(1.45, 1, 'ln(x)', col = "orange")
abline(h = 0, col = 'darkgreen')
text(1.5,-2, "y=0", col = "blue")
abline(v = 1, col = 'blue')
text(0.5,1, "x=0", col = "darkgreen")
segments(x0 = 3, y0 = 0, x1 = 3, y1 = log(3), col = 'red')
segments(x0 = 3.2, y0 = 0, x1 = 3.2, y1 = log(3.2), col = 'red')
arrows(x0 = 3.4, y0 = 0.3, x1 = 3.2, y1 = 0.3, length = 0.06, col = "red")
text(3.6, y = 0.3, 'dx', col = "red")
abline(v = 0, col = 'black')
puntos = 10000
# limite superior integral
xm = 2*exp(1)
x1 = runif(puntos, 0, 1)
y1 = runif(puntos, -10,0)
x2 = runif(puntos, 1, xm)
y2 = runif(puntos, 0,log(xm))
# VERDE = area deseada
# ROJO = area no deseada
color1 = ifelse(y1>log(x1),'green','pink')
color2 = ifelse(y2<log(x2),'green','pink')
color=c(color1,color2)
#Grafico plot
plot(c(x1,x2),c(y1,y2), pch = 16, cex = 0.1, col = color, main = 'Simulacion grafico integral ln(x)', ylab = 'ln(x)', xlab = 'x')
# Rectangulo 1
segments(x0 = 0, y0 = -10, x1 = 1, y1 = -10,col = 'red')
segments(x0 = 0, y0 = 0, x1 = 1, y1 = 0,col = 'red')
segments(x0 = 0, y0 = 0, x1 = 0, y1 = -10, col = "red" )
segments(x0 = 1, y0 = 0, x1 = 1, y1 = -10, col = "red" )
text(0.5,-5,"A", col = "red")
# Rectangulo 2
segments(x0 = xm, y0 = 0, x1 = xm, y1 =log(xm),col = 'blue')
segments(x0 = xm, y0 = 0, x1 = 1, y1 = 0,col = 'blue')
segments(x0 = 1, y0 = log(xm), x1 = 1, y1 = 0, col = "blue" )
segments(x0 = 1, y0 = log(xm), x1 = xm, y1 = log(xm), col = "blue" )
text(3.4,0.5,"B", col = "blue")
curve(log(x),add=T)
# suma de puntos Rectangulo A
cuantos_siA = sum(y1>log(x1))
#proporcion de puntos de color verde en el rectangulo A
porc_punt_siA = cuantos_siA/puntos
#10%
# area rectangulo A
AA = 1*10
#suma de puntos rectangulo B
cuantos_siB = sum(y2<log(x2))
#proporcion de puntos de color verde en el rectangulo B
porc_punt_siB = cuantos_siB/puntos
#area del rectangulo B
AB = (xm-1)*log(xm)
puntA = (table (color1)[1] * AA)/ puntos
puntB = (table (color2)[1] * AB)/ puntos
puntA + puntB
## green
## 5.774767