Mathematica Help with Mathematica - Solve & Plot Equation

  • Thread starter Thread starter Suin
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion centers on solving a differential equation using Mathematica, specifically the equation d/dx (x^2 dy/dx) = x^2 e^(-y) with boundary conditions y(0)=0 and y'(0)=0. The initial attempt to solve this using NDSolve results in an error due to the singularity at x=0, caused by the term 2/x in the reformulated equation. A workaround is suggested by starting the numerical integration at a small positive value (0.00001) instead of zero, which successfully avoids the error. The user then questions the validity of the resulting plot, wondering if it accurately reflects the original problem. While the plot remains consistent with varying the starting point, the discussion suggests seeking further confirmation in a dedicated differential equations forum for a rigorous approach.
Suin
Messages
3
Reaction score
0
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
 
Physics news on Phys.org
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.
 
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?
 
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
 
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.
 

Similar threads

Replies
1
Views
2K
Replies
1
Views
2K
Replies
4
Views
2K
Replies
1
Views
2K
Replies
5
Views
2K
Replies
1
Views
2K
Back
Top