source("http://macosa.dima.unige.it/r.R") # If I have not already loaded the library
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
# In some case, some manipulations are necessary to calculate an integral. An example.
g = function(x) sin(x)^3
integral(g,0,200)
# Error: maximum number of subdivisions reached
# But I know that from 0 to 2*pi the integral is 0 ...
2*pi*30
# 188.4956
# The integral is
integral(g, 2*pi*30,200)
# 0.218024
#
# Another trick:
integral(g,0,50)+integral(g,50,100)+integral(g,100,150)+integral(g,150,200)
# 0.218024