Familiarizing Students with Definition of Lebesgue Integral: Examples of Calculation Directly from Its Definition Using Mathematica

We present in this paper several examples of Lebesgue integral calculated directly from its definitions using Mathematica. Calculation of Riemann integrals directly from its definitions for some elementary functions is standard in higher mathematics education. But it is difficult to find analogical examples for Lebesgue integral in the available literature. The paper contains Mathematica codes which we prepared to calculate symbolically Lebesgue sums and limits of sums. We also visualize the graphs of simple functions used for approximation of the integrals. We also show how to calculate the needed sums and limits by hand (without CAS). We compare our calculations in Mathematica with calculations in some other CAS programs such as wxMaxima, MuPAD and Sage for the same integrals.

In popular books of calculus, for example [3,7,12], we can find many examples of Riemann integral calculated directly from its definition. The aim of these examples is to familiarize students with the definition of Riemann integral. But we cannot find analogical examples for Lebesgue integral.
In this article, with similar aim but for Lebesgue integral definition, we present the following examples of calculation directly from its definition: π/2 0 sin x dm(x), 1 0 exp(x) dm(x), π 0 ln(1 − 2r cos x +r 2 ) dm(x) (r > 1), 1 0 x k dm(x) (k ∈ N), 1 −1 x 2 dm(x) where dm(x) denotes the Lebesgue measure on the real line. The way we presented we may also calculate e.g. 1 ln x dm(x) using "partition the range of f " Lebesgue philosophy. We calculate sums, limits and plot graphs of needed simple functions using Mathematica.

