# Complex first-order differential equation

I have a differential equation

$$\frac{dx}{dt} = \sqrt{1+x^4}$$

$$x$$ is a complex variable.

I want to solve it for some given initial condition, and plot the solution (real part vs. imaginary part).

I've tried this

sol = NDSolve[{x'[t] == Sqrt[1 + x[t]^4], x[0] == 1 + I}, x[t], {t, 0, 20}, Method -> "ExplicitMidpoint", "StartingStepSize" -> 1/1000];
ParametricPlot[Evaluate[{Re[x[t]], Im[x[t]]} /.sol], {t, 0, 20}]


But the result is not what I was expecting, it should be something similar to this

But if I use the direction fields:

With[{xMin = 3}, StreamPlot[{Re[#], Im[#]} &[Sqrt[1 + (x + I y)^4]], {x, -xMin, xMin}, {y, -xMin, xMin}]]


The result somehow resembles what I want:

How can I obtain the correct plot just by solving the differential equation?

• Plot3D[Re[Sqrt[1 + (re + im*I)^4]], {re, 0, 2}, {im, 0, 2}] and Plot3D[Im[Sqrt[1 + (re + im*I)^4]], {re, 0, 2}, {im, 0, 2}] show a branch cut that is probably giving NDSolve fits. Sorry, I don't have a fix though! Jan 10, 2019 at 19:05
• What's the source of your expected plot? Jan 10, 2019 at 19:20
• @ Chris K Thanks for your comment. It's a part of my university homework. Jan 10, 2019 at 19:28
• Mathematica can solve this exactly by separating the variables and integrating, which will give same curve as Michael E2's, but I don't understand what parameter you are varying to get your other expected curves. Jan 11, 2019 at 1:13

This, which is substantially the same as the OP's, looks correct as far as it goes:

sol = NDSolve[{x'[t] == Sqrt[1 + x[t]^4], x[0] == 1 + I},
x, {t, -3, 3}, Method -> "ExplicitMidpoint", "StartingStepSize" -> 1/1000];
ParametricPlot[Evaluate[{Re[x[t]], Im[x[t]]} /. sol],
Evaluate@Flatten@{t, x["Domain"] /. sol[[1]]}, AspectRatio -> 0.6]


You can see from the StreamPlot that the stream lines reverse direction where the plot of sol stops. That is why the integration stops.

A workaround is to raise the order by differentiating the rationalized ODE:

sol = NDSolve[{D[x'[t]^2 == 1 + x[t]^4, t], x[0] == 1 + I,
x'[0] == Sqrt[1 + x[0]^4]}, x, {t, -3, 3},
Method -> "ExplicitMidpoint", "StartingStepSize" -> 1/1000];
ParametricPlot[Evaluate[{Re[x[t]], Im[x[t]]} /. sol],
Evaluate@Flatten@{t, x["Domain"] /. sol[[1]]}, AspectRatio -> 0.6]


• This is very intelligent. Jan 10, 2019 at 20:03
• @Callmeatomato. Thanks for the compliment and the accept. I feel like it's a standard trick. The same trick was used on a much thornier problem here by Carl Woll and by me, as well as in one of the Q&A linked to it. Jan 10, 2019 at 21:44
• Thanks for the link. Your answer to that question is frightening! I need a couple of months to digest that. Jan 10, 2019 at 22:09