Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Well, if you insist on numerical solutions to differential equations, you can always try desolve_rk4 or one of the various solutions documented in the relevant chapter of the documentation. But in this case, it's much easier to solve it first in symbolic terms :

sage: var("a,b,c")
(a, b, c)
sage: y=function("y")
sage: de=diff(y(x),x)==a*y(x)*(b-y(x))
sage: S1=desolve(de,y(x),[0,c], ivar=x, contrib_ode=True);S1
-(log(-b + y(x)) - log(y(x)))/(a*b) == (a*b*x - log(-b + c) + log(c))/(a*b)

This is an implicit solution, that can be easily solved : l''s get rid of constants in the left-hand side, by multimpyong both terms by a*b, then simplify the log terms :

sage: S2=(S1*(a*b)).simplify_log();S2
log(-y(x)/(b - y(x))) == a*b*x + log(-c/(b - c))

Lat's take the exponential of both terms of this equality, then expand logs :

sage: S3=S2.lhs().exp().expand_log()==S2.rhs().exp().expand_log();S3
-y(x)/(b - y(x)) == -c*e^(a*b*x)/(b - c)

It remains a first-degree linear equation, whose (unique) solution is trivial :

sage: S=solve(S3,y(x))[0];S
y(x) == b*c*e^(a*b*x)/(c*e^(a*b*x) + b - c)

This solution can (should)) be checked :

sage: bool(diff(S.rhs(),x)==de.rhs().subs({y(x):S.rhs()}))
True

Substitute your numeric constants :

sage: S.subs([a==0.00054,b==500,c==90])
y(x) == 4500*e^(0.270000000000000*x)/(9*e^(0.270000000000000*x) + 41)

One notes that this solution could be expressed approximately as 500/(e^0.27*x)+5.556) (by dividing both numerator and denominator by 9), not quite the expected result...

How did you come to expect this result ? Wasn't there a copy error ?