0
$\begingroup$

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 :(

  • 0
    Stackoverflow might be a better place to discuss the problem on such softwares. Best wishes.2012-05-05

1 Answers 1

0

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.