Show $f$ (assumed continuous and analytic apart from a line segment) is analytic in domain $D$
Show $f$ (assumed continuous and analytic apart from a line segment) is analytic in domain $D$
If $f$ is continuous in a domain $D\subset\mathbb{C}$, and $f$ is analytic in $D \setminus L$ where $L$ is a line segment ($L \subset D$), then show $f$ is analytic in $D$.
I guess I have to use Morera's Theorem to prove this. But, I'm not exactly sure how to approach this.
Any help would be appreciated!
I shall prove a more general result for you, i.e. by replacing line segment with line. You are right, the idea is to use Morera's theorem. Note that (in the proof below) you can replace $\mathbb C$ by any domain $D$, the proof stays the same. If needed, the domain $D$ can be brought closer to the real line (so that I may assume $L$ is a subset of the real line) by means of translation; which is a homeomorphism. Lastly, I have used "holomorphic" instead of "analytic", but these are equivalent notions. The essence of the argument lies in how to use Morera's theorem, as you shall see. $\newcommand{\C}{\mathbb C}$ $\renewcommand{\Im}{\operatorname{Im}}$ $\renewcommand{\Re}{\operatorname{Re}}$
Theorem. If a continuous function $f:\C\to\C$ is holomorphic outside a line $L$ in $\mathbb C$ then it is holomorphic everywhere.
Without loss of generality, we may assume that $L$ is the real line. This can be arranged by means of an affine transformation. In fact, it is easy to see that the reasoning that follows works for any line $L$ in $\C$. In other words, it is affine-invariant. We shall use Morera's theorem to show that $f$ is entire.
Morera's Theorem. Let $G$ be an open, connected subset of $\C$, and let $f: G\to \C$ be a continuous function such that $\int_T f(z) dz = 0$ for every triangular path $T$ in $G$; then $f$ is analytic in $G$.
In our case, $G = \C$. Let $T$ be a triangle (without interior) in $\C$. $\int_T f(z) dz = 0$ for every $T$ contained entirely in $\mathbb H_1 = \{z\in \C: \Im z > 0\}$ or $\mathbb H_2 = \{z\in \C: \Im z < 0\}$ by Cauchy's theorem. It remains to consider the case where $T$ intersects the real line. Decomposing $T$ into smaller triangles, it suffices to consider the case where $T$ has an edge on the real line. $\color{red}{^1}$ Without loss of generality, suppose $T$ lies in $\overline{\mathbb H_1}$. Let $T$ have vertices $A,B$ and $C$ as in the figure below. We can find a compact set $K \subset \C$ containing $T$. Since $f$ is continuous, $f(K)$ is compact, hence bounded. That is, there exists $M > 0$ such that $|f(z)| \le M$ for all $z\in K$.
Construct a line segment $B_\delta C_\delta$ parallel to $BC$, at height $\delta > 0$ above the base. Drop perpendiculars $B_\delta B_\delta'$ and $C_\delta C_\delta'$ on $BC$. $$\int_{ABC} f(z)\, dz = \int_{AB_\delta C_\delta} f(z)\, dz + \int_{B_\delta BC C_\delta} f(z)\, dz$$ By Cauchy's theorem, $$\int_{AB_\delta C_\delta} f(z)\, dz = 0$$ as $AB_\delta C_\delta$ lies entirely inside $\mathbb H_1$, where $f$ is holomorphic. So, $$\int_{ABC} f(z)\, dz = \int_{B_\delta BC C_\delta} f(z)\, dz$$ Since $\delta > 0$ is arbitrary, take limits as $\delta\to 0$. Then, $$\int_{ABC} f(z)\, dz = \lim_{\delta\to 0} \int_{B_\delta BC C_\delta} f(z)\, dz$$ Also, $$\int_{B_\delta BC C_\delta} f(z)\, dz = \int_{B_\delta B B_\delta'} f(z)\, dz + \int_{B_\delta B_\delta' C_\delta' C_\delta} f(z)\, dz + \int_{C_\delta C_\delta' C} f(z)\, dz$$ As $\delta\to 0$, $\operatorname{len} (B_\delta B B_\delta') \to 0$ and $\operatorname{len} (C_\delta C_\delta' C)\to 0$. We have $$\left| \int_{B_\delta B B_\delta'} f(z)\, dz \right| \le \sup_{z\in B_\delta B B_\delta'} |f(z)| \operatorname{len}(B_\delta B B_\delta') \le M \operatorname{len}(B_\delta B B_\delta') \xrightarrow{\delta\to 0} 0$$ and $$\left| \int_{C_\delta C_\delta' C} f(z)\, dz \right| \le \sup_{z\in C_\delta C_\delta' C} |f(z)| \operatorname{len}(C_\delta C_\delta' C) \le M \operatorname{len}(C_\delta C_\delta' C) \xrightarrow{\delta\to 0} 0$$ Moreover, $$\int_{B_\delta B_\delta' C_\delta' C_\delta} f(z)\, dz = \int_{B_\delta' C_\delta'} f(z)\, dz + \int_{C_\delta B_\delta} f(z)\, dz + \int_{B_\delta B_\delta'} f(z)\, dz + \int_{C_\delta' C_\delta} f(z)\, dz$$ As $\delta\to 0$, $\operatorname{len}(B_\delta B_\delta') \to 0$ and $\operatorname{len}(C_\delta' C_\delta) \to 0$. We have $$\left|\int_{B_\delta B_\delta'} f(z)\, dz \right| \le \sup_{z\in B_\delta B_\delta'} |f(z)| \operatorname{len}(B_\delta B_\delta') \le M \operatorname{len}(B_\delta B_\delta') \xrightarrow{\delta\to 0} 0$$ and $$\left|\int_{C_\delta' C_\delta} f(z)\, dz \right| \le \sup_{z\in C_\delta' C_\delta} |f(z)| \operatorname{len}(C_\delta' C_\delta) \le M \operatorname{len}(C_\delta' C_\delta) \xrightarrow{\delta\to 0} 0$$ Lastly, $$\int_{B_\delta' C_\delta'} f(z)\, dz + \int_{C_\delta B_\delta} f(z)\, dz \xrightarrow{\delta\to 0} 0$$ as the segments $B_\delta C_\delta$ and $B_\delta' C_\delta'$ both approach $BC$, as $\delta\to 0$.$\color{red}{^2}$ Therefore, $$\int_{ABC} f(z)\, dz = \lim_{\delta\to 0} \int_{B_\delta BC C_\delta} f(z)\, dz = 0$$ We conclude that $$\int_T f(z)\, dz = 0$$ for every triangle in $\C$. By Morera's theorem, $f$ is holomorphic on $\C$, i.e. $f$ is entire.
Footnotes:
$\color{red}{1.}$ This argument is standard; see, for example, the proof of Schwarz Reflection Principle.
$\color{red}{2.}$ A similar argument is seen in the proof of Cauchy's integral formulae (the keyhole contour construction).
Related Posts: See Post 1, Post 2.