Sympy Computation with dsolve for Logistic Differential Equation

If you know the initial value, you should let SymPy do the work within dsolve:

using SymPy
@syms K, L, y(), t
∂ = Differential(t)
yt = dsolve(∂(y(t)) ~ K*y(t)*(L - y(t)), ics=Dict(y(0) => 800)) # equation of t; K, L
yt = rhs(yt)    # work with just the expression, not the equation
yt = subs(yt, L=>2000, K => 3//10000)  # leaves as an expression of t alone

The value of yt can be passed on to plot using the recipe, or after calling lambdify can be passed as a function to other actions.

The ics argument allows you to pass a dictionary, as shown.

The earlier answer suggested what to do if you knew the value of C1 (find the variable, the substitute in for the known value). That isn’t suggested unless that is all you have to work with.

1 Like