# Under what restrictions do piecewise continuous functions in higher dimensions form vector spaces?

Definition 1. A function $$f : [a,b] \to \mathbb R$$ is called piecewise continuous if $$[a,b]$$ may be broken up into a finite number of subintervals $$[t_i,t_{i+1}]$$, $$i = 1,2,\dots, n$$, such that $$f$$ is continuous on each open subinterval $$(t_i,t_{i+1})$$ and has finite limits at their endpoints.

A natural extension to higher dimensions could be formulated as:
Definition 2. A function $$f : \Omega \subseteq \mathbb R^d \to \mathbb R$$ is called piecewise continuous if there is a finite set of open and connected sets $$\omega_1,\omega_2,\dots, \omega_n \subset \Omega$$ satisfying $$\bigcup_{i=1}^n\overline{\omega_i} = \Omega$$ and $$\omega_i\cap\omega_j=\emptyset$$ for $$i\neq j$$, and to each set $$\omega_i$$ a function $$g_i \in C(\overline{\omega_i})$$ with $$g_i = f$$ on $$\omega_i$$.

Let us for simplicity assume $$d = 2$$.
Let $$PC(\Omega)$$ be the set of all piecewise continuous functions $$f : \Omega \to \mathbb R$$, as per the above Definition 2.
Proposition. The set $$V = PC(\mathbb R^2)$$ is not a vector space.
Proof: Take for instance $$f(x_1,x_2) = \begin{cases} 1 & \text{if x_2 \geq \sin(x_1) } \\ 0 & \text{otherwise}, \end{cases}$$ and $$g(x_1,x_2) = \begin{cases} 1 & \text{if x_2 \leq -\sin(x_1) } \\ 0 & \text{otherwise}, \end{cases}$$ each in $$V$$. Clearly, $$f+g$$ will have the value 2 in an infinite number of disjoint sets, even if both $$f$$ and $$g$$ were defined by only two sets each. So $$f+g \not\in V$$. $$\square$$

What can we do to get a vector space? Restricting ourselves to compactly supported functions does not fix the problem.
Proposition. The set $$V = PC(\Omega)$$ for a bounded set $$\Omega \subset \mathbb R^2$$ does not form a vector space in general.
Proof: Define $$\psi(s) = \begin{cases} 0 & \text{if s \leq 0 } \\ -\sin\left(\frac{s}{1-s^2}\right) & \text{if s \in (0,1) },\end{cases}$$ and consider $$f(x_1,x_2) = \begin{cases} 1 & \text{if \max(|x_1|,|x_2|) < 1 and x_2 \geq \psi(x_1) } \\ 0 & \text{otherwise}, \end{cases}$$ and $$g(x_1,x_2) = \begin{cases} 1 & \text{if \max(|x_1|,|x_2|) < 1 and x_2 \leq -\psi(x_1) } \\ 0 & \text{otherwise}. \end{cases}$$ Clearly, each are compactly supported on in the square domain $$\{(x_1,x_2) : \max(|x_1|,|x_2|) < 1+\epsilon \}$$ for any $$\epsilon > 0$$, but again $$f+g$$ takes the values 2 on an infinite number of disjoint open sets. So still we don't have a vector space. $$\square$$

Question! Is there a simple requirement that immediately yields a vector space. It seems that to get these infinitely interweaving sets on a bounded set must require increasingly sharp turning. Would restricting to compact support along with the boundary of each $$\omega_i$$ being Lipschitz continuous be strong enough? I would assume yes, but is there a lesser requirement, which is sufficient?

Edit #1: Clearly, from mihaild's excellent example, which is both Lipschits continuous and infinitely differentiable that assumption was wrong. mr_e_man suggests strictly convex sets $$\omega_i$$, but that is incredibly restrictive as very few convex sets can tile together to fill an area. However, it made me think, what if each set $$\omega_i$$ was constructible by taking unions and differences of finitely many convex sets. Certainly, that should at least eliminate all these "easy" counterexamples with oscillating boundaries.

