# Solve the following differential equation?

Posted 5 months ago
601 Views
|
3 Replies
|
2 Total Likes
|
 I am trying to solve this differential equationr'[t]=k(1-r[t]/25] . r[0]=20 Where t is time in months from 0 to 12.the problem is that the coefficient k is also time-dependent. It has values k (Jan, Feb, Mar) = 0.1 k (Apr, May, Jun) = 0.3 k (Jul, Aug, Sep) = 0.5 k (Oct, Nov, Dec) = 0.2Many thanks in advance!
3 Replies
Sort By:
Posted 5 months ago
 k[t_] := Piecewise[{{.1, 0 < t < 3}, {.3, 3 < t < 6}, {0.5, 6 < t < 9}}, 0.2] sol = NDSolve[{r'[t] == k[t]*(1 - r[t]/25), r[0] == 20}, r, {t, 0, 12}] Plot[Evaluate[r[t] /. sol], {t, 0, 12}] 
 It can also be solved symbolically just by replacing NDSolve with DSolve (at least in V10+): DSolve[{r'[t] == k[t]*(1 - r[t]/25), r[0] == 20}, r, {t, 0, 12}] 
 Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1STThe rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your posts and make sure code blocks start on a new paragraph and look framed and colored like this. int = Integrate[1/(x^3 - 1), x]; Map[Framed, int, Infinity]