# How do I solve this ODE numerically in Mathematica?

I want to solve these equations numerically in Mathematica and plot them.

$$u'(t)=1.5\,u(t)\,v(t)-u(t) \space \space \space \text{and} \space \space u(0)=0.001$$ $$v'(t)=-1.5\,u(t)\,v(t) \space \space \space \text{and} \space \space v(0)=0.999$$ $$z'(t)=u(t) \space \space \space \text{and} \space \space z(0)=0$$

I have tried this:

sol = NDSolve[{u'[t] == -u[t] + 1.5 u[t] v[t],
v'[t] == 1.5 u[t] v[t], w'[t] = u[t],
u[0] == v[0] == z[0] = 0},
{u, v, w}, {t, 10}]


But it doesn't seem to work. Thanks in advance.

• Clear all the variables you used, and try again with the change z[0] == 0. Note the difference between equality (==) and assignment (=). – J. M. is in limbo Jun 17 '15 at 13:17
• Still doesn't work. I get this: NDSolve::deqn: "Equation or list of equations expected instead of True in the first argument {\!(True, *SuperscriptBox[\"u\", \"[Prime]\", MultilineFunction->None][t] == (-5)\\\ u[t]\\\ v[t], True, 0.001 == u[0] == 0 == 0)}." – Trix Jun 17 '15 at 13:19
• I said, clear everything. Start in a fresh session if need be. The error you showed tells me you didn't do the first thing I told you to do. – J. M. is in limbo Jun 17 '15 at 13:22
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Jun 17 '15 at 13:46
• You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. – Michael E2 Jun 17 '15 at 13:46

This is mostly because your code is completely unrelated to your equation.

• What is w?
• Why do you use = when you want ==?
• Where does the 5 come from when you want 1.5?
• Why are all of your initial values 0?

Here is something to start with but first go to Evaluation -> Quit Kernel

sol = NDSolveValue[{
u'[t] == 1.5 u[t] v[t] - u[t],
v'[t] == -1.5 u[t] v[t],
z'[t] == u[t],
u[0] == 0.001,
v[0] == 0.999,
z[0] == 0}, {u, v, z}, {t, 10}]

Plot[Through[sol[t]], {t, 0, 10}, PlotRange -> All, Evaluated -> True]
`

• It works now. Thanks! – Trix Jun 17 '15 at 13:25
• @Trix If this answer is the solution, then mark it with the green checkmark that you find below the up- and downvote buttons. – halirutan Jun 17 '15 at 13:26
• @BobHanlon Fixed it. Thanks. – halirutan Jun 17 '15 at 14:53