0xbadc0de
0xbadc0de

Reputation: 3925

Solve the ODE with NDSolve and dependet variables

I have intialconditions:

sf = 200; 
sm = 100; 
p = 40; 
betaf = 0.15; 
betam = 0.15; 
mums = 0.02; 
mufs = 0.02; 
sigma = 0.20; 
mum = 0.02; 
muf = 0.02; 

and the ODE:

sf' := -muf*sf + (betaf + mums + sigma)*p - HarmonicMean[sf, sm]; 
sm' := -mum*sm + (betam + mufs + sigma)*p - HarmonicMean[sf, sm}]; 
p' := p - (mufs + mums + sigma)*p + HarmonicMean[{sf, sm}];

That i want is an abstract solution (sf(t),sm(t),p(t)) with NDSolve to plot it later. My problem is that all variables are dependet in all 3 equations, so i don't know how to write the NDSolve call.

Upvotes: 1

Views: 405

Answers (1)

István Zachar
István Zachar

Reputation: 1344

I could not manage to get an analytic solution, but the numerical one goes like this. Note that not all symbols you listed are variables of the system: those not being dependent of the independent variable t are parameters. (Also note that there are some typos in the OP's code).

variables = {sf[t], sm[t], p[t]};
parameters = {betaf -> 0.15, betam -> 0.15, mums -> 0.02, 
   mufs -> 0.02, sigma -> 0.20, mum -> 0.02, muf -> 0.02};

equations = {
   sf'[t] == -muf*sf[t] + (betaf + mums + sigma)*p[t] - 
     HarmonicMean[{sf[t], sm[t]}],
   sm'[t] == -mum*sm[t] + (betam + mufs + sigma)*p[t] - 
     HarmonicMean[{sf[t], sm[t]}],
   p'[t] == 
    p[t] - (mufs + mums + sigma)*p[t] + HarmonicMean[{sf[t], sm[t]}],
   sf[0] == 200,
   sm[0] == 100,
   p[0] == 40
   };

sol = NDSolve[equations /. parameters, variables, {t, 0, 100}];

Plot[Evaluate[variables /. sol], {t, 0, 100}]

Mathematica graphics

Upvotes: 2

Related Questions