Extension of a Sobolev Function

Let $$\Omega _1$$ and $$\Omega_2$$ are smooth open sets and $$A= \partial \Omega_1 \cap \partial \Omega_2.$$ Let $$\Omega ^\prime = \Omega_1 \cup \Omega_2 \cup A$$ be an open set. Let $$f$$ is defined on $$\Omega^\prime$$ such that $$f |_{\Omega_1 }:=g_1 \in H^1 (\Omega_1 )$$ and $$f |_{\Omega_2}:=g_2 \in H^1 (\Omega_2 )$$. Let the traces of $$g_1$$ and $$g_2$$ agree on A. Then can we say that $$f \in H^1(\Omega^\prime)$$?

Then answer is yes. Here is a proof: For each $$j=1,\ldots,n$$ put $$f_j:=\partial_jg_1 \chi_{\Omega_1}+\partial_j g_2 \chi_{\Omega_2}$$. Clearly, $$f_j\in L^2(\Omega')$$. If we can show that the weak (distributional) derivative of $$f$$ coincides with $$f_j$$, we obtain $$f\in H^1(\Omega')$$. To this end, we simply verify for any $$\phi\in C^\infty_0(\Omega')$$ that: \begin{align*} \int_{\Omega'} f\,\partial_j\phi\,dx &= \int_{\Omega_1} f\,\partial_j\phi\,dx + \int_{\Omega_2} f\,\partial_j\phi\,dx\\ &= \int_{\Omega_1} g_1\,\partial_j\phi\,dx + \int_{\Omega_2} g_2\,\partial_j\phi\,dx\\ &= -\int_{\Omega_1} \partial_j g_1\, \phi\,dx + \int_{A} g_1\, n_j\, \phi\, d\sigma - \int_{\Omega_2} \partial_j g_2\,\phi\,dx + \int_{A} g_2\, (-n_j)\, \phi\, d\sigma\\ &= -\int_{\Omega_1} \partial_j g_1\, \phi\,dx - \int_{\Omega_2} \partial_j g_2\,\phi\,dx = -\int_{\Omega'} f_j\,\phi\,dx. \end{align*} Observe that the boundary integrals reduce to integrals over $$A$$ since $$\phi=0$$ on $$\partial\Omega'\setminus A$$. Observe also the sign in $$-n_j$$ in the second boundary integral due to $$n$$ denoting the outer normal on $$\Omega_1$$.
Edit: As pointed our @Apratim, the partial integration above is valid since $$\Omega_1$$ and $$\Omega_2$$ are assumed to be smooth. So no further regularity assumptions needed on $$A$$.
• Thanks for the nice solution. Please note that we don't need any assumption on $A$, as you did integration by parts on $\Omega_1$ and $\Omega_2$, which are smooth. – Apratim Bhattacharya Jun 10 at 11:23
• @Apratim: You are right, no assumptions are needed on $A$ since $\Omega_1$ and $\Omega_2$ are already assumed to be smooth. I edited the answer accordingly. – StarBug Jun 10 at 12:10