# Specifying history for delay differential equations near infinity'' (using NDSolve)

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?

• 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).$ Jan 2 '19 at 2:06
• Thanks Somos, but my question is how to use NDSolve to handle this problem.
– Sina
Jan 2 '19 at 2:22
• Ah, yes. I should have mentioned that I don't think NDSolve[] is going to help. Jan 2 '19 at 2:34
• 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] Jan 2 '19 at 9:34
• 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. Feb 3 '19 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;
fasy[x]
(*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}]

• 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. Jan 2 '19 at 10:15