# Thread: help with NDSolve in mathematica

1. ## help with NDSolve in mathematica

Hey All,

I am trying to model a system of differential equations. I've formulated an equation, but am having trouble to get mathematica (version7) to provide me a (approximated) solution. Below is the code that I have:

Code:
crossAreaCyl = Pi*(3.075^2);
aholetop = Pi*(.15875^2);
aholebottom = Pi*(.2^2);
g = 980;
h0top = 90.678;
h0bottom = 0.001;

solution = NDSolve[
{
x'[t] == (-aholetop*Sqrt[2*g*(x[t] - y[t])])/crossAreaCyl,

y'[t] == ((aholetop*Sqrt[2*g*(x[t] - y[t])]) - (aholebottom *
Sqrt[2*g*y[t]]))/crossAreaCyl,
x[0] == h0top,
y[0] == h0bottom},
{x, y},
{t, .1, 1}];
When I run this, I get the following error twice:

Code:
NDSolve::mconly: For the method IDA, only machine real code is available. Unable to continue with complex values or beyond floating-point exceptions. >>
The documentation doesn't seem to help me out in this case, unfortunately. Is there any help on how I can get any sort of solution?

Thanks,
Sam

2. I got no error when I cut and pasted your code into ver. 7 and plotted the results with:

Plot[Evaluate[{x[t], y[t]} /. solution], {t, 0.1, 1}]

Often in Mathematica, a past variable assignment will conflict with a current assignment if you're not careful about variable names. A good idea to remember is when you have a problem and nothing looks wrong, cut the code out, stop Mathematica, re-start it, then paste it back in and see if that fixes the problem.