# Given the u or v of the analytic function f(z), find f(z)

Given the u or v of the analytic function f(z), find f(z):

z=x+I y,

f[z]=u[x,y]+I v[x,y]

Given $$v=\left[-x+\left(x^2+y^2\right)^{1 / 2}\right]^{1 / 2}, f(0)=0$$

Then find f[z].

First, I get u[x,y] by Total derivative method.

Clear["Global*"];
exactQ[{P_, Q_}, {x_, y_}] := D[P, y] == D[Q, x] // Simplify;
exactQ[{P_, Q_, R_}, vars_] :=
Curl[{P, Q, R}, vars] == {0, 0, 0} // Simplify;
exactSolve[vf_, vars_] /; exactQ[vf, vars] :=
Fold[#1 + Integrate[#2[[1]] - D[#1, #2[[2]]], #2[[2]]] &, 0,
Transpose[{vf, vars}]]

v[x_, y_] := (-x + (x^2 + y^2)^(1/2))^(1/2)

dtu[x_, y_] := {D[v[x, y], y], -D[v[x, y], x]}
u[x, y] = exactSolve[dtu[x, y], {x, y}]


(* $$\frac{y}{\sqrt{-x+\sqrt{\mathrm{x}^2+\mathrm{y}^2}}}$$ *)

Then I tried to find f[z], but the result was not completely simplified. I don't know what caused it and how to modify the code. The correct answer in the textbook is $$f(z)=\sqrt{2 z}$$.

ClearAll["Global*"]

u[x, y] = y/Sqrt[-x + Sqrt[x^2 + y^2]];

v[x, y] = (-x + (x^2 + y^2)^(1/2))^(1/2);

f[x, y] = (u[x, y] + c) + I v[x, y] // Simplify
eq = Simplify[f[x, y], {x + I*y == z}] /. z -> 0
sol = Solve[eq == 0, c]
f[x, y] = f[x, y] /. sol[[1]]

expr = Simplify[f[x, y], {x + I*y == z}]


(* $$-\frac{{\mathbb{i} z}}{\sqrt{-x+\sqrt{x^2+y^2}}}$$ *)

EDIT

ClearAll["Global*"]

u[x, y] = y/Sqrt[-x + Sqrt[x^2 + y^2]];

v[x, y] = (-x + (x^2 + y^2)^(1/2))^(1/2);

f[x, y] = u[x, y] + c + I v[x, y];
eq = Simplify[f[x, y], {x + I*y == z}] /. z -> 0;
sol = Solve[eq == 0, c];
f[x, y] = f[x, y] /. sol[[1]]

f[z_] :=
FullSimplify[
f[x, y] /. {x -> (z + Conjugate[z])/2,
y -> (z - Conjugate[z])/(2 I)}, Element[x | y, Reals]];

f[z]


(* -((I z)/Sqrt[Abs[z] - Re[z]]) *)

But the result -((I z)/Sqrt[Abs[z] - Re[z]]) cannot be simplified to the textbook result Sqrt[2 z]. I did not detect any obvious errors in my code, and it obtained correct results when used on other complex functions. I don't know where the problem is.

• Since the CR-equation holds on the whole plane except 0, why not just take the value on real or imaginary axis? e.g. u[x,0]+I v[x,0] Commented Jul 2, 2023 at 10:10
• It is customary to acknowledge the source of borrowed code. (Borrowing is welcome, but please cite it.) Commented Jul 2, 2023 at 13:49
• @Lacia Thank you for your suggestion. But this method has achieved correct results in other functions, so I think it should be a simplification problem. Commented Jul 2, 2023 at 14:57
• @Michael E2 I'm very sorry that there was no citation before and it has been edited. Thank you for the reminder and excellent code. Commented Jul 2, 2023 at 15:02
• It's no problem. Thanks for the edit. :) Commented Jul 2, 2023 at 15:07

First of all, your code in this block:

f[x, y] = (u[x, y] + c) + I v[x, y] // Simplify
eq = Simplify[f[x, y], {x + I*y == z}] /. z -> 0
sol = Solve[eq == 0, c]
f[x, y] = f[x, y] /. sol[[1]]


sets the constant c to -((I Sqrt[x^2 + y^2])/Sqrt[-x + Sqrt[x^2 + y^2]]). I assume this is not the intended effect, and I think it actually makes your answer wrong (or, perhaps, "more wrong".) Your real value of $$f$$, assuming that $$c = 0$$, should be

u[x, y] = y/Sqrt[-x + Sqrt[x^2 + y^2]];
v[x, y] = (-x + (x^2 + y^2)^(1/2))^(1/2);
f[x_, y_] = (u[x, y] + c) + I v[x, y] // Simplify

f[z_] = f[x, y] /. {x -> 1/2 (z + Conjugate[z]), y -> 1/(2 I) (z - Conjugate[z]), c -> 0}

