# Solving ODE numerically in Mathematica - 'ndnum' error?

Tags:
1. Feb 28, 2014

### chipotleaway

I'm trying to solve this ODE $R'(t)=\frac{-a}{R(t)^2}$ numerically in Mathematica (a, b are non-zero constants). Here's what I have:

Code (Text):

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 (Text):

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?

2. Feb 28, 2014

### D H

Staff Emeritus
It means that your a and b aren't numerical. NDSolve wants numerical data.

3. Feb 28, 2014

### chipotleaway

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 $t=1.2*10^{-8}$ whereas the solution I got from solving by hand (which I'm quite certain is correct) is $1.32*10^{-8}$.

Last edited: Feb 28, 2014
4. Mar 3, 2014

### Bill Simpson

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.