What is the formal definition of a piecewise function? In many precalculus and calculus textbooks, the authors mention the term "piecewise function". However, they never define it rigorously. So, what is the rigorous and formal definition of a piecewise function, or is there none?
 A: There needn't be a formal definition, as a piecewise function is a plain function, and any function can be redefined in a piecewise way.
Piecewise is just informative about how the function in question was defined and is a hint about its properties. For instance, a piecewise polynomial function is immediately understood as being infinitely differentiable almost everywhere.
See https://en.wikipedia.org/wiki/Piecewise.
A: The short answer is that any piecewise function is just a function.
As an example, if you have e.g. $f: A \rightarrow B$ with $B = \{b_1,b_2\}$ some set, $A = \mathbb{R}$ and $f(x)=b_1$ if $x \leq 0$ and $f(x)=b_2$ if $x>0$. Define functions $g: (-\infty,0] \rightarrow B$ and $h: (0,\infty)\rightarrow B$ such that $g(x)=b_1$ and $h(x_2)=b_2$. Then formally one has that $f = g \cup h$ and the union of two functions is again a function (This will hold for arbitrary finite unions). The reason is that formally the function $f$ is a subset of $A \times B$ with $\times$ the Cartesian product such that for any $a \in A$ there is a unique $b \in B$ such that $(a,b) \in f$.
