# Why Can't DSolve Find a Solution for this ODE with y[-x]

I wanted to find a accuracy solution of the following ODE.

$$y'(x)+y(x)=-y(-x).$$

But when I try to use DSolve as follows

DSolve[y'[x] + y[x] == -y[-x], y[x], x]


I get a warning message:

DSolve::litarg: To avoid possible ambiguity, the arguments of the dependent variable in {y[x]+(y^[Prime])[x]==-y[-x]} should literally match the independent variables.

How can I solve this equation with $$y(-x)$$?

• As the warning message says, the argument to the dependent variable must be exactly the same as in the last parameter. This is like as if you wrote DSolve[ y'[x]+1==y[z],y[x],x] . May be if you explain what you want to write y[-x] in there instead of y[x] it will help. – Nasser Oct 15 '18 at 2:23
• Is that equation even an ODE? I don't think $y(-x)$ is an allowed term in an "ordinary" differential equation. – Federico Poloni Oct 15 '18 at 15:26

Put g[x] =f[-x], change the sign x in the equation, then we get a system of two equations that has a solution

 DSolve[{f'[x] + f[x] + g[x] == 0, -g'[x] + g[x] + f[x] ==
0}, {f, g}, x]

Out[]= {{f -> Function[{x}, (1 - x) C[1] - x C[2]],
g -> Function[{x}, x C[1] + (1 + x) C[2]]}}


From the condition g[x] =f[-x]we find C[1] = C[2]

• You could also add f'[0] + 2f[0] == 0 as in @AccidentalFourierTransform's answer. – Carl Woll Oct 15 '18 at 4:33
• Thank you. We can also use the condition g[x]=f[-x] – Alex Trounev Oct 15 '18 at 4:44
• How did you get this: -g'[x] + g[x] + f[x] == 0 ? – user36313 Jul 31 '20 at 7:41
• @user36313 If we change sign x->-x  then y'[x]->-y'[-x]=-g'[x]. – Alex Trounev Jul 31 '20 at 23:12
• Thank you, but I still do not get it. If we change x->-x, then by literal substitution it should be y'[x]->y'[-x]. Why is it not so? – user36313 Aug 2 '20 at 6:01

Take $$y'(x)+y(x)+y(-x)=0$$

Write the same equation, with $$x\to-x$$: $$y'(-x)+y(x)+y(-x)=0$$ and subtract the two equations: $$y'(x)-y'(-x)=0$$

Integrate this equation: $$y(x)+y(-x)=2y(0)$$ and plug this back into the initial equation: $$y'(x)+2y(0)=0$$ with solution $$y(x)=y(0)(1-2x)$$

It is easy to check that this solves the initial equation:

y'[x] + y[x] == -y[-x] /. y -> ((-2 y[0] # + y[0]) &)
(* True *)


I hope I didn't mess up the algebra though, so please double check everything.