Help with mathematica

  • Mathematica
  • Thread starter Suin
  • Start date
  • #1
3
0
Hi all,

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

[itex] \frac{d}{dx} (x^2 \frac{d y}{dx})=x^2 e^{-y}[/itex]

with boundary conditions

[itex] y(0)=0, y'(0)=0 [/itex]

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
 

Answers and Replies

  • #2
1,796
53
I think that's because Mathematica is trying to solve numerically, the equation

[tex]y''+2/x y'=e^{-y}[/tex]

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
3
0
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 [itex] \frac{2}{x} [/itex] but I can't manage to fix it adjusting the interval of integration and the initial conditions. Where did I make a mistake?
 
  • #4
3
0
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):

[itex] 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][/itex]

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
1,796
53
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.
 

Related Threads on Help with mathematica

  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
1
Views
2K
Replies
2
Views
2K
  • Last Post
Replies
8
Views
11K
  • Last Post
Replies
1
Views
1K
Replies
1
Views
2K
Replies
8
Views
4K
Replies
1
Views
1K
Replies
10
Views
2K
Top