## Generate uniform data on (0,1). The expected value is 1/2. X = runif(1e4) ## Simulate the exact result for the log function. L1 = mean(log(X)) ## The mathematical approximation for the log function. L2 = log(1/2) ## Simulate the exact result for the squaring function. S1 = mean(X^2) ## The mathematical approximation for the squaring function. S2 = (1/2)^2