# Second order differential equation of a complex function

I am curious about whether Mathematica can help me solve a second order differential equation of a function in the complex plane. The equation that I am looking to solve is:

$\dfrac{d^2}{dz^2}(u+iv) - 2\pi i(u+iv)=0$

where $u$ and $v$ are functions of $z$ only, $u[z]$ and $v[z]$. The boundary conditions I have are:

$\dfrac{du}{dz}=0 \; at \; z=0$

$\dfrac{dv}{dz}=\dfrac{\tau_{0}}{\mu} \; at \; z=0$

My first attempt to solve this was to try to define a general function for $u + iv$ as:

w[z_] := w[z] = u[z] + I v[z]


and then try to use DSolve:

DSolve[w[z]'' - (2 π I) w[z] == 0, w[z], z]


but I get the following error:

DSolve::dsfun: u[z]+I v[z] cannot be used as a function.

I also don't have any luck if I try to use solve this equation without the function $w[z]$:

DSolve[(u[z] + I v[z])'' - (2 π I) (u[z] + I v[z]) == 0, w[z], z]


since this returns the same error as previously mentioned.

I know that I am missing something pretty major in what I am asking of Mathematica, but I am stuck as to how I can formulate my code. Is there a better way to first decouple this second order equation to a first order ODE, and then use DSolve?

First solve for $w$ and then separate $u$ and $v$ from it:

solw[z_] = w[z] /. First@DSolve[w''[z] - (2 π I) w[z] == 0, w[z], z]
{solu[z_], solv[z_]} = {Re@#, Im@#} &@solw@z // ComplexExpand


You can use ReIm instead of {Re@#, Im@#} & if you're in v10, of course.

I would use @xzczd's approach most of the time. But if someone wants to solve the ODE in terms of component functions u and v, how to do it might not be so obvious to all users. You need to separate real and imaginary parts and simplify it with ComplexExpand.

DSolve[
ComplexExpand[ReIm[D[u[z] + I v[z], z] - 2 Pi I (u[z] + I v[z])], z] == {0, 0},
{u, v}, z]
(*
{{u -> Function[{z}, C[1] Cos[2 π z] - C[2] Sin[2 π z]],
v -> Function[{z}, C[2] Cos[2 π z] + C[1] Sin[2 π z]]}}
*)