```---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
Integrals of F from A to B when A or B are infinite or F is undefined at A or B
[ continuation from here ]

# I have to calculate ∫[0,1] (x^3-x^5)/log(x) dx.
f = function(x) (x^3-x^5)/log(x)
# In 0 and 1 f is not defined. But if I make the graph:
BF=3; HF=2.8
graphF( f,0,1, "brown")
# I obtain the graph below on the left:

# After all:
f(0); f(1)
# 0   NaN     as x -> 1 f(x) -> -2, indeed:
f(1-1e-10)
# -2
# I could extend f like this:  f(0)=1  f(1)=-2
# Therefore ∫[0,1] (x^3-x^5)/log(x) dx  must be a negative number.
# From the graph I understand it is near -1/2. We perform the calculation:
integral(f, 0,1)
# -0.4054651
# Is it the logarithm of something?
exp(integral(f, 0,1))
# 0.6666667
fraction(exp(integral(f, 0,1)))
# 2/3
log(2/3)
# -0.4054651
# I can draw the graph of the "integral function" x -> ∫[0,x] f (the graph IF above):
Plane(0,1, 0,-0.5)
Gintegra(f, 0,1, "seagreen")
POINT(1,log(2/3),"red")
#
#
# I have to calculate ∫(-∞,∞) sin(x)/x dx

g = function(x) sin(x)/x
# We know that g(x) -> 1 as x -> 0
g(10^-(1:5))                                        # g(0.1), ..., g(0.00001)
# 0.9983342 0.9999833 0.9999998 1.0000000 1.0000000
BF=4.5; HF=3
RANGE0(g, -10*pi,10*pi)
# "~ min F(min)   Max F(Max)   mFmF[1:4] = "
# -4.49697447 -0.21723225 -0.03144737  0.99983519   g(x) sta tra -0.22 e 1
TICKx=pi; TICKy=0.1; Plane2(-10*pi,10*pi,-0.22,1)
underX(c("-10pi","-6pi","-2pi","0","2pi","6pi","10pi"),2*pi*c(-5,-3,-1,0,1,3,5))
underY(c(-2,0,5,10)/10,c(-2,0,5,10)/10)
graph2(g,-10*pi,10*pi,"brown")
Z = function(x) 0
Diseq(Z,g, -10*pi,10*pi,"red")
Diseq(g,Z, -10*pi,10*pi,"yellow")
graph2(g,-10*pi,10*pi,"brown")
# ∫(-∞,∞) sin(x)/x dx = 2 * ∫[0,∞) sin(x)/x dx     (simmetry of the graphic)
integral(g,0,1e2)
# 1.562225
# integral(g,0,1e3)
# Error: maximum number of subdivisions reached
# It is advisable to proceed with successive sums (on [0,10] [10,20] ... [100,110],
# then [0,10] ... [1000,1010], then [0,10] ... [10000,10010], then ...)
s=0; b=10
n=1e1; s0=s; s=0; for(i in 0:n) s=s+integral(g,b*i,b*(i+1)); more( c(s,s-s0) )
# 1.57988048912506  1.57988048912506
n=1e2; s0=s; s=0; for(i in 0:n) s=s+integral(g,b*i,b*(i+1)); more( c(s,s-s0) )
#  1.57081912496797615  -0.00906136415708381
n=1e3; s0=s; s=0; for(i in 0:n) s=s+integral(g,b*i,b*(i+1)); more( c(s,s-s0) )
#  1.57073311569261e+00  -8.60092753700581e-05
n=1e4; s0=s; s=0; for(i in 0:n) s=s+integral(g,b*i,b*(i+1)); more( c(s,s-s0) )
# 1.57078774776842e+00  5.46320758134655e-05
n=1e5; s0=s; s=0; for(i in 0:n) s=s+integral(g,b*i,b*(i+1)); more( c(s,s-s0) )
# 1.57079730319125e+00  9.55542282965460e-06
# it is sufficient to convince oneself that is π/2
fraction(s/pi)
# 1/2
# If you want you can go on (it takes a few seconds):
n=1e6; s0=s; s=0; for(i in 0:n) s=s+integral(g,b*i,b*(i+1)); more( c(s,s-s0) )
#  1.57079622778987e+00  -1.07540137972428e-06
#
# Therefore:  ∫[0,∞) sin(x)/x dx = π/2, ∫(-∞,∞) sin(x)/x dx = π
#
# I have to calculate ∫(-∞,∞) 1/(pi*(1+x^2)) dx

g = function(x) 1/(pi*(1+x*x)); graphF(g,-5,5, "brown")
integral(g, -Inf,Inf)
# 1                  g is a probability density function

```