Trying to solve a BVP

sols1 = Simplify[ DSolve[{y''[x] - s*y[x] == -F[x], y'[0] == 0, y'[1] == 0},y[x], {x, 0, 1}]]

The solution given $\frac{\left(e^{2 \sqrt{s} x}+e^{2 \sqrt{s}}\right) \int_1^0 -\frac{F(K[1])}{\left(2 \sqrt{s}\right) e^{\sqrt{s} K[1]}} \, dK[1]+\left(e^{2 \sqrt{s}}-1\right) e^{2 \sqrt{s} x} \int_1^x -\frac{F(K[1])}{\left(2 \sqrt{s}\right) e^{\sqrt{s} K[1]}} \, dK[1]-e^{2 \sqrt{s} x} \int_1^0 \frac{F(K[2]) e^{\sqrt{s} K[2]}}{2 \sqrt{s}} \, dK[2]+e^{2 \sqrt{s}} \int_1^x \frac{F(K[2]) e^{\sqrt{s} K[2]}}{2 \sqrt{s}} \, dK[2]-\int_1^x \frac{F(K[2]) e^{\sqrt{s} K[2]}}{2 \sqrt{s}} \, dK[2]-e^{2 \sqrt{s}} \int_1^0 \frac{F(K[2]) e^{\sqrt{s} K[2]}}{2 \sqrt{s}} \, dK[2]}{\left(e^{2 \sqrt{s}}-1\right) e^{\sqrt{s} x}}$

is not matching as I am trying to compute it using green's function

$-\int_x^1 -\frac{F(a) \left(e^{2 a \sqrt{s}}+e^{2 \sqrt{s}}\right) \left(e^{2 \sqrt{s} x}+1\right)}{\left(2 \left(e^{2 \sqrt{s}}-1\right) \sqrt{s}\right) e^{\sqrt{s} (a+x)}} \, da-\int_0^x -\frac{F(a) \left(e^{2 a \sqrt{s}}+1\right) \left(e^{2 \sqrt{s} x}+e^{2 \sqrt{s}}\right)}{\left(2 \left(e^{2 \sqrt{s}}-1\right) \sqrt{s}\right) e^{\sqrt{s} (a+x)}} \, da$

The expression from Mathematica (2nd expression) is not matching with the one I have calculated by hand (3rd expression). The BVP is written as y''-sy=-F(x), y'(0)=0, '(1)=0. I wanted to know if my expression calculated by hand is wrong or if the two expressions are the same, I am somehow missing it. (N.B: I tried to manipulate the expression from Mathematica but I think it is off from my expression). Thanks for the perusal.

  • $\begingroup$ Could you be more specific as to what the problem is though? $\endgroup$
    – MarcoB
    Commented Apr 24, 2018 at 22:58
  • $\begingroup$ I have edited the post. $\endgroup$
    – TMon
    Commented Apr 25, 2018 at 12:21
  • $\begingroup$ A bit of tedious calculation, of splitting the integrals of Mathematica, will show the match. $\endgroup$
    – TMon
    Commented Apr 25, 2018 at 19:37

1 Answer 1


is not matching

Because it does not "look" the same, does not mean it is not equivalent or that it is wrong.

Mathematica solution is correct, it is just written differently. One way to verify, is to simply pluging some values for s and F[x] and see if Mathematica solution matches the Green function solution by hand. So below I solved the problem using Green Function method, and compared the solution for say s=2 and f(x)=x and got the same plot.

Mathematica seems to just expanded the integrals out, that come from the Green function integrals.


Mathematica graphics


Mathematica graphics

Now I found the Green function solution, and plotted it using same force and s and got same exact solution


\begin{align*} y^{\prime\prime}\left( x\right) -sy\left( x\right) & =-f\left( x\right) \\ y^{\prime}\left( 0\right) & =0\\ y^{\prime}\left( 1\right) & =0 \end{align*}

The first step is to determine $y_{1},y_{2}$. These are the two fundamental solutions of $y^{\prime\prime}-sy=0$ . To simplify the derivation, let $y_{1}\left( x\right) $ be the solution that satisfies the boundary conditions at the left end of domain and $y_{2}\left( x\right) $ satisfies the boundary condition on the right end.

The solution to $y^{\prime\prime}\left( x\right) -sy\left( x\right) =0$ is $y_{h}=c_{1}e^{\sqrt{s}x}+c_{2}e^{-\sqrt{s}x}$. Hence $y_{h}^{\prime} =c_{1}\sqrt{s}e^{\sqrt{s}x}-c_{2}\sqrt{s}e^{-\sqrt{s}x}$. Applying BC $y^{\prime}\left( 0\right) =0$ gives

\begin{align*} 0 & =c_{1}\sqrt{s}-c_{2}\sqrt{s}\\ c_{1} & =c_{2} \end{align*}

Therefore \begin{align*} y_{1}\left( x\right) =e^{\sqrt{s}x}+e^{-\sqrt{s}x} \end{align*}

Applying BC $y^{\prime}\left( 1\right) =0$ gives

\begin{align*} 0 & =c_{1}\sqrt{s}e^{\sqrt{s}}-c_{2}\sqrt{s}e^{-\sqrt{s}}\\ c_{2} & =c_{1}\frac{\sqrt{s}e^{\sqrt{s}}}{\sqrt{s}e^{-\sqrt{s}}}\\ & =c_{1}e^{2\sqrt{s}} \end{align*}