Edit #2: Turns out even even my convex set idea is problematic. Consider the set $$\Omega = [-1,1]\times[0,2]$$ and let $$\theta_i = \pi\left(1-\frac{1}{2^i}\right), i = 0,1,2,\dots,n-1\quad\text{and}\quad\theta_n = \pi,$$ and $$\varphi_{i+1} = \theta_i + \frac{\theta_{i+1}-\theta_i}{2}, i = 0,1,2,\dots,n-1,\quad \varphi_0 = 0, \quad\text{and}\quad \varphi_{n+1}=\pi.$$ Consider the point sets $$\mathcal P_n = \{(\cos(\theta_i),\sin(\theta_i)) : i = 0,1,\dots,n \}$$ and $$\mathcal Q_n = \{(\cos(\varphi_i),\sin(\varphi_i)) : i = 0,1,\dots,n+1 \}.$$ Take $$\mathcal P = \bigcup_{n=1}^\infty\mathcal P_n$$ and $$\mathcal Q = \bigcup_{n=1}^\infty \mathcal Q_n$$ and let $$\omega_1$$ be the convex hull of $$\mathcal P$$ and $$\omega_2 = \Omega\backslash\omega_1$$ and $$\eta_1$$ the convex hull of $$\mathcal Q$$ and $$\eta_2 = \Omega\backslash\eta_1$$. Let $$f(\mathbf x) = \begin{cases} 1 & \text{if \mathbf x \in \omega_1 } \\ 0 & \text{if \mathbf x \in \omega_2 } \end{cases} \quad g(\mathbf x) = \begin{cases} 0 & \text{if \mathbf x \in \eta_1 } \\ 1 &\text{if \mathbf x \in \eta_2}. \end{cases}$$ Then the set of $$f$$ can be constructed by difference of finitely many (just 2) convex sets and likewise for $$g$$ and $$f+g$$ will again have infinitely many disjoint sets with value 2.

Visual example here:

Edit #3: More restrictive idea: Each set $$\omega_i$$ must be a polygon! That has to do it, right?

Even smooth boundary isn't enough: take $$f(x, y) = \begin{cases} 0,\ y \leq 0\\ 1\end{cases}$$ and $$g(x, y) = \begin{cases} 0,\ y \leq \exp(-\frac{1}{x^2})\sin(\frac{1}{x})\\ 1\end{cases}$$

For family $$\mathcal F$$ of open subsets of $$\Omega$$, say function $$f$$ on $$\Omega$$ is $$\mathcal F$$-piecewise continuous iff there is a finite set of $$\omega_i, \ldots, \omega_n$$, $$\omega_i \in \mathcal F$$ s.t. $$\bigcup \overline{\omega_i} = \Omega$$ and $$f |_{\omega_i}$$ can be extended to continuous function on $$\overline{\omega_i}$$ for each $$i$$. Your original definition corresponds to $$\mathcal F$$ been set of all open connected sets.

Set of all $$\mathcal F$$-piecewise continuous functions is a vector space iff for $$a, b \in \mathcal F$$, $$a \cap b$$ is union of finite number of sets from $$\mathcal F$$.

If we have a family $$\mathcal G$$ of sets s.t. $$\Omega \in \mathcal G$$ and $$\mathcal G$$ is closed under union and difference (for example, set you described - sets constructible from convex by taing finite unions and differences), then $$\mathcal G$$ is also closed under intersection: if $$a, b \in \mathcal G$$ then $$\Omega \setminus a$$, $$\Omega \setminus b$$, $$(\Omega \setminus a) \cup (\Omega \setminus b)$$ and $$\Omega \setminus (\Omega \setminus a) \cup (\Omega \setminus b) = a \cap b$$ are all in $$\mathcal G$$. So $$\mathcal G$$-piecewise continuous functions form a vector space.

UPD: such $$\mathcal G$$ is actually not exactly what was asked about - the original question was about connected sets from $$\mathcal G$$ (or equivalently sets with finite number of connected components). And difference of two convex set can have infinitely many connected components, as your example proves.

A bit simple example will be circle and "polygon" with infinitely many non-zero sides inscribed into it (for example, polygon with vertices $$(\cos 2\pi - \frac{2\pi}{n}, \sin 2\pi - \frac{2\pi}{n})$$).

UPD2: polygons will work. Boundary of intersection is subset of union of boundaries, so boundary of intersection will consist of finite number of line segments (each segment is described by edge it is taken from and at most two edges that give it endpoints) - thus intersection will be finite union of polygons.

• Excellent counterexample to the Lipshitz continuity and more.
– zo0x
Commented Nov 24, 2020 at 8:24
• I just noticed you have made an update to you answer in response to my former edit. I think the family of sets constructible from convex sets is still problematic however; see my edit #2.
– zo0x
Commented Nov 24, 2020 at 14:09
• I suppose it works if the "connected" requirement is dropped, however, I think the original definition also works if that part is dropped.
– zo0x
Commented Nov 24, 2020 at 14:32
• Yes, I forget that base operation (ie difference of two convex sets) doen't preserve finitness of number of connected components. Commented Nov 24, 2020 at 15:14
• I wonder, probably a more general set of shapes could work too. Say, consider polygons, but where each boundary segment between two vertex is allowed to be convex or concave. I think that would work too.
– zo0x
Commented Nov 25, 2020 at 11:00

I think you just need to restrict the allowed subsets (on which the function is continuous) so that they're closed under intersection. These could be axis-aligned rectangles, for example. Or you could require the subsets to be open and convex, not just connected, since the intersection of convex sets is convex.

• Hmm, that seems VERY restrictive. I wonder, what if we say that each set $\omega_i$ should be constructible as the union and difference of a finite set of convex sets.
– zo0x
Commented Nov 24, 2020 at 8:32