0
$\begingroup$

I try to solve this equation numerically :

eq= z''[t] + (2691+ D[Log[Abs[z'[t]^2]],t]) (z'[t]^2 + Abs[z'[t]]^2 ) == 0;

By NDSolveValue with arbitrary initial conditions:

NDSolveValue[{eq, z[0]==0.1, z'[0]==1}, z, {t,0,25}]

But this gives an error:

Encountered non-numerical value for a derivative at t == 0..`

Declaration:

The error goes when I remove the Abs function, I.e., writing z'[t]^2 instead of Abs[z'[t]]^2 .

However the function z[t] is complex and I want to keep solving in case of Abs[z'[t]]^2. Any idea how to write this in a better syntax so that Mathematica can find numerical values?

Thanks

$\endgroup$
2
  • $\begingroup$ However the function z[t] is complex but this is the function you are solving for. How do you know it is complex before solving for it? It is better to just solve for z[t] and after finding the solution you could look at its abs, real part or imaginary part and so on. $\endgroup$ – Nasser Jul 7 '20 at 12:52
  • $\begingroup$ I know the function is complex because I'm studing, so in my analytic calculations there are z[t] and $z^*[t]$ . But I wanna to avoid using Conjugate[z[t]] in NDSolve so I'm using Abs instead. $\endgroup$ – Dr. phy Jul 7 '20 at 13:26
4
$\begingroup$

One way is to use RealAbs :

eq = z''[t] + (2691 + D[Log[RealAbs[z'[t]^2]], t]) (z'[t]^2 + RealAbs[z'[t]]^2) == 0;
sol = NDSolveValue[{eq, z[0] == 0.1, z'[0] == 1}, z, {t, 0, 25}];
Plot[sol[t], {t, 0., 25.}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks @rmw , but RealAbs is for real numbers, so the result is the same as if I used z'[t] ^2 . I just think numeric solving for complex numbers in Mathemtica is not trivial $\endgroup$ – Dr. phy Jul 7 '20 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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