Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to learn to solve system of differential equation in MathCad like this one:

dI(t)/dt = coeff * I(t) * S(t)

dS(t)/dt = -coeff * I(t) * S(t)

N = S(t) + I(t)

where 'N' and 'coeff' are user specified coefficients

In MathCad I did:

            ( coeff * y0 * y1   )
D(t, y) :=  (                   )
            ( -coeff * y0 * y1  )

      ( 1 )
ic := (   )
      ( 9 )

But :

S := rkfixed (ic, 0, 10, 100, D)

returns: D - this function can't be used here.

And I don't know how and where insert N=S(t) + I(t) equation :(

share|cite|improve this question
Looks like Lotka–Volterra equation, and for the constraint, with $S(t) = N- I(t)$ plugged in the second equation you get $dI/dt = cNI(t) - cI^2$, try solving this using a stable marching scheme. – Shuhao Cao Apr 27 '12 at 22:59
As an example I used quite easy system with two variables ... but what should I do when I'll have 4-6 variables with no way to make such substitution? – davs Apr 27 '12 at 23:04
Then this works like a constraint minimization problem numerically rather than a simple "marching in time" problem, does $N$ change with time too? I am not familiar with MathCad, but using rkfixed this kind of Runge Kutta with fixed marching step doesn't seem right. – Shuhao Cao Apr 27 '12 at 23:14
N is constant. variable coeff also sets ones. Following info contains what I'm working with: I - number of infected items and S is number of suspected items. Mentioned above system of DiffEquation is S-I model of virus spreading. N - number of all items (S+I), coeff - rate of infection between items – davs Apr 27 '12 at 23:30
Stackoverflow might be a better place to discuss the problem on such softwares. Best wishes. – Frank Science May 5 '12 at 8:34
up vote 0 down vote accepted

I can give you an answer for the above system (2 ODEs). For your system equation 3 can be derived from equations 1,2 since:$$\frac{dI(t)}{dt}=coeff\cdot S(t)\cdot I(t) \hspace{0.5cm} (1)$$ $$\frac{dS(t)}{dt}=-coeff\cdot S(t)\cdot I(t) \hspace{0.5cm} (2)$$

Adding $(1)$ and $(2)$, you get:

$$\frac{dI(t)}{dt}+\frac{dS(t)}{dt}=0 \Leftrightarrow I(t)+S(t)=c \ \forall \ t\geq0$$where $c$ is a constant. So, by defining the IC you're defining $N=c=I(0)+S(0)$ too and therefore equation $(3)$ is useless. As far as Mathcad is concerned, since you're trying to march forward in time you correctly chose to use rkfixed. Here is the mathcad code i used for an example problem:

enter image description here

As you can see the sum $S(t)+I(t)$ is constant for every t and equal to 1.1 as defined by the initial condition.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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