Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Solving ODE numerically in Mathematica - 'ndnum' error?

Tags:
  1. Feb 28, 2014 #1
    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 (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. jcsd
  3. Feb 28, 2014 #2

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    It means that your a and b aren't numerical. NDSolve wants numerical data.
     
  4. Feb 28, 2014 #3
    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: Feb 28, 2014
  5. Mar 3, 2014 #4
    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Solving ODE numerically in Mathematica - 'ndnum' error?
  1. Mathematica: ODE's (Replies: 2)

Loading...