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

Mathematica NDSolve

  1. Dec 22, 2013 #1
    Hi, I'm having a problem with NDSolve in mathematica where it is interpreting my initial conditions as "True" or "False".

    Here is the code:
    Code (Text):
    soln = NDSolve[{eqn1[[1]], eqn1[[2]], x[0] == y[0] == 0, x'[0] == 1,
        y'[0] == 0}, {x, y}, t];
    where eqn1 is determined by the following code:
    Code (Text):
    Clear[soln, eqn1, xeqn, yeqn, eqn, sink, source, field,  k, m, a,  f, F, U]
    a = 1;
    sink = {0,
        a} - (1/(x^2 + (y - a)^2))*(x^2 + (y - a)^2)^(-1/2)*{x, y - a};
    source = {0, -a} + (1/(x^2 + (y + a)^2))*(x^2 + (y + a)^2)^(-1/2)*{x,
         y + a};
    field = sink + source;
    F = m*k*field;
    U[x_, y_] = Integrate[F[[1]], x] + Integrate[F[[2]], y];
    T = (m/2) (x'[t]^2 + y'[t]^2);
    L = T - U[x[t], y[t]];
    xeqn = D[L, x[t]] == D[D[L, x'[t]], t];
    yeqn = D[L, y[t]] == D[D[L, y'[t]], t];
    eqn = {xeqn, yeqn};
    eqn1 = eqn /. {k -> 1, m -> 1}
    Here is the error:
    Code (Text):
    NDSolve::deqn: Equation or list of equations expected instead of False in the first argument
    {eqn1[[1]], eqn1[[2]], x[0] == y[0] == 0, False, False}
    It looks to me like I must be typing my velocity initial conditions in wrong or something, but every example I can find online does it this same way. I've also tried typing it in other ways like using the D function etc, but I keep having the same issue. :\
  2. jcsd
  3. Dec 22, 2013 #2


    Staff: Mentor

    Interesting. I don't get an error using Mathematica 9.0. Try quitting your kernel and re-running it.
  4. Dec 22, 2013 #3
    Wow, I was almost certain that wasn't going to work. I've been dealing with the problem for a long time now, just never bothered to ask. Turns out, restarting mathematica fixed it though. I just did a restart and copy/pasted what was here.

    Is there anything to take from this? Any ideas why that might have happened? I wonder if saving my work and restarting mathematica would have also worked. Guess I'll have to experiment more later on.
  5. Dec 22, 2013 #4


    Staff: Mentor

    It looks like somehow y'[0] and x'[0] were previously set to some specific value, and it was causing problems.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Mathematica NDSolve
  1. Mathematica NDSolve (Replies: 1)

  2. NDSolve in Mathematica (Replies: 3)

  3. Mathematica NDSolve (Replies: 27)