# Solving this Second Order D.E

I'm trying to solve this second order D.E.

eq[t_] = x''[t] - (D[Log[solx[t]], t] + D[Log[Abs[D[x[t], t]]^2], t]) (x'[t]^2 + Abs[x'[t]]^2)



where:

solx[t_] := -0.7 (0.0015 + t)^(-2)


But both the analytic or numeric solutions give errors:

DSolve[{eq[t] == 0, x[0] == 1}, x[t], t] // FullSimplify


Or

NDSolveValue[{eq[t] == 0, x[0] == 1, x'[1] == 0}, x, {t, 0, 10}]


The initial conditions are so arbitrary. So any help to make these solutions work ?

The OP adds that x[t] is to be complex. Since D[] treats functions as complex analytic and Abs[] is not differentiable anywhere, one is forced to deal with the real-analytic components Re[x[t]] and Im[x[t]] of x[t]. It was easier to just "see" how to write the problematic term in terms of these parts than to figure out how to get Mathematica to transform the original equation.

D[Log[ComplexExpand[Abs[D[u[t] + I*v[t], t]]^2]], t]
(term = 2 Re[x'[t] Conjugate[x''[t]]]/Abs[x'[t]]^2) /.
x -> Function[t, u[t] + I*v[t]] // ComplexExpand // Simplify

(*
(2 u'[t] u''[t] + 2 v'[t] v''[t])/(u'[t]^2 + v'[t]^2)
(2 u'[t] u''[t] + 2 v'[t] v''[t])/(u'[t]^2 + v'[t]^2)
*)

ClearAll[x, t, solx, eq];
solx[t_] := -7/10 (15/10000 + t)^(-2)

eq[t_] = x''[t] - (D[Log[solx[t]], t] + term) *
(x'[t]^2 + Abs[x'[t]]^2);

DSolve[{eq[t] == 0, x[0] == 1}, x[t], t]

(*  \$Aborted  (killed DSolve[] after a minute or so) *)

sol = NDSolveValue[{eq[t] == 0, x[0] == 8/10, x'[0] == -1/40 + I/40},
x, {t, 0, 10}]

ReImPlot[sol[t], {t, 0, 10}]


If you really want to solve a BVP as in the OP — it seems an off-handedly tossed-out problem, though — use your understanding of the problem to pick good "StartingInitialConditions".

Original answer, assuming x[t] is real as it is in the example

1. Use exact coefficients, not floating-point (inexact) numbers.
2. Abs is the complex absolute value and is not differentiable. Use RealAbs or apply ComplexExpand to it or its derivative.

This gives a solution:

ClearAll[x, t, solx, eq];
solx[t_] := -7/10 (15/10000 + t)^(-2)

eq[t_] = x''[
t] - (D[Log[solx[t]], t] +
D[Log[RealAbs[D[x[t], t]]^2], t]) (x'[t]^2 + RealAbs[x'[t]]^2)

DSolve[{eq[t] == 0, x[0] == 1}, x[t], t]


BVP's are difficult to solve if the ODE is prone to singularities. This gives a solution:

NDSolveValue[{eq[t] == 0, x[0] == 1, x'[1] == -1}, x, {t, 0, 10}]

• The RealAbs changes seems to matter more than conversion to exact coefficients. Commented Aug 9, 2020 at 22:43
• @Michael E2. Thanks. But x[t] is a complex function. I don't want to use RealAbs cause that makes it real. Commented Aug 10, 2020 at 6:44
• @Dr.phy The DSolve and NDSolve problems you proposed were real-only, so I assumed x[t] was real. Commented Aug 10, 2020 at 14:30
• @Dr.phy I meant to point out, besides why I assumed x was real, that I added a complex solution, too. Commented Aug 12, 2020 at 22:04