Mathematica NDSolve initial condition

Click For Summary

Discussion Overview

The discussion revolves around the use of NDSolve in Mathematica for solving a set of differential-algebraic equations. Participants explore issues related to initial conditions, numerical stability, and the handling of coefficients with large disparities in magnitude.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant reports a discrepancy in the value of q[0] after solving the equations, noting that it differs from the initial condition specified in the code.
  • Another participant questions the validity of dropping terms with coefficients of ##10^{-35}## and ##10^{-36}##, suggesting that doing so yields expected results.
  • A participant mentions that the large coefficients in the equations were initially derived from physical constants, and they replaced them to troubleshoot the issue without believing it affected the outcome.
  • Concerns are raised about numerical stability when solving equations with coefficients that vary significantly in scale, prompting a discussion on which terms may be neglected.
  • One participant suggests redefining functions to ensure that coefficients are of similar scale to improve numerical stability.
  • Another participant recommends using higher precision or exact numbers for coefficients in Mathematica, while cautioning against treating measured coefficients as exact due to potential issues in methods.
  • A participant describes solving one of the equations for p(t) in terms of the other functions and notes that while the initial conditions seem fine, they encounter stiffness problems likely due to rapid oscillations in f(t).

Areas of Agreement / Disagreement

Participants express differing views on the treatment of small coefficients and the implications for numerical stability. There is no consensus on the best approach to address the stiffness problem encountered in the equations.

Contextual Notes

Participants highlight limitations related to the numerical stability of solutions when coefficients differ greatly in magnitude and the potential impact of treating coefficients as exact numbers.

karlzr
Messages
129
Reaction score
2
Hi, I am trying to use NDSolve in Mathematica to solve a set of differential-algebraic equations:
NDSolve[{-6250 f[t] + 0.025 p[t]^2 f[t] + 0.1 f[t]^3 + 3 q[t] f'[t] +
f''[t] == 0,
1.5230870989335428*^-35 p[t]^4 + q'[t] ==
0, -4.32*^36 q[t]^2 + 10/3 \[Pi]^2 p[t]^4 + 0.0125 p[t]^2 f[t]^2 +
0.025 (-62500 + f[t]^2)^2 == 0, f[0] == 1, f'[0] == 0,
q[0] == 6.899183459150538*^-13}, {f, p, q}, {t, 0, tf}]
q[0]/.%

After solving the equations, I tried check my solution. I found that q[0]=4.75446*10^-15 rather than the initial value 6.899183459150538*^-13 given in the code.I check q[0] because when I plot my solutions, q[t] is somehow constant at 4.75446*10^-15. So could anyone tell me what is going wrong in my code?
Thank you so much!
 
Physics news on Phys.org
Why can't you drop the terms multiplied by ##10^{-35}## and ##10^{-36}##? I tried doing it, and it works.
 
matteo137 said:
Why can't you drop the terms multiplied by ##10^{-35}## and ##10^{-36}##? I tried doing it, and it works.

Do you mean when you evaluate q[0], it gives you the expected value, the number in the code?
As to those ugly coefficients in the equations: at first they don't appear in my equations. I mean those coefficients are given in terms of physical constants. In order to find the problem, I replaced those equations with the ones you see. I don't think it matters, since both of them gave me the same result.
 
Often it is not numerically stable to blindly solve equations with coefficients in such a large range. What you have to do first, is to understand which terms you can drop/neglect, for example because they are many orders of magnitude smaller than the others.
 
The coefficients vary by so large scale, but each term in the equations should be of similar scale. I guess I can first try redefining my functions so that the coefficients don't differ so much. Thanks!
 
The other thing that you can do in Mathematica is to use higher precision numbers for your coefficients or even exact numbers (rationals). However, if those are measured coefficients rather than exact numbers, then treating them as exact numbers is likely to hide problems in your methods.
 
I solved the third equation, the algebraic one, for ##p(t)## in terms of the other two functions and substituted this expression into the first two equations. So I have only two equations left for ##f(t)## and ##q(t)##. The initial conditions seem to be fine. But there is some stiffness problem. I guess it is because ##f(t)## is oscillating too rapidly as expected. So does anyone know how to deal with this kind of stiffness problem?
Thanks so much!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
Replies
8
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K