# DSolve - 2nd order Differential Equation

I'm trying to solve the DE: $$\partial^2 \phi(x)=\frac{\rho(x)}{\epsilon}$$ with $$\rho\left(x\right)=0$$ for $$x<-L$$; $$\rho\left(x\right)=\rho_a$$ for $$-L; $$\rho\left(x\right)=\rho_b$$ for $$0 and $$\rho\left(x\right)=0$$ for $$x>L$$

and Neumann boundary condition $$\partial_x\phi(\pm\infty)=0$$. I'm trying to use the following command, but I got no response from Mathematica

 DSolve[{\[Phi]''[x] == 1/\[Epsilon]d \[Rho][x] + NeumannValue[0, x < -1000000] + NeumannValue[0, x > 1000000]},\[Phi][x],x]


Thank you very much for the help. Best,

• Is this what you want?: DSolve[{\[Phi]''[x] == 1/\[Epsilon]d Piecewise[{{\[Rho]a, -L < x <= 0}, {\[Rho]b, 0 < x < L}}]}, \[Phi], x, Assumptions -> L > 0 && {\[Rho]a, \[Rho]b} \[Element] Reals] -- You can get the derivative to vanish at one infinity but not the other. – Michael E2 Feb 3 at 21:59
• Yes, it is precisely that. I have already defined $\rho(x)$ as Piecewise function.. So my problem concerns how to implement the Neumann condition within the DSolve command.. For instance, I'd like to use $\partial_x \phi(\pm \infty)=0$ – denis Feb 3 at 22:03
• Isn't the solution found by integrating $\frac{\rho(x)}{\epsilon}$ twice? So the general solution is the (double) antiderivative plus $c_1x+c_2$. I don't see how to get $\phi_x$ to vanish at both $\pm\infty$ with only one free parameter $c_1$ (except by accident, say depending on $\rho_a$, $\rho_b$). – Michael E2 Feb 3 at 22:08
• You are correct.. For $x \rightarrow \pm \infty$ the solution is given by $c_1 x + c_2$.. Then, by imposing $\partial_x \phi (\pm \infty) = 0$ we obtain $c_1=0$, so that the DE is undetermined by the constant $c_2$.. How can be possible to give two Neumann boundary condition and just get one constant? I'm puzzling with this.. Thanks. – denis Feb 3 at 22:22
• If $\rho_a = -\rho_b$ and you set C[2] -> -((L (\[Rho]a + \[Rho]b))/\[Epsilon]d) in my DSolve code, then the solution vanishes at both $\pm\infty$. I don't think it can be done for arbitrary values of the parameters. But maybe I'm overlooking something. – Michael E2 Feb 3 at 22:28