Mathematica NDSolve conditions help

In summary: When you tried to use the Integrate function, it tried to interpret those values as true or false, which wasn't what you intended.
  • #1
Hertz
180
8
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:
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:
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:
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. :\
 
Physics news on Phys.org
  • #2
Interesting. I don't get an error using Mathematica 9.0. Try quitting your kernel and re-running it.
 
  • #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.
 
  • #4
It looks like somehow y'[0] and x'[0] were previously set to some specific value, and it was causing problems.
 
  • #5



Hi there,

It seems like the issue might be with your initial conditions. The error message is indicating that the initial conditions for x'[0] and y'[0] are being interpreted as False, which is not a valid input for NDSolve.

I would recommend checking your initial conditions and making sure they are formatted correctly. It's possible that there is a typo or some other mistake that is causing NDSolve to interpret them as False. Also, double check that your equations are correct and that you are passing the correct variables to NDSolve.

If you continue to have trouble, you may want to try reaching out to the Mathematica community for further assistance. They may be able to provide more specific guidance on how to resolve this issue. Good luck!
 

FAQ: Mathematica NDSolve conditions help

1. What is NDSolve in Mathematica?

NDSolve is a function in Mathematica that is used to numerically solve differential equations.

2. How do I specify initial conditions in NDSolve?

To specify initial conditions, you can use the "InitialConditions" option in the NDSolve function and provide a list of equations that define the initial state of the system.

3. What is the difference between "Boundary Conditions" and "Initial Conditions" in NDSolve?

Boundary conditions are conditions that are specified at the boundaries of the domain, while initial conditions are specified at a specific starting point within the domain.

4. Can I use NDSolve for systems of partial differential equations?

Yes, NDSolve can be used to solve systems of partial differential equations, but you will need to specify the boundary and initial conditions for each equation in the system.

5. How do I handle singularities or discontinuities in my differential equations when using NDSolve?

You can use the "Method" option in NDSolve to choose a method that can handle singularities, or you can manually remove the singularities from your equations before using NDSolve.

Similar threads

Replies
1
Views
881
Replies
1
Views
690
Replies
4
Views
2K
Replies
1
Views
1K
Replies
1
Views
889
Replies
1
Views
764
Replies
8
Views
802
Back
Top