Help with Mathematica - Solve & Plot Equation

  • Context: Mathematica 
  • Thread starter Thread starter Suin
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around solving and plotting a differential equation using Mathematica. Participants explore issues related to numerical integration, boundary conditions, and the behavior of the solution near singular points.

Discussion Character

  • Technical explanation, Debate/contested, Homework-related

Main Points Raised

  • One participant presents a differential equation and boundary conditions they are trying to solve using Mathematica.
  • Another participant suggests that the error encountered is due to the singularity at x=0, specifically the term involving 2/x, and proposes starting the numerical integration at a small positive value instead.
  • A different participant attempts to adjust the initial conditions and integration interval but still encounters difficulties, indicating uncertainty about the adjustments made.
  • One participant confirms that a modified code works without errors when starting from a small positive value, but questions how to relate the resulting plot back to the original problem.
  • Another participant acknowledges the challenge of rigorously addressing the relationship between the modified plot and the original problem and suggests seeking further clarification in a dedicated forum.

Areas of Agreement / Disagreement

Participants generally agree that the singularity at x=0 complicates the numerical solution, but there is no consensus on how to rigorously connect the modified solution to the original problem.

Contextual Notes

Participants express limitations in their understanding of the implications of modifying initial conditions and the integration interval, particularly regarding the behavior of the solution near singular points.

Who May Find This Useful

Individuals interested in numerical methods for solving differential equations, particularly in the context of Mathematica, may find this discussion relevant.

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 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
8
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K