Definitions of Lebesgue Integral
The following two definitions of Lebesgue integral are used in the first part of this article: Let (R, M, m) be the measure space, where M is σ -algebra of Lebesgue measurable subsets in R, and m is the Lebesgue measure on R.
Let R be extended real numbers R with two more elements adjoined, denoted +∞ and −∞. Let A be Lebesgue measurable subset of R. A real-valued function f on A is called simple if it assumes only finitely many distinct values. Let f : A → R be measurable nonnegative function (we've omitted the definition of Lebesgue integral for simple real measurable functions). We stress the fact that the value of the Lebesgue integral of function f in the Definition 2 is independent of the choice of the sequence s n . The proof of this fact can be found in [1,p. 130,Theorem 17.5.] and in [11, p. 300], [15,p. 289,Theorem 4.6].
The equivalence of the two definitions follows from the Lebesgue's Monotone convergence theorem (See [13, Theorem 11.28, p. 318], [6]) or it could be proved more elementary (sketch of the proof): From the basic properties of Lebesgue integral for simple measurable function we have that A s n dm(x) is nondecreasing sequence of real numbers. Hence the limit lim n→∞ A s n dm(x) exists (finte or ∞). Suppose that lim n→∞ A s n dm(x) = a ≥ 0 for some nondecreasing sequence s n of nonnegative simple measurable functions such that lim n→∞ s n (x) = f (x) for every x ∈ A.
Directly from properties of the least upper bound we have that When a = ∞ then the equivalence is obvious. Suppose that a < ∞ and that sup A s dm(x) : 0 ≤ s ≤ f, s : A → R is simple measurable function > a. That means that there exists simple measurable function s such that 0 ≤ s ≤ f and A s(x) dm(x) > a. Let t n (x) = max{s(x), s n (x)} for all x ∈ A and for n = 1, 2, . . ..
It can be shown that t n are simple measurable functions for n = 1, 2, . . ., s(x) ≤ t n (x) ≤ t n+1 (x) for all x ∈ A, n ∈ N and lim n→∞ t n (x) = f (x) for all x ∈ A.
Because the limit in the Definition 2 is independent of the choice of the sequence s n and a < A s( which contradicts the assumption lim n→∞ A s n dm(x) = a. So it must be: We will consider six examples of calculating Lebesgue integral directly from its definition.
3 Example: Let us consider the function: f (x) = sin x, x ∈ [0, π/2). For the rest of this example we will restrict our consideration to x ∈ [0, π/2). We will calculate π/2 0 sin x dm(x) applying directly Definition 1. Consider Using Wolfram Mathematica we get the following Figs. 1 and 2: Fig. 1 Graphs of functions f , s 1 , s 2 . We can see that It is clear that s n ,s n are sequences of nonnegative simple measurable functions and that s n ≤ f ands n ≥ f on [0, π/2) for all n = 1, 2, . . ..
Let consider the function: f (x) = exp x, x ∈ [0, 1). For the rest of this example we will restrict our consideration to x ∈ [0, 1).
We will calculate 1 0 exp x dm(x) applying directly Definition 1. Consider It is clear that s n ,s n are sequences of nonnegative simple measurable functions and that s n ≤ f ands n ≥ f on Similarly Listing 4 Mathematica code:

In[7]:= Simplify
Of course we could use the following formulae: n k=0 q k = 1−q n+1 1−q (q = 1) and lim x→0 exp x−1 x = 1 instead of the code in Listings 3 and 4 to get the results in formulae (4.1) and (4.2).
It is clear that s n ,s n are sequences of nonnegative simple measurable functions and that s n ≤ f ands n ≥ f on [0, π) for all n = 1, 2, . . .. In the Mathematica code below we use the fact that if s k is a sequence of positive values with convergent sum, then we have k s k = ln exp( k s k ) = ln k exp(s k ) .
Using Wolfram Mathematica we get: Listing 5 Mathematica code: In[2]:= pr=Simplify Similarly Listing 6 Mathematica code: In listings 5, 6 we used the substitution rule (n->2ˆn) because when we used directly 2ˆn instead n, Mathematica could not simplify the expression. We cannot calculate these limits in one step using Mathematica. But using other CAS (wxMaxima, MuPAD) we cannot calculate these limits even in two steps in any way. Sō Of course we could use the following formulae:  Of course we could use the Stolz and binomial theorems instead of the code in Listings 7 and 8 to get the results in formulae (6.1) and (6.2).
Using formulae (6.1) and (6.2) and similar reasoning like in the previous example (Sect. 3) we get:  Let consider the function: f (x) = x 2 , x ∈ [−1, 1). For the rest of this example we will restrict our consideration to x ∈ [−1, 1). We will calculate 1 −1 x 2 dm(x) applying directly Definition 1. Consider Of course we could use the formula n k=1 k 2 = 1 6 n(n + 1)(2n + 1) instead of the code in Listings 9 and 10 to get the results in formulae (7.1) and (7.2).
Using formulae (7.1) and (7.2) and similar reasoning like in the previous example (Sect. 3) we get:
Similarly Of course we could use the Stolz and binomial theorems instead of the code in Listings 11 and 12 to get the results in formulae (9.9). Similar reasoning like in the previous example gives: Hence directly from Definition 3 we have Let y k = k/n, k = 0, 1, 2, . . . , n so Q n : c = 0 < 1 n < · · · < n−1 n < 1 = d.

Comparing the Calculations in Mathematica with Calculations in Some Other CAS Programs
The authors tried to repeat calculations for examples of Lebesgue integrals using some other CAS programs such as: wxMaxima, MuPAD and Sage. The following Lebesgue integrals: π/2 0 sin x dm(x), 1 0 e x dm(x), 1 −1 x 2 dm(x) were calculated in analogical way in these CAS programs. We used standard procedures in these programs to calculate sums and limits. We could not calculate the integrals: 1 0 x m dm(x) (m ∈ N) and π 0 ln(1 − 2r cos x + r 2 ) dm(x) (r > 1). The use of procedures which we have used before (for integrals π/2 0 sin x dm(x), 1 0 e x dm(x), 1 −1 x 2 dm(x)) for these two integrals had no effect. We used standard procedures: sum, limit, simplification, assume.

Conclusions
In this paper the authors present several examples of Lebesgue integral calculated directly from its definition using Mathematica. We also consider the calculation of integrals using "partition the range of f Lebesgue-philosophy.
Familiarizing students with definition of an integral by calculation integrals directly from its definition is a standard approach in the case of Riemann integral.
Many examples of Riemann integral calculated using only its definition can be found in literature. We could not find any analogical examples in available literature for Lebesgue integral, so this paper is an attempt to fill this gap.
Using Mathematica or other CAS programs for calculation Lebesgue integrals directly from its definitions, seems to be didactically useful for students because of the possibility of symbolic calculation of sums, limits and plot graphs-checking our hand calculations. Moreover we get students used not only to definition of Lebesgue integral but also to CAS applications generally. The principles of programming in Mathematica language are given in [14,16].
The six examples from Sects. 3-8 of our article could be used as a supplement to the textbooks [4,6,8,10,13] (when we use Definition 1) and also as a supplement to to the textbooks [1,11,15] (when we use Definition 2). And this is the main reason why we in our article included the Definitions 1 and 2 of Lebesgue integral and calculated the examples of integral directly from these definitions.