2
$\begingroup$

Hi I am a biologist and I want to model some ecological data that I have. I am new to mathematics and to ODEs. I want to write generic equations for a multi-dimensional system of ODEs. So, I want to look at "i" number of species(S) in "j" number of habitats and to study their population size as a function of time "t".

I have written generic mathematical equation for the system and it is given as: S'(i,j,t)= M(j-1) Ci S(i,j-1,t) - (Mj Ci + Dj) S(i,j,t);

where M - migration and depends on the habitat, C-chance of survival of individual species, D- death of the individual members of the species.

So, I can have i*j number of equations for this system and as an example the eqn for species-9 in the habitat-5 at time-10, would look like this:

S'(9,5,10)= M4 C9 S(9,4,10) - (M5 C9 + D5) S(9,5,10).

I want to write a generic equation in mathematica so that I can solve for very large number of i( say 100) in j=10 habitats, without writing the 1000 equations. Can I do this?

I want to have numerical or symbolic solution for this. But I don't know how to implement this in mathematica.

$\endgroup$
3
  • $\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 Sep 25 '15 at 12:52
  • $\begingroup$ Use DSolve or NDSolve. The examples in the documentation show how to set up systems of equations. $\endgroup$ – Michael E2 Sep 25 '15 at 12:55
  • $\begingroup$ If the answer below answered your question, it is customary to say thank you by upvoting and accepting the answer! $\endgroup$ – march Sep 29 '15 at 17:10
2
$\begingroup$

I don't find the model very appealing, as I believe that migration should be a matrix connecting habitats and differentiated between species and also the death and survival probs should be discriminated.

Anyway, this is a start:

SeedRandom[42];
nSpecies = 3;
nHabitats = 2;
Array[(cSurvival[#] = RandomReal[]) &, nSpecies];
Array[(migration[#] = RandomReal[{-1, 1}]) &, nHabitats + 1, 0];
Array[(death[#] = RandomReal[]) &, nHabitats];

eqs = Table[D[s[i, j, t], t] ==  cSurvival[i] migration[j - 1]  - 
                                (cSurvival[i] migration[j]  + death[j]) s[i, j, t], 
           {i, nSpecies}, {j, nHabitats}];
initCon = Array[(s[##, 0] == #1 + #2) &, {nSpecies, nHabitats}];
vars = Flatten@Array[s[##, t] &, {nSpecies, nHabitats}];

sol = DSolve[{eqs, initCon}, vars, t];

Table[Plot[s[i, j, t] /. sol, {t, 0, 10}, AxesOrigin -> {0, 0}, 
            PlotLabel -> ("species " <> ToString@i <> ", habitat " <> Totring@j)],
     {i, nSpecies}, {j, nHabitats}]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Hi! Thanks for your help. I am onto it... And yes model is not appealing because it is not the complete model here. I made a lot of generalisations for better understanding of my question. My aim was to get an idea about how to write code lines for generic equations. My model is way more twisted and complex and I think I will need help more regularly to be able to get something out of it, through mathematica. It is because of the generous people like you I have at least got started, Thanks again for your help! $\endgroup$ – VitalSigns Sep 27 '15 at 20:05

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.