# Mathematica NDSolve initial condition

• Mathematica
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 == 1, f' == 0,
q == 6.899183459150538*^-13}, {f, p, q}, {t, 0, tf}]
q/.%

After solving the equations, I tried check my solution. I found that q=4.75446*10^-15 rather than the initial value 6.899183459150538*^-13 given in the code.I check q 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!

Related MATLAB, Maple, Mathematica, LaTeX 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.

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, 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!

Dale
Mentor
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!