# 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. Oct 15, 2018 at 2:23
• Is that equation even an ODE? I don't think $y(-x)$ is an allowed term in an "ordinary" differential equation. Oct 15, 2018 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 - x C],
g -> Function[{x}, x C + (1 + x) C]}}


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

• You could also add f' + 2f == 0 as in @AccidentalFourierTransform's answer. Oct 15, 2018 at 4:33
• Thank you. We can also use the condition g[x]=f[-x] Oct 15, 2018 at 4:44
• How did you get this: -g'[x] + g[x] + f[x] == 0 ? Jul 31, 2020 at 7:41
• @user36313 If we change sign x->-x  then y'[x]->-y'[-x]=-g'[x]. Jul 31, 2020 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? Aug 2, 2020 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 # + y) &)
(* True *)


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