\begin{align*} y_{2}\left( x\right) =e^{\sqrt{s}x}+e^{2\sqrt{s}}e^{-\sqrt{s}x} \end{align*}

The Wronskian is \begin{align*} W & = \begin{vmatrix} y_{1} & y_{2}\\ y_{1}^{\prime} & y_{2}^{\prime} \end{vmatrix} = \begin{vmatrix} e^{\sqrt{s}x}+e^{-\sqrt{s}x} & e^{\sqrt{s}x}+e^{2\sqrt{s}}e^{-\sqrt{s}x}\\ \sqrt{s}e^{\sqrt{s}x}-\sqrt{s}e^{-\sqrt{s}x} & \sqrt{s}e^{\sqrt{s}x} -e^{2\sqrt{s}}\sqrt{s}e^{-\sqrt{s}x} \end{vmatrix} \\ & =\left( e^{\sqrt{s}x}+e^{-\sqrt{s}x}\right) \left( \sqrt{s}e^{\sqrt{s} x}-e^{2\sqrt{s}}\sqrt{s}e^{-\sqrt{s}x}\right) -\left( e^{\sqrt{s} x}+e^{2\sqrt{s}}e^{-\sqrt{s}x}\right) \left( \sqrt{s}e^{\sqrt{s}x}-\sqrt {s}e^{-\sqrt{s}x}\right) \\ & =2\sqrt{s}\left( 1-e^{2\sqrt{s}}\right) \end{align*}

For $s\neq0$ the above is non-zero. The Green function is

\begin{align*} G\left( x,a\right) & =\frac{-1}{W}\left\{ \begin{array} [c]{ccc} y_{1}\left( a\right) y_{2}\left( x\right) & & 0\leq a\leq x\\ y_{1}\left( x\right) y_{2}\left( a\right) & & x\leq a\leq1 \end{array} \right. \\ & =\frac{1}{2\sqrt{s}\left( e^{2\sqrt{s}}-1\right) }\left\{ \begin{array} [c]{ccc} \left( e^{\sqrt{s}a}+e^{-\sqrt{s}a}\right) \left( e^{\sqrt{s}x} +e^{2\sqrt{s}}e^{-\sqrt{s}x}\right) & & 0\leq a\leq x\\ \left( e^{\sqrt{s}x}+e^{-\sqrt{s}x}\right) \left( e^{\sqrt{s}a} +e^{2\sqrt{s}}e^{-\sqrt{s}a}\right) & & x\leq a\leq1 \end{array} \right. \end{align*}

Hence the solution is \begin{align*} y\left( x\right) =\int_{0}^{x}G\left( x,a\right) F\left( a\right) da+\int_{x}^{1}G\left( x,a\right) F\left( a\right) da \end{align*}


\begin{align*} y\left( x\right) & =\frac{1}{2\sqrt{s}\left( e^{2\sqrt{s}}-1\right) }\int_{0}^{x}\left( e^{\sqrt{s}a}+e^{-\sqrt{s}a}\right) \left( e^{\sqrt {s}x}+e^{2\sqrt{s}}e^{-\sqrt{s}x}\right) F\left( a\right) da\\ & +\frac{1}{2\sqrt{s}\left( e^{2\sqrt{s}}-1\right) }\int_{x}^{1}\left( e^{\sqrt{s}x}+e^{-\sqrt{s}x}\right) \left( e^{\sqrt{s}a}+e^{2\sqrt{s} }e^{-\sqrt{s}a}\right) F\left( a\right) da \end{align*}

Mathematica result is an expansion of the above integral. Mathematica also using d[K1] and d[K2] for the integrals, while in the hand solution da is used for both. But it is the same.

Plotting the above

y1[arg_]:=Exp[Sqrt[s] arg]+Exp[-Sqrt[s] arg];
y2[arg_]:=Exp[Sqrt[s]arg]+Exp[2 Sqrt[s]] Exp[-Sqrt[s] arg];

Mathematica graphics

mySol=-1/wronskian Integrate[y1[a] y2[x] f[a],{a,0,x}]
      -1/wronskian Integrate[y1[x] y2[a] f[a],{a,x,1}]

Mathematica graphics


Mathematica graphics

You can try different s values and different f. You'll get same result as Mathematica's. Sometimes it is hard for CAS to give same looking result as hand solution.

  • $\begingroup$ Hello @Nasser, Thanks for your reply. I understand that it is hard to get the same looking answer from CAS. But I tried to break the expression from Mathematica and compare terms, but it seems like they do not match. Do you observe the same thing? Am I missing something here? And thanks again for your help. $\endgroup$
    – TMon
    Commented Apr 25, 2018 at 12:31
  • $\begingroup$ @TMon but it seems like they do not match but if the Mathematica output give the same result as hand solution for same input, then it must be correct. It is hard to make it match visually since it is complicated. But why is that important? The important thing, is that it gives same output for same input as the hand solution, right? Mathematica just wrote the final integrals in strange way. This happens in many other places as well. To verify the result. I always plot result for random input and compare with hand solution. This is the easiest way to check. $\endgroup$
    – Nasser
    Commented Apr 25, 2018 at 17:32
  • $\begingroup$ Thanks Naseer. I have successfully matched the terms by hand too. Well, it was bugging me until I saw the terms were really matching. Validating my hand solution with yours was a relief. The rest was a bit of tedious calculations. $\endgroup$
    – TMon
    Commented Apr 25, 2018 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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