Solving ODE numerically in Mathematica - 'ndnum' error?

  • Context: Mathematica 
  • Thread starter Thread starter chipotleaway
  • Start date Start date
  • Tags Tags
    Error Mathematica Ode
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 8K views
chipotleaway
Messages
174
Reaction score
0
I'm trying to solve this ODE [itex]R'(t)=\frac{-a}{R(t)^2}[/itex] numerically in Mathematica (a, b are non-zero constants). Here's what I have:

Code:
NDSolve[{R'[t]==-a/R[t]^2, R[0]==b,
WhenEvent[R[t]==0, end=t; "StopIntegration"]}, R, {t,0,1}]

It's returning with

Code:
NDSolve:::ndnum : Encountered non-numerical value for a derivative at t==0.'

What does it mean there's a non-numerical value for a derivative at t=0 and how do I fix it?
 
on Phys.org
Thanks D H, I didn't notice I hadn't defined all my other constants to be a and b yet.

If it isn't too off-topic, how accurate is this method? I'm getting an answer of [itex]t=1.2*10^{-8}[/itex] whereas the solution I got from solving by hand (which I'm quite certain is correct) is [itex]1.32*10^{-8}[/itex].
 
Last edited:
Usually Mathematica calculates the accuracy and precision as it works through a problem.

Try giving your coefficients more than the default machine that is implied by a simple decimal point and see what you get. You can also click on Details & Options on the help page and look at options to have it work with greater precision in NDSolve.