Consider the following DDE:

$ f''(x)+ f(x+ 1) = 0.$

For $ x \gg 1$, this DDE should approximately reduce to that of a simple harmonic oscillator: $f''(x)+f(x) \approx 0$. Suppose that for some physical reason I require $f(x) = \sin{x}$ for large $x$ and then use this as a ``history'' for the above DDE. I am then interested to see what $f(x)$ is in the vicinity of $x=0$.

The problem is that (not surprisingly) depending on where I set the history condition (when using NDSolve), I get a different answer for $f(x)$ near $x=0$. Any suggestions for how to properly handle this?

  • $\begingroup$ Plase read Math Stackexchange question 2765086 "Writing the recursive as explicit" and its answers for ideas. Also see [MSE question 2245492] (math.stackexchange.com/q/2245492) "Continuous recursive iteration" for $\,f'(x)=f(x-1).$ $\endgroup$ – Somos Jan 2 at 2:06
  • $\begingroup$ Thanks Somos, but my question is how to use NDSolve to handle this problem. $\endgroup$ – Sina Jan 2 at 2:22
  • $\begingroup$ Ah, yes. I should have mentioned that I don't think NDSolve[] is going to help. $\endgroup$ – Somos Jan 2 at 2:34
  • $\begingroup$ In the documentation of NDSolveValue I found an example which might help(NDSolveValue[{x'[t] == x[t] (x[t - Pi] - x'[t - 1]), x[t /; t <= 0] == Cos[t]}, x, {t, 0, 8}]): Instead of initial conditions try f[t /; t >= 0] == Sin[t] $\endgroup$ – Ulrich Neumann Jan 2 at 9:34
  • 11
    $\begingroup$ You haven't accepted any answers to any of your questions. You can accept the answer, if any, that solves your problem, by clicking the checkmark sign. $\endgroup$ – Michael E2 Feb 3 at 23:23

Assuming an asymptotic 2Pi-periodic solution f[t]==s Sin[t]+ c Cos[t] the ode can be integrated:

first integration:

gl1 = f'[x] - f'[0] == Integrate[f[1 + u], {u, 0, x}] /. f -> (c Cos[#]+ s Sin[#] &)
gl1/. x->2Pi (* 2Piperiodic boundary conditions*)
(* True*)

second integration

gl2 = f[x] - f[0] - f'[0] x ==Integrate[f[1 + u], {v, 0, x}, {u, 0, v}] /.f -> (c Cos[#] + s Sin[#] &)
sol=Solve[gl2 /. x -> 2 Pi, s][[1]]
(*{s -> (c Sin[1])/(1 + Cos[1])}*)

Asymptotic solution:

fasy=(c Cos[#] + s Sin[#] )& /. sol /.c->1;
(*Cos[x] + (Sin[1] Sin[x])/(1 + Cos[1])*)

The initial values evalute to

{fasy[0], Derivative[1][fasy][0]}
(*{1, Sin[1]/(1 + Cos[1])}*)
sol = NDSolve[{f''[x] + f[x + 1] == 0, f[x /; x >= 0] == Sin[x]}, f, {x, 0, 8Pi}][[1]]
Plot[{Evaluate[f[x] /. sol], Sin[x]}, {x, 0, 8 Pi}]
  • $\begingroup$ For the case x /; x >= 0 NDSolve returns Sin[x] as result. Varying the lower limit for x (x /; x >= x0 ) shows, that the initial values change and increase depending on x0. $\endgroup$ – Ulrich Neumann Jan 2 at 10:15

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.

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