TITLE: Existence of an antiderivative in $U \cup V$ if it exists in both $U$ and $V$
QUESTION [8 upvotes]: I'm doing this exercise where I know that a function $f$ that is holomorphic in $U \cup V$, has a holomorphic antiderivative in $U$ and also another holomorphic antiderivative in $V$, where $U, V \subseteq \mathbb{C}$ are open sets such that $U \cap V \neq \emptyset$ and $U \cap V$ is connected. 


Then the question is to prove that $f$ has a holomorphic antiderivative in the union $U \cup V$, and provide a counterexample to show that the hypothesis on the intersection $U \cap V$ are required for the result to be true.


My attempt
I thought that since there are holomorphic functions $F: U \rightarrow \mathbb{C}$ and $G: V \rightarrow \mathbb{C}$ such that $F' = f$ in $U$ and $G' = f$ in $V$, then in the intersection both derivatives coincide so in $U \cap V$ we have $F' = G'$ and so $F = G + C$ in $U \cap V$, where $C$ is a constant. But now my problem is that I don't see how to extend this to the whole union $U \cup V$, and I don't see where I'll use the connectedness assumption.
So if you could help me with my argument I would be most grateful. By the way, if you could also give me a hint to construct a counterexample that would be great. Thanks.

REPLY [2 votes]: Suppose $f(z)=1/z$.  Let $U$ be the open upper half-plane plus a small area surrounding $1$ (say a small open disk of radius $1/10$) and another surrounding $-1$.  Let $V$ be the open lower half-plane plus a small area surrounding $1$ and another surrounding $-1$.
Then $f$ has a holomorphic antiderivative on $U$ and another on $V$, but if I'm not mistaken, it has none on $U\cup V$.