1
$\begingroup$

From Sample,This works correctly.

sol = NDSolveValue[{x''[t] + x[t - 1] == 0, x[t /; t <= 0] == t^2}, x, {t, -1, 5}];

Plot[sol[x], {x, -1, 5}]

Now I want to solve the above via Taylor expansion.

sol = NDSolve[{x''[t] + x[t] - x'[t] == 0, x[t /; t <= 0] == t^2}, 
  x, {t, -1, 5}]

This returns a horizontal line. Obviously not the correct. Why?

add) I tried the following with reference to comments.
Although this works certainly, there is still an error.
How does NDSolve solve the above(top's) delayed equation?

sol = NDSolveValue[{x''[t] + x[t] - x'[t] == 0, x[0] == 0, 
   x'[0] == -0.1}, x, {t, 0, 5}];
Plot[sol[x],{x,0,5}]
$\endgroup$
  • 2
    $\begingroup$ You have to specify the initial conditions differently: NDSolve[{x''[t] + x[t] - x'[t] == 0, x[0] == 0, x'[0] == 2}, x, {t, 0, 5}] works as expected. $\endgroup$ – Lukas Lang Jan 8 at 17:52
  • 1
    $\begingroup$ Looking at the sample diagram(unfortunately MMA 11.0.1 can't solve the sample) I would expect a negativ initial slope x'[0]! $\endgroup$ – Ulrich Neumann Jan 8 at 19:37
  • $\begingroup$ @Xminer What error do you mean? On my machine (11.3.0.0), there are no error messages. But I don't get why you set x'[0]==0.1 - to reproduce the result above, you need to set it to x'[0]==2. $\endgroup$ – Lukas Lang Jan 9 at 8:25
  • $\begingroup$ I mean "error" is "the difference between True Answer(by NDSolve) and My Answer(via Taylor Expansion). I set $x'[0]==-0.1$ because $x'[0]=2$ doesn't reproduce the same result asNDSolve[{x''[t] + x[t - 1] == 0, x[t /; t <= 0] == t^2}, x, {t, -1, 5}] $\endgroup$ – Xminer Jan 9 at 17:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.