# How to solve Two-Point Boundary Value Problem (Bratu-type equation)?

I reviewed Q1 and Q2, but I can not use of they. I wrote the following code:

eq = D[u[x], {x, 2}] - Pi^2*Exp[u[x]] == 0;
init = {u[0] == 0, u[1] == 0};
Eqe = Quiet[NDSolve[Join[eq, init], u[x], {x, 0, 1}]]


I do not know why it does not work. Any suggestions?

• First, it should be Join[{eq}, init]. – corey979 Jan 7 '17 at 19:36

This is one hell of a simple BVP, which Mathematica does not handle with ease.

Here is my experimentation,

eq = u''[x] - Pi^2*Exp[u[x]] == 0;
init = {u[0] == 0, u[1] == 0};


First, I tried without specifying the method like the OP

sol = NDSolve[Join[{eq}, init], u[x], {x, 0, 1}]


NDSolve::ndsz: At x == 0.7071067304302846, step size is effectively zero; singularity or stiff system suspected.

Then, with a method,

sol = NDSolve[Join[{eq}, init], u[x], {x, 0, 1},
Method -> {"ExplicitRungeKutta", "StiffnessTest" -> False}]


NDSolve::ndsz: At x == 0.7071067304302846, step size is effectively zero; singularity or stiff system suspected.

Shooting

After trying different method's, finally I got lucky with shooting

sol = NDSolve[Join[{eq}, init], u[x], {x, 0, 1},
Method -> {"Shooting",
"StartingInitialConditions" -> {u[0.0] == 0, u'[0.0] == 0}}]


NDSolve::ndsz: At x == 0.7071067304302846, step size is effectively zero; singularity or stiff system suspected.

The singularity seems to occur in the vicinity of x=1. So, I tried with different StartingInitialConditions and finally got able to produce an answer without any warning.

sol = NDSolve[Join[{eq}, init], u[x], {x, 0, 1},
Method -> {"Shooting",
"StartingInitialConditions" -> {u[0.5] == 0, u'[0.5] == 0}}]
Plot[u[x] /. sol, {x, 0, 1}]


Note

This BVP can easily be solved with maple numerically,

restart;with(plots):
eq := diff(u(x),x\$2)-Pi^2*exp(u(x));
ibcs:=(u)(0)=0,u(1)=0;
sol:=dsolve({eq,ibcs},numeric);
odeplot(sol,[[x,u(x)]],0..1,color=[red],axes=boxed);


Finally, comparing the solutions from both Mathematica and Maple

• Many many thanks. In this way, output just is plot. Is the function of solution can be found with Plot? – user45459 Jan 8 '17 at 6:29
• @user45459 The output of NDSolve is an interpolating function not just a plot InterpolatingFunction[data][x]. Plot command is only used for plotting nothing else. – zhk Jan 8 '17 at 6:50
• I am confused. Because I do not have any output. I want to have a function u[x] on [0,1], but I gain Plot on [0,1]. Is there any way which I gain a function u[x] or a polynomial for interpolation function? – user45459 Jan 8 '17 at 7:22
• @user45459 Well, NDSolve produces numerical solution in terms of interpolation function. If you are looking for analytical solution then you should use DSolve? DSolve[eq, u, x]` – zhk Jan 8 '17 at 8:07