Ask Your Question

Revision history [back]

The following works for now, but the substitution used below is deprecated, so it might not work in a future version of Sage. Maybe someone can give a more future-proof solution.

sage: y = function('y', x)
sage: de = diff(y, x) == y*(100 - y)
sage: sol = desolve(de, y)
sage: z = SR.var('z')
sage: solz = sol.substitute({y(x):z})
sage: solz.solve(z, to_poly_solve=True)
[z == 100*e^(100*_C + 100*x)/(e^(100*_C + 100*x) - 1)]

The following works for now, but the substitution used below is deprecated, so it outputs a deprecation warning (once per session) and more importantly it might not work in a future version of Sage. Maybe someone can give a more future-proof solution.

sage: y = function('y', x)
sage: de = diff(y, x) == y*(100 - y)
sage: sol = desolve(de, y)
sage: z = SR.var('z')
sage: solz = sol.substitute({y(x):z})
sol.substitute({y(x):z})  # deprecated
sage: solz.solve(z, to_poly_solve=True)
[z == 100*e^(100*_C + 100*x)/(e^(100*_C + 100*x) - 1)]

To work around the deprecation warning, one could do the replacement in the string representation of the expression and then read the string again into an expression. Not very elegant, but here goes:

sage: y = function('y', x)
sage: de = diff(y, x) == y*(100 - y)
sage: sol = desolve(de, y)
sage: z = SR.var('z')
sage: solz = SR(str(sol.lhs()).replace('y(x)', 'z')) == sol.rhs()
sage: solz
-1/100*log(z - 100) + 1/100*log(z) == _C + x
sage: solz.solve(z, to_poly_solve=True)
[z == 100*e^(100*_C + 100*x)/(e^(100*_C + 100*x) - 1)]

I'd still be interested in a cleaner solution.