Integer part and fractional part functions¶
Part 2 · Functions · Chapter 7 · lecture notes by Fabio Furini · Chapter PDF
1. Integer part and fractional part functions¶
- Two functions that are typically encountered when writing algorithms are the integer part (floor) function and the fractional part (or decimal part) function.
Definition 1: of the integer part function
The integer part (floor) function is:
Definition 2: of the upper integer part function
The upper integer part (ceiling) function is:
Definition 3: of the fractional part function
The fractional part function is:
-
The integer part function \(f(x)= \lfloor x \rfloor\) is monotone increasing, like the upper integer part function \(f(x)= \lceil x \rceil\).
-
Graphs of the functions \(f(x)=\lceil x \rceil\) and \(f(x)= \lfloor x \rfloor\) on the interval \([-4,4]\).
-
Note that the fractional part is a periodic function with period 1:
2. Piecewise-defined functions¶
- Starting from the elementary functions, new ones can be built by using different analytic definitions on different intervals.
Definition 4: of piecewise-defined function
A function \(f\) whose value \(f (x)\) is computed through different “instructions” depending on the interval in which \(x\) lies is called a piecewise-defined function.
Example 1: Piecewise-defined functions
Consider for example
its graph is:
- From the logical / algorithmic point of view, one can say that a function of this kind has the peculiarity of being built using not only mathematical functions but also the logical function “if … then”.