Question: How to use piecewise with dsolve,numeric

Hi group,

I am stumped and would appreciate some advice.  I'm trying to use the piecewise function in the context of dsolve,numeric.  As a simple example:

piwz := piecewise(S(t) < 40000, 0, S(t) >= 40000, 1);

eq1 := diff(S(t), t) = k1*S(t)-k2*S(t)*piwz

In this example, I want the value of piwz in eq1 to be a function of S(t).  However, when I use dsolve, numeric to solve this, and to plot using odeplot in the usual manner, the result doesn't make sense- it seems to ignore the piwz term, or I get an error when S(t) = 40,000.  

I suspect that the problem is related to a circular argument, in which the value of S(t) that is needed to determine piwz is also dependent upon the value of piwz.  Is there a way around this general problem, so that I can use piecewise with dsolve, numeric for this purpose?

Thanks in advance.

Steve

Please Wait...