1
$\begingroup$

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

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

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.

$\endgroup$
  • $\begingroup$ Clear all the variables you used, and try again with the change z[0] == 0. Note the difference between equality (==) and assignment (=). $\endgroup$ – J. M. is in limbo Jun 17 '15 at 13:17
  • $\begingroup$ 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)}." $\endgroup$ – Trix Jun 17 '15 at 13:19
  • 1
    $\begingroup$ 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. $\endgroup$ – J. M. is in limbo Jun 17 '15 at 13:22
  • $\begingroup$ 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! $\endgroup$ – Michael E2 Jun 17 '15 at 13:46
  • $\begingroup$ 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. $\endgroup$ – Michael E2 Jun 17 '15 at 13:46
3
$\begingroup$

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]

Mathematica graphics

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.