Message Boards Message Boards

Solve the following differential equation?

GROUPS:

I am trying to solve this differential equation

r'[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.2

Many thanks in advance!

POSTED BY: Paradox Paradox
Answer
2 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}]

fig1

POSTED BY: Alexander Trounev
Answer
2 months ago

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}]
POSTED BY: Michael Rogers
Answer
2 months ago

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The 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]

enter image description here

POSTED BY: Moderation Team
Answer
2 months ago

Group Abstract Group Abstract