FullSimplify[f[z]]

(* (I (-z + Abs[z]))/Sqrt[Abs[z] - Re[z]] *)


But this is not actually equal to $$\sqrt{2z}$$ over the entire complex plane, at least as Mathematica defines the square root function:

Reduce[f[z] == Sqrt[2 z], z]
(* (Re[z] < 0 && Im[z] >= 0) || (Re[z] >= 0 && Im[z] > 0) *)


So, for example, we have

ComplexExpand[{f[-I], Sqrt[-2I]}]
(* {-1 + I, 1 - I} *)


More generally, it appears that in the complement of the region found above, your $$f(z)$$ is equal to $$-\sqrt{2z}$$ instead; and everywhere on the plane we have $$f(z)^2 = 2 z$$:

FullSimplify[f[z]^2]
(* 2 z *)


Plotting out the functions, it also appears that your function is equal to $$\sqrt{2z}$$ if you define the branch cut to lie on the positive real axis, while Mathematica defines the branch cut to lie on the negative real axis:

{ComplexPlot3D[f[z], {z, -2 - 2 I, 2 + 2 I}],
ComplexPlot3D[Sqrt[2 z], {z, -2 - 2 I, 2 + 2 I}]


This kind of ambiguity is to be expected when dealing with functions with branch cuts.

• This is so clean and clear: wish could give more than+1 Commented Jul 5, 2023 at 22:31

This can be done as follows. Starting from your

ClearAll["Global*"]
u[x, y] = y/Sqrt[-x + Sqrt[x^2 + y^2]];v[x, y] = (-x + (x^2 + y^2)^(1/2))^(1/2);


, we have

FullSimplify[ ComplexExpand[y/Sqrt[-x + Sqrt[x^2 + y^2]] +
I*(-x + (x^2 + y^2)^(1/2))^(1/2) /. {x -> r*Cos[\[Theta]],
y -> r*Sin[\[Theta]]}], Assumptions -> r > 0 && \[Theta] >= 0 && \[Theta] <= Pi]


Sqrt[2] E^((I \[Theta])/2) Sqrt[r]

and

Sqrt[2] E^((I \[Theta])/2) Sqrt[r] /. {r -> Abs[z], \[Theta] -> Arg[z]}


Sqrt[2] E^(1/2 I Arg[z]) Sqrt[Abs[z]]

in the upper complex half-plane. Making use of the Riemann-Schwarz principle with the positive ray of the real axis as $$\gamma$$, we draw the conclusion this is valid in the whole complex plane with the cut along the negative ray of the real axis.

• FullSimplify[ ComplexExpand[ y/Sqrt[-x + Sqrt[x^2 + y^2]] + I*(-x + (x^2 + y^2)^(1/2))^(1/2) /. {x -> Abs[z]*Cos[Arg[z]], y -> Abs[z]*Sin[Arg[z]]}], Assumptions -> Abs[z] >= 0 && Arg[z] >= 0 && Arg[z] <= Pi] results in Sqrt[2] E^(1/2 I Arg[z]) (z^2)^(1/4) which is not OK. Commented Jul 2, 2023 at 17:16

By inspection, it is the imaginary part of a function of $$z=r e^{i \phi}$$. In polar coordinates we identify the radicand as the square of the half angle sine

$$i \sqrt{\sqrt{x^2+y^2}-x}=i \sqrt{r-r \cos (\phi )}=i \sqrt{2 r \sin ^2\left(\frac{\phi }{2}\right)}=i \sqrt{2 r} \sin \left(\frac{\phi }{2}\right)=i \Im\left(\sqrt{2 r} e^{\frac{i \phi }{2}}\right)=i \Im\left(\sqrt{2 r e^{i \phi }}=i \Im\left(\sqrt{2 z}\right)\right)$$

Mathematica is not very good in irrational verifying.

I Sqrt[-x + Sqrt[x^2 + y^2]] == I Sqrt[r - r Cos[[Phi]]] == I Sqrt[2 r (Sin[[Phi]/2]^2) ] == Sqrt[2 r] I Sin[[Phi]/2] == I Im[Sqrt[2 r] E^(I [Phi]/2)] == I Im [Sqrt[2 r E^(I [Phi])] == I Im[Sqrt[2 z]]

The Cauchy-Riemann equations can be integrated, but again without running into irrationals, only if one knows the result. It's therefore, I assume, that the result is given in advance-

      ((-Integrate[D[#, x], y] + I #  )^2 &)[Sqrt[
x - Sqrt[x^2 + y^2]]] // Simplify

-2 (x + I y)

• Thank you for your answer. But I think it's more like a mathematical approach, suitable for manual calculation. I am looking for a MMA solution to this problem. @Roland F Commented Jul 2, 2023 at 15:06