#04 (08/30/2023)

Integration

Some of important integrals that you may have forgotten:



xα dx
xα+ 1

α+ 1

1

x
dx
ln x

dx

1 + x2
arctan x

dx




a2x2
arcsin (x/a)

f(x) g′(x) dx
f(x)g(x) −
f′(x) g(x) dx

f(x) dx
x f(x) −
x f′(x) dx

Exercises

Evaluate the following integrals:

(a)
dx

ex + ex
(b)



 

a2x2
 
dx
(c)
eax cos b x dx
(d)



 

x2 + 1
 
dx
Solution for (d)  
I


 

x2 + 1
 
dx.
Use integration by parts:
I
=
x

 

x2 + 1
 

x


 

x2 + 1
 


 
dx
=
x

 

x2 + 1
 

x2




x2 + 1
dx
=
x

 

x2 + 1
 

x2 + 1 − 1




x2 + 1
dx
=
x

 

x2 + 1
 



 

x2 + 1
 
dx +
dx




x2 + 1
=
x

 

x2 + 1
 
I +
dx




x2 + 1
,
(1)
so
I = 1

2


x

 

x2 + 1
 
+
dx




x2 + 1


.
(2)
Now, the integral, J, defined as
J
dx




x2 + 1
,
(3)
is a challenging integral. The recipe is to change the variable from x to t as1


 

x2 + 1
 
= tx.
(4)
With this substitution,
1
=
t2 −2 t x,
(5)
dx
=
tx

t
dt,
(6)
so
J
=

1

tx
tx

t
dt
=

dt

t
=
lnt
=
ln
x +

 

x2 + 1
 

,
(7)
and finally we obtain
I = 1

2

x

 

x2 + 1
 
+ ln 
x +

 

x2 + 1
 


.
(8)
It is, however, more practical these days to carry out integrations like the one above via computer.
Enter the following line
Sqrt[x^2 + 1]

exactly (case sensitive, square bracket) in the first box and x (lower case) in the second box, then press the query button.
Integrate with respect to .

Numerical Integration

You can differentiate almost any function exactly but very few functions can be integrated analytically which is why numerical integrations are more important than numerical differentiation.
numint.jpg
  • (Left) Rectangular rule:

    I  ∼  h (f0 + f1 + f2 + …+ fn−1).
    (9)
  • Trapezoidal rule:
    I  ∼   h

    2
    (f0 + 2 f1 + 2f2 + …+ 2 fn−1 + fn).
    (10)
  • Simpson rule:
    I  ∼   h

    3
    (f0 +4 f1 + 2 f2 + 4 f3 + 2 f4 + …+ 4 f2n−1 + f2n).
    (11)
where
h = ba

n
,     h′ = ba

2 n
.
(12)
It is possible to estimate possible numerical errors for each scheme.
Derivation

Rectangular rule

The rectangular rule is to approximate ∫at f(x)dx by a rectangle with f(t) as the height and ta ( = h) as the base.
num_rec.jpg
The error is then defined as

ϵ(t) = (ta) f(t) −
t

a 
f(x) dx.
(13)
To see how this function behaves, take the derivative of ϵ(t) with respect to t as
ϵ′(t)
=
f(t) + (ta) f′(t) − f(t)
=
f′(t) (ta)
 ∼ 
f′(ξ) (ta),
(14)
where ξ is some constant value assuming that f′(t) does not fluctuate much between a and t. By integrating Eq. (14) with respect to t, we have

ϵ(t)
 ∼ 
f′(ξ)

2
(ta)2
=
f′(ξ)

2
h2,
(15)
where h = (ta).
When adding up Eq. (15) over a finite interval of (a,b) for n times, the total error is

ϵtotal
 ∼ 
n h2 f′(ξ)

2
=
(ba) f′(ξ)

2
h,
(16)
where ba = n h was used in Eq. (16). Equation (16) implies that when the rectangular rule is used to approximate

b

a 
f(x) dx,
(17)
the numerical error involved is in the order of
ϵtotal  ∼ A h,
(18)
where A is a constant and h is the step size. In other words, to get 10−5 accuracy for ba = 1, one would need n = (ba)/h  ∼ 105 partitions over the interval.

Trapezoidal Rule

num_trap.jpg
The error involved in the trapezoidal rule is given

ϵ(t) =
f(t) + f(a)

2

(ta) −
t

a 
f(x) dx.
(19)
Take the derivative of Eq. (19) as
ϵ′(t) = f′(t)

2
(ta) + f(t) + f(a)

2
f(t),
(20)
which does not yield much insight. Try taking another derivative of Eq. (20) as

ϵ"(t)
=
f"(t)

2
(ta) + f′(t)

2
+ f′(t)

2
f′(t)
 ∼ 
f"(ξ)

2
(ta).
(21)
Integrating Eq. (21) yields

ϵ′(t)  ∼  f"(ξ)

4
(ta)2.
(22)
Integrating Eq. (22) again yields

ϵ(t)
 ∼ 
f"(ξ)

12
(ta)3
=
f"(ξ)

12
h3.
(23)
By adding up Eq. (23) over the interval of (a,b), we obtain
ϵtotal
 ∼ 
n h3 f"(ξ)

12
=
(ba) f"(ξ)

12
h2
 ∼ 
A h2,
(24)
where A is a constant. This conclusion implies that we need √{105}  ∼ 316 partitions to obtain 10−5 accuracy.

Simpson's Rule

From the result of error analysis of the trapezoidal rule, it was found that

I  ∼ Tn + A h2,
(25)
where I is the true value, Tn is the approximation by the trapezoidal rule, h is the step size and n is the number of partitions. If one makes the stepsize h one-half, Eq. (25) becomes

I  ∼ T2n + A
h

2

2

 
,
(26)
or

I
 ∼ 
Tn + A h2,
(27)
4I
 ∼ 
4 T2n + A h2,
(28)
from which it follows

I  ∼  4T2nTn

3
+ (higher order terms than h2).
(29)
Actual computation of Eq. (29) is
I
 ∼ 
1

3

4 h

2
(f0 + 2 f1 + 2 f2 + …+ 2 f2n−1 + f2n)− (2 h)

2
(f0 + 2 f2 + 2 f4 + …+ f2n)
=
h

3

f0 + 4 f1 + 2 f2 + 4 f3 + 2 f4 + …+2 f2n−2 + 4 f2n−1 + f2n
.
(30)
Equation (30) is called the Simpson rule as you already figured it out.
An example of numerical integration with poor convergence:  

Using the relationship
4
1

0 


 

1 − x2
 
dx = π,
(31)
to compute an approximation of π.
numint_ex.jpg
Numerical integration of this function results in poor convergence. Why ?


Footnotes:

1For an integral of the type

F(x,

 

a x2 + b x + c
 
) dx     a > 0
the following change of variable usually works:


 

a x2 + b x + c
 
= √a xt.



File translated from TEX by TTH, version 4.03.
On 29 Aug 2023, 21:06.