Mathematica: Infinite expression error when using NDSolve

In summary, the conversation discusses a problem with using NDSolve in Mathematica to solve a nonlinear ODE. The problem is related to an infinite expression encountered in the solution. The conversation ends with a suggestion to contact WRI tech support for help with finding a solution.
  • #1
stephanie22
2
0
Dear all,

If someone could help me solve this mathematica NDSolve problem, that would be really nice. Here is a related, simpler problem to the one I am having. Suppose I want to solve the nonlinear ODE
[tex]
\left(2 r + f(r) f'(r) \right) (1 + f'(r)^2) + r f(r) f''(r) = 0
[/tex]
subject to the initial conditions
[tex]
f(R) = f(-R) = 0 \,.
[/tex]
This problem is simpler than the one I actually want to solve, because in this case I know that the solution is
[tex]
f(r) = (R^2 - r^2)^{1/2} \,.
[/tex]

I would like to try and recreate the above solution by using NDSolve in mathematica. I try using the code
Code:
NDSolve[{(2 r + f[r] f'[r]) (1 + f'[r]^2) + r f[r] f''[r] == 0, 
  f[1] == 0, f[-1] == 0}, f, {r, -1, 1}]
but I receive the error message "Power::infy: Infinite expression 1/0. encountered." I would like to recreate the solution f(r) = \sqrt{1 - r^2}.

Thanks in advance for any help!

Steph
 
Last edited:
Physics news on Phys.org
  • #2
An interesting question (and well asked). Unfortunately, I don't have a good answer for you.

If you use Trace[ NDSolve[...], TraceInternals->True], then you can see that NDSolve is trying the shooting method when it all goes wrong. However, I'm not sure what exactly is going wrong nor how to fix it.

I suggest you contact WRI tech support (http://www.wolfram.com/support/contact/) and see if they can sort it out.
If they do have a good answer, it would be great if you could post it here.
 

Related to Mathematica: Infinite expression error when using NDSolve

1. What does the "Infinite expression error" mean in Mathematica?

The "Infinite expression error" in Mathematica occurs when a mathematical expression evaluates to a number that is too large or too small to be represented by the computer's memory. This can happen when using functions like NDSolve, which involves numerical calculations.

2. How can I fix the "Infinite expression error" in Mathematica?

There are a few ways to fix the "Infinite expression error" in Mathematica. One option is to increase the precision of your calculations by using the PrecisionGoal and AccuracyGoal options in NDSolve. Another option is to use the WorkingPrecision option to specify a higher precision for your calculations. You can also try simplifying your equations or using alternative methods for solving them.

3. Why does the "Infinite expression error" only occur with NDSolve?

The "Infinite expression error" can occur with any function that involves numerical calculations, but it is more common with NDSolve because it involves solving differential equations, which can lead to rapidly growing or decaying solutions. This can result in numbers that are too large or too small to be represented by the computer's memory, causing the error.

4. Can the "Infinite expression error" be avoided altogether in Mathematica?

No, the "Infinite expression error" cannot always be avoided in Mathematica as it is a limitation of the computer's memory and numerical calculations. However, as mentioned before, there are ways to minimize the chance of encountering this error by increasing precision, simplifying equations, or using alternative methods for solving problems.

5. Is there a way to check for potential "Infinite expression errors" in my Mathematica code?

Yes, you can use the Check function in Mathematica to catch potential "Infinite expression errors" and handle them in a specific way. This allows you to detect and handle the error without interrupting the execution of your code. You can also use the Message function to display a warning message when the error occurs.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
292
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
246
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
170
  • MATLAB, Maple, Mathematica, LaTeX
Replies
19
Views
145
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
442
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top