# Help with mathematica

1. Dec 20, 2011

### Suin

Hi all,

I'm just a beginner with mathematica, and I tried to plot the solution of the following equation

$\frac{d}{dx} (x^2 \frac{d y}{dx})=x^2 e^{-y}$

with boundary conditions

$y(0)=0, y'(0)=0$

Using the following mathematica code:

NDSolve[{D[x^2 y'[x], x] == x^2 Exp[-y[x]], y[0] == 0, y'[0] == 0}, y, {x, 0, 30}]

But I got "Power::infy: "Infinite expression 1/0. encountered, ecc" and I don't know why and I don't know hot to solve and plot that equation in mathematica.

Can anyone help me?

Thank you

Mattia

2. Dec 20, 2011

### jackmell

I think that's because Mathematica is trying to solve numerically, the equation

$$y''+2/x y'=e^{-y}$$

and when you start the numerical integration at x=0, it can't because of the 2/x term. That doesn't necessarilly mean there isn't a solution at zero but rather, the particular method Mathematica is using, cannot start at 0. For example, if you adjusted the code to start at say 0.001, it would work fine.

3. Dec 21, 2011

### Suin

Thank you for your reply; in fact I thought something similar so I tried

NDSolve[{D[x^2 y'[x], x] == x^2 Exp[-y[x]], y[0] == 1, y'[0] == 1}, y, {x, 1, 30}]

just to see if it worked but it didn't. I think the problem is related to the $\frac{2}{x}$ but I can't manage to fix it adjusting the interval of integration and the initial conditions. Where did I make a mistake?

4. Dec 21, 2011

### Suin

No you were right, I was wrong.

The following code works, in the sense that it did not get any error (it is the same as before with al the zero repalced by 0.00001):

$s =\text{NDSolve}\left[\left\{2 x y'[x]+x^2 y''[x]==e^{-y[x]} x^2,y[0.00001]==0.00001,y'[0.00001]==0.00001\right\},y,\{x,0.00001,30\}\right]$

Plot[Evaluate[y[x] /. s], {x, 0.00001, 30}, PlotRange -> All]

Now I have another question: how can I know if the plot of this code has anything to do with my original problem? I tried putting more "zeros" in the 0.00001 and see that the graph remains almost the same, so I think it's okay, but can you give me other arguments?

Thank you

5. Dec 21, 2011

### jackmell

Ok, very good. I see what you mean. I don't know how to approach that rigorously though. How about asking that in the DE forum above if you want.