7
$\begingroup$

This ODE (#50 from Murphy's ODE collection book) causes kernel crash each time

enter image description here

Here is the code

ClearAll[y, x]
DSolve[ y'[x] == Cos[2 x] + (Sin[2 x] + y[x]) y[x], y[x], x]

Screen shot below. Should this be tagged a bug? Does this happen on other platforms? I am using windows 7. I tried it on 10.4, and it also crashes there.

Mathematica graphics

But on version 9.0, it does not crash, but it can't solve it:

Mathematica graphics

Maple can solve it, but solution is complicated using HeunC special functions which Mathematica do not have

Mathematica graphics

But Book also gives one simple solution y(x)=tan(x), which is easily verified to be true by Mathematica. (the other solution it gives is little more complicated).

eq = Hold [D[y[x], x] == Cos[2 x] + (Sin[2 x] + y[x]) y[x]];
Simplify[ReleaseHold[eq /. y[x] -> Tan[x]]]

Mathematica graphics

Why does Mathematica kernel crash on this ODE?

Update:

Send bug report to Wolfram support, CASE:3806616 .

fyi, the book contains 2315 ODE's, which will take me long time to type and run. The current test report if you are interested is here. But it currently contains small number of ODE's from the book, will add more with time.

$\endgroup$
  • 1
    $\begingroup$ Linux v11, get's stuck, but doesn't crash. $\endgroup$ – Feyre Dec 23 '16 at 20:21
  • 1
    $\begingroup$ The code crashes v10.3.1 and v11.0.0, both on Windows 64-bit $\endgroup$ – JungHwan Min Dec 23 '16 at 20:44
  • $\begingroup$ @Feyre what do you mean by 'stuck'? No solution or evaluation taking too long? For me, the code seems to crash the kernel 2-3 minutes after its evaluation. $\endgroup$ – JungHwan Min Dec 23 '16 at 20:46
  • $\begingroup$ @JungHwanMin I let it run for 10m, without result, I'm considering letting it run for an hour just to see if anything happens. It should be noted I have 16gb of RAM, which is still more than most today, which might have to do with it. $\endgroup$ – Feyre Dec 23 '16 at 20:56
  • $\begingroup$ I would go head and send a report to support@wolfram.com so that they can investigate and look address this. $\endgroup$ – user6014 Dec 23 '16 at 21:22
9
$\begingroup$

A bit too long for a comment. I think the hang is happening within Integrate:

Block[{Integrate},
  DSolve[y'[x] == Cos[2 x] + (Sin[2 x] + y[x]) y[x], y[x], x] /. {
    Integrate -> Inactive[Integrate]}
]

enter image description here

Edit

Here's the solution using withTimedIntegrate (as Micheal E2 pointed out in the comments):

withTimedIntegrate[DSolve[y'[x] == Cos[2 x] + (Sin[2 x] + y[x]) y[x], y[x], x], 1]

enter image description here


And just for fun, here's a way to solve this ODE:

  • Substitute y[x] == v'[x]/v[x] to get

    v''[x] - Sin[2x]v'[x] + Cos[2x]v[x] == 0

  • Next substitute Cos[x] == t to get

    (t^2 - 1)v''[t] + (2t^3 - t)v'[t] + (1 - 2t^2)v[t] == 0

  • Then substitute v[t] == t w[t] to get

    t(t^2 - 1)w''[t] + (2t^4 + t^2 - 2)w'[t] == 0

  • Substitute f[t] = w'[t] to get the first order separable equation

    t(t^2 - 1)f'[t] + (2t^4 + t^2 - 2)f[t] == 0

  • This equation is easily solved, and the solution is

    {{f[t] -> (E^-t^2 C[1])/(t^2 Sqrt[1 - t^2])}}

  • One can then perform all the back substitutions to get the final answer, which is where some nasty integrals will come into play.

$\endgroup$
  • 1
    $\begingroup$ "This equation is easily solved", MMA doesn't seem to think so. $\endgroup$ – Feyre Dec 23 '16 at 22:08
  • 1
    $\begingroup$ withTimedIntegrate[DSolve[..], 1] gives a slightly nicer result, with only the intractable integral left in the answer. (+1) $\endgroup$ – Michael E2 Dec 23 '16 at 22:16
  • 1
    $\begingroup$ @Feyre I should've tested before I said that... MMA get's tripped up on a hard integral. I've edited my post to get to a solution that is easier to solve. $\endgroup$ – Chip Hurst Dec 23 '16 at 22:26
  • $\begingroup$ @MichaelE2, thanks for pointing me to withTimedIntegrate! $\endgroup$ – Chip Hurst Dec 23 '16 at 22:27

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.