3
$\begingroup$

I want to solve the following equation numerically:

enter image description here

with initial condition y[0]=0 and y'[0]=0

I tried to do so by using the NDSolve function:

eqn = Derivative[2][y][x] == 1+y[x] - Integrate[Derivative[1][y][x - t]/sqrt[t], {t, 0, x}]; NDSolve[{eqn, y[0] == 0, Derivative[1][y][0] == 0}, y, {x, 0, 1}]

But it seems like Matlab cannot solve it directly. Do you have any suggestions?

$\endgroup$
3
  • 2
    $\begingroup$ You mean Mathematica cannot solve? You wrote Matlab $\endgroup$
    – L.K.
    Oct 6, 2016 at 11:03
  • $\begingroup$ Convert it to a regular ODE and then feed it to NDSolve[]. $\endgroup$ Oct 6, 2016 at 11:18
  • $\begingroup$ sqrt should be Sqrt. This isn't main issue here of course. $\endgroup$
    – xzczd
    Oct 6, 2016 at 11:22

1 Answer 1

6
$\begingroup$

As mentioned in the comment above, sqrt should be Sqrt and Matlab should be Mathematica, these aren't the main issue here of course. Currently NDSolve can't handle the problem, but we can solve the equation with the help of LaplaceTransform:

teqn = LaplaceTransform[eqn, x, s] /. Rule @@@ ic
tsol = Solve[teqn, LaplaceTransform[y[x], x, s]][[1, 1, -1]]
(* 1/(s (-1 + Sqrt[\[Pi]] Sqrt[s] + s^2)) *)

InverseLaplaceTransform can't handle tsol, so I turned to this numeric Laplace inversion package:

Plot[FT[(s \[Function] #) &@tsol, x], {x, 0, 1}]

Mathematica graphics

Finally, DSolve in v11 can solve this equation in principle, but sadly it doesn't give the correct answer in this case, I think there's no doubt it's a bug:

eqn = y''[x] == 1 + y[x] - Integrate[y'[x - t]/Sqrt[t], {t, 0, x}];

ic = {y[0] == 0, y'[0] == 0};

sol[x_] = y[x]/.First@DSolve[{eqn, ic}, y@x, x]
(* 1/2 E^-x (-1 + E^x)^2 *)
Plot[{sol@x, FT[(s \[Function] #) &@tsol, x]}, {x, 0, 1}, 
 PlotLegends -> {"Output of DSolve", "Numeric Solution"}]

Mathematica graphics

What's more awkward is, if the second argument of DSolve is modified to y i.e. if we write DSolve[{eqn, ic}, y, x], DSolve will return the input... Seems that this new feature is still unstable.

$\endgroup$
2
  • 1
    $\begingroup$ Dsolve gives wrong answer.Can you check it? $\endgroup$ Dec 29, 2016 at 17:24
  • $\begingroup$ @MariuszIwaniuk You're right. DSolve in v11 is more unstable than I thought. Edited. Thanks for point out. $\endgroup$
    – xzczd
    Dec 30, 2016 at 3:01

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