1
$\begingroup$

Consider the competition model defined by

dx/dt = x (2 − 0.4 x − 0.3 y)
dy/dt = y (1 − 0.1 y − 0.3 x)

Where the population x(t) and y(t) are measured in the thousands and t in years. Use a numerical solver to analyze the populations over a long period of time for

  1. x(0) = 1.5, y(0) = 3.5

I have used the documentation of NDSolve, but I was not able to make it work. Can you supply code for solving the above system with the initial values I give? If I had example code for solving this first initial value problem, I think I could handle the other 14 initial values I have for the same equation. I only need to know how to code the equation system like this:

sol1 = DSolve[{y'[x] == y[x] - Cos[Pi x / 2], y[2] == 2}, y[x], x];

It's my first time using this software.

$\endgroup$

closed as off-topic by bbgodfrey, Henrik Schumacher, eyorble, gpap, Johu Sep 17 '18 at 15:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – bbgodfrey, Henrik Schumacher, eyorble, gpap, Johu
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Possible duplicate of How can I solve a system of differential equation using NDSolve? $\endgroup$ – Artes Sep 13 '18 at 23:29
  • 3
    $\begingroup$ Before you ask other people to do your homework for you, I think you should read this documentation article $\endgroup$ – m_goldberg Sep 14 '18 at 0:04
  • $\begingroup$ Use this syntax. NDSolve[{Eq1,Eq2,ic1,ic2},{depvar1,depvar2},{t,0,10}] $\endgroup$ – zhk Sep 14 '18 at 4:17
  • $\begingroup$ The ODE in the code you show is not at all like system in the problem statement. Therefore, the example code is no help in clarifying your question. Also, the problem statement directs you to use a numerical solver. In Mathematica that would be NDSolve. $\endgroup$ – m_goldberg Sep 15 '18 at 20:36
0
$\begingroup$

One way to attack your problem set is to write a custom numerical solver. For this purpose I suggest using NDSolveValue because it returns the ODE solutions as functions that can be used just as if they were built-in functions.

I will demonstrate the method using a simpler system of ODEs than the one you are studying. You should be able to adapt my code to your problem without much effort.

solver[x0_, y0_, tmax_] :=
  NDSolveValue[
    {x'[t] == y[t] (1.2 - .5 x[t]), y'[t] == x[t] (.8 - .5 y[t]),
     x[0] == x0, y[0] == y0},
    {x, y}, {t, 0, tmax}]

solver[.5, 2, 25]

solns

Now that we have solutions to ODEs in the form of interpolation functions, any of Mathematica's many, many tools can used to perform the requested analysis.

Since you don't give any details about what kind of analysis is expected, I will demonstrate only a very simple tool for analysis, a plotter. The point here being that, again, it is best to attack the problem by writing a custom function.

plotter[x0_, y0_, tmax_] :=
  Module[{xF, yF},
    {xF, yF} = solver[x0, y0, tmax];
    Plot[{xF[t], yF[t]}, {t, 0, tmax}, PlotLabels -> {x[t], y[t]}]]

plotter[.5, 2, 25]

plot

$\endgroup$

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