Let $f(x)$ be smooth complex valued function with real argument $x\in[0,1]$. I want to get square root $g(x)=\pm\sqrt{f(x)}$ where the sign is chosen so that g(x) is smooth. How can I do that?

In Mathematica, the branch cut of square root is on negative reals. Thus, for example, I want to flip the sign if $f(x)$ cross negative reals in complex plane when $x$ increases.

  • $\begingroup$ Something like this? Plot[Sign[x]*Sqrt[Abs[x]], {x, -5, 5}] imgur.com/0FoXmC1 $\endgroup$
    – flinty
    Jul 30, 2020 at 13:48
  • $\begingroup$ Are you OK with your "square root" giving different values for different arguments? For example, if $f(x) = e^{2 \pi i x}$, then I think you're forced to have $g(x) = e^{i \pi x}$. But this would mean that $g(0) \neq g(1)$, even though $f(0) = f(1)$. $\endgroup$ Jul 30, 2020 at 14:03
  • $\begingroup$ More generally, if $f(x)$ "winds" around zero as $x$ ranges from 0 to 1, I think you'll be forced to either accept a discontinuity in $g(x)$ or have a multi-valued square root. $\endgroup$ Jul 30, 2020 at 14:05
  • $\begingroup$ Thank you for a comment. Yes, I'm okay with that. I just want to construct smooth $g(x)$ and don't care $g(0)\neq g(1)$. If it's problematic, then let's concentrate on the case "winding number" of $f(x)$ around zero is even number. $\endgroup$ Jul 30, 2020 at 14:13
  • $\begingroup$ Got it. So the goal is to construct a smooth complex-valued function $g(x)$ such that $g^2(x) = f(x)$. $\endgroup$ Jul 30, 2020 at 14:15

1 Answer 1


The problem can be reduced (I think) to the problem of defining a phase function $\arg(f(x))$ that is continuous on the interval $x \in [0, 1]$. This is tricky, because the path $f(x)$ may "wind" around the origin, leading to different values of the "continuous argument" for the same value of the "conventional argument". A successful "continuous argument" function will need to "keep track of the history" of the function $f(x)$, so that it "knows" whether the phase along the positive real axis should be $0$, $2 \pi$, or something else.

One way to do this is to note that although the conventional Arg function is discontinuous along the negative real axis, its derivative is continuous. Specifically, since $\arg(f(x)) = \Im \ln(f(x))$, we have $$ \frac{d}{dx} \left[ \arg(f(x)) \right] = \Im \left[ \frac{f'(x)}{f(x)} \right]. $$ We can treat this as a differential equation for $\arg(f(x))$; if we integrate it, we'll get a "continuous argument" function. $$ \tilde{\arg}(f(x)) \equiv \arg(f(0)) + \int_0^x \Im \left[ \frac{f'(t)}{f(t)} \right] \, dt. $$ With this in hand, we can then define $$ g(x) = \sqrt{|f(x)|} e^{i \tilde{\arg}(f(x))/2} $$ and this function will be continuous.


I will test this function on $f(x) = e^{4 \pi i x}$. Difficulties may arise for more complicated functions, particularly those which have roots where $f(x) = 0$. (However, I believe that no smooth $g(x)$ can be defined in such cases anyhow.)

Continuous argument function:

contarg[f_] :=
  Arg[f[0]] + Integrate[Im[f'[t]/f[t]], {t, 0, #}] &;
f[x_] = Exp[4 \[Pi] I x];
Plot[{Arg[f[x]], Evaluate[contarg[f][x]]}, {x, 0, 1}]

enter image description here

Continuous square root:

contsqrt[f_] := Sqrt[Abs[f[#]]] Exp[I contarg[f][#]/2] &
Plot[Evaluate[ReIm[contsqrt[f][x]]], {x, 0, 1}]
Plot[Evaluate[ReIm[Sqrt[f[x]]]], {x, 0, 1}, PlotStyle -> Dashed]

(* E^(2 I \[Pi] x) Sqrt[E^(-4 \[Pi] Im[x])] *)

enter image description here

enter image description here

For more complicated functions $f(x)$, Mathematica may not be able to perform the integral required to evaluate contarg[f][x]. In such cases, you may have to resort to using NIntegrate instead.

  • $\begingroup$ I'm happy for the very clear idea and grateful for showing precise implementation. Thank you so much! $\endgroup$ Jul 30, 2020 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.