Sol 1
Sol 1
1. (a) Using only the fact that constant functions, x and sin(x) are continuous and
the computation rules for continuous functions prove that
x3 + cos(x)2 + πx − 2
f (x) =
x2 + π
is continuous as a function from R to R.
(b) Let the function f : R → R be defined by
x2 + 2 cos(x) − max(0, x)
f (x) := q .
ln(|x3 − 1| + 2) + π x
(a) Since multiples of continuous functions are continuous, then −2, π and πx
are continuous. As the product of continuous functions is continuous, it
follows that x2 is continuous, as well as x3 . Since 1 and sin(x) are continuous
functions, hence sin(x)2 is again a continuous function as the product of
two continuous functions is continuous. Then, the fact that cos(x)2 = 1 −
sin(x)2 implies that cos(x)2 is a continuous function as the sums of continuous
functions are continuous. Further, it follows that x3 + πx − 2 and x2 +
π are continuous. Quotients of continuous functions are continuous if the
denominator is not zero. Since x2 + π ̸= 0 for all x ∈ R, the function f is
continuous.
(b) • Theorem 4.4 (the cosine function is continuous)
• Lemma 4.9 (the absolute value of continuous function is continuous)
• Lemma 4.10 (the maximum of continuous functions is continuous)
• Example on page 154 (the root function is continuous)
• Example on page 155 (polynomials are continuous)
• Theorem 4.3 (the exponential function is continuous)
• Theorem 4.7 (the sum, product, and quotient, where defined, of two
continuous functions is continuous)
• Theorem 4.8 (the composition of two continuous functions is continuous)
1
Mathematics for AI 2 Exercise Sheet 1 SS24
2. Determine the largest domain of the following functions and check their continuity
using the appropriate arguments.
• h1 (x) = 1
x
√
• h2 (x) = x
• h3 (x) = √1
x
• h4 (x) = √ 1
x2 +1
Solution:
2
Mathematics for AI 2 Exercise Sheet 1 SS24
3. Let x ∈ R, then the floor and ceiling functions can be defined as follows:
f loor(x) :=⌊x⌋ = max{m ∈ Z | m ≤ x},
ceiling(x) :=⌈x⌉ = min{n ∈ Z | n ≥ x}.
• Plot both functions on the interval [−13, 3] using any software of your choice.
• Write a Python script regarding the implementation of the floor and ceiling
functions without using any external packages.
• Study the continuity of the floor and ceiling functions.
Solution:
•
Listing 1: Python code
• # Floor function implementation
def f l o o r ( x ) :
i f ( x >= 0 or int ( x)−x==0):
return int ( x )
else :
return int ( x ) − 1
# Ceiling function implementation
def c e i l i n g ( x ) :
i f ( x >= 0 and int ( x)−x !=0) :
return int ( x ) + 1
else :
return int ( x )
# Test v a l u e s
t e s t _ v a l u e s = [ −3 , 3 , 2 . 3 , 4 . 8 , −3.5 , 7 . 1 ]
# C a l c u l a t e f l o o r and c e i l i n g f o r each t e s t v a l u e
for v a l in t e s t _ v a l u e s :
print ( f " ␣ Input ␣ : ␣{ v a l }␣ " )
print ( f " ␣ F l o o r ␣ : ␣{␣ f l o o r ␣ ( ␣ v a l ␣ )} ␣ " )
print ( f " ␣ C e i l i n g ␣ : ␣{␣ c e i l i n g ␣ ( ␣ v a l ␣ )} ␣ " )
print ( )
3
Mathematics for AI 2 Exercise Sheet 1 SS24
• The floor function f (x) = ⌊x⌋ is continuous in every open interval between
integers, (n, n + 1) for any integer n. However, it is not continuous at any
integer n.
To prove that the floor function, denoted by ⌊x⌋, is not continuous, we can
show that it fails to satisfy the definition of continuity at certain points.
Let’s consider the point x = n, where n is an integer.
For any x in the interval (n, n + 1), the floor function takes the value n.
However, as we approach x = n from the left, i.e., as x approaches n from
the interval (n − 1, n), the function jumps from n − 1 to n. This means that
there exists a discontinuity at every integer n.
Formally, let’s show this using the definition of continuity at x = n:
Let ε = 12 , then for any δ > 0, if we consider x = n− 2δ , which is in the interval
(n − 1, n) then |x − n| < δ. However, |⌊x⌋ − ⌊n⌋| = |(n − 1) − n| = 1 > ε.
Thus, the floor function fails to satisfy the definition of continuity at x = n.
Since there are discontinuities at every integer, the floor function is not con-
tinuous over its entire domain. Therefore, we have proven that the floor
function is not continuous.
The same argument can be used to show that ⌈x⌉ is not continuous. In fact,
for any x in the interval (n − 1, n), the ceiling function takes the value n.
However, as we approach x = n from the right, i.e., as x approaches n from
the interval (n, n + 1), the function jumps from n to n + 1. This means that
there exists a discontinuity at every integer n. Formally, let ε = 21 , for any
choose δ > 0 if we consider x = n + 2δ , which is in the interval (n, n + 1), it
follows that |x − n| < δ. However, |⌈x⌉ − ⌈n⌉| = |(n + 1) − n| = 1 > ε. Thus,
the ceiling function fails to satisfy the definition of continuity at x = n.
4
Mathematics for AI 2 Exercise Sheet 1 SS24
x if x is rational
(
f (x) :=
x2 if x is irrational
(a) Let
0 if x > 0 1 if x > 0
(
f (x) := and g(x) :=
1 if x ≤ 0 0 if x ≤ 0
Then both f (x) and g(x) are discontinuous at 0. However, h(x) := f (x)+
g(x) = 1 for all x ∈ R. which is continuous everywhere.
Let
1 if x ∈ Q −1 if x ∈ Q
f (x) := and g(x) :=
0 if x ∈ R \ Q 0 if x ∈ R \ Q
Then both f (x) and g(x) are discontinuous everywhere. However, h(x) =
f (x) + g(x) = 0 for all x ∈ R, i.e., continuous everywhere.
n o
(b) For the continuity at 1. Let ϵ > 0, choose δ = min 1, 3ϵ , then,
|x − 1| < δ =⇒ |x + 1| = |x − 1 + 2| ≤ |x − 1| + 2 < 3
Hence,
if x is rational |x − 1|
(
|f (x) − 1| =
if x is irrational |x2 − 1| = |x + 1||x − 1|
5
Mathematics for AI 2 Exercise Sheet 1 SS24
5. Use the ε − δ−criterion to show that the following functions are discontinuous.:
0, x < −1
x = −1
1
,
−1, x < 0
2
sgn(x) := 0, x = 0 , rect(x) := 1, x ∈ (−1, 1)
1, x > 0
x=1
1
,
2
0, x > 1
Solution:
If sgn were continuous at 0, it would have to hold that
However, we show that this does not hold for ε = 12 and any δ > 0. Consider
x = δ/2, then |x − 0| < δ, but | sgn(x) − sgn(0)| = |1 − 0| = 1 > ϵ.
Suppose rect were continuous at 1 and −1, then:
and
∀ε > 0 ∃δ > 0 ∀x ∈ R : |x + 1| < δ ⇒ | rect(x) − rect(−1)| < ε.
Yet, we disprove this for ε = 14 and any δ > 0. Let x = 1 + 2δ , then |x − 1| < δ,
but | rect(x) − rect(1)| = |0 − 21 | = 21 > ϵ.
Similarly we can conclude that rect is not continuous at −1 if we select a sequence
xn = −1 − 2δ and ε = 41 .
□
6
Mathematics for AI 2 Exercise Sheet 1 SS24
6. Use the ε − δ−criterion to show that the following functions are continuous:
0, x < 0 1 x, x<0
ReLU(x) := , LeakyReLU(x) := 2
x, x ≥ 0 x, x ≥ 0
Solution:
To prove the continuity of the ReLU function at any point c ∈ R, first we observe
that ReLU is continuous for both for x > 0 and x < 0 given that both the identity
and the constant functions are continuous in their domains of definition. Thus,
we need to check the continuity of ReLU at x = 0. That is we need to show that
for any ϵ > 0, there exists a δ > 0 (may depend on ϵ) such that for all x ∈ R
satisfying |x − 0| = |x| < δ, we have |ReLU (x) − ReLU (0)| = |ReLU (x)| < ϵ. Our
aim is to find δ that satisfies the previous claim.
Thus, the ReLU function is continuous at any point c, and the proof is complete.
In order to prove continuity of the LeakyReLU function, we argue as in the
previous case of ReLU . That is, since LeakyReLU is continuous for both for
x > 0 and x < 0 given that linear functions are continuous in their domains of
definition. Thus, we need to check the continuity of LeakyReLU at x = 0.