6
$\begingroup$

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)$?

$\endgroup$
2
  • 2
    $\begingroup$ 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. $\endgroup$
    – Nasser
    Oct 15, 2018 at 2:23
  • $\begingroup$ Is that equation even an ODE? I don't think $y(-x)$ is an allowed term in an "ordinary" differential equation. $\endgroup$ Oct 15, 2018 at 15:26

2 Answers 2

7
$\begingroup$

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]

$\endgroup$
6
  • 1
    $\begingroup$ You could also add f'[0] + 2f[0] == 0 as in @AccidentalFourierTransform's answer. $\endgroup$
    – Carl Woll
    Oct 15, 2018 at 4:33
  • $\begingroup$ Thank you. We can also use the condition g[x]=f[-x] $\endgroup$ Oct 15, 2018 at 4:44
  • $\begingroup$ How did you get this: -g'[x] + g[x] + f[x] == 0 ? $\endgroup$
    – user36313
    Jul 31, 2020 at 7:41
  • $\begingroup$ @user36313 If we change sign x->-x then y'[x]->-y'[-x]=-g'[x]. $\endgroup$ Jul 31, 2020 at 23:12
  • $\begingroup$ 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? $\endgroup$
    – user36313
    Aug 2, 2020 at 6:01
10
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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