Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can get the dummy variable by

dummy_var = sols[0].rhs().variables()[0]

And then define a callable function changing the dummy variable to a proper symbolic one.

var('z')
f(z) = sols[0].rhs().subs({dummy_var:z})

Now you can simply do f(0), f(1) or whatever you want.

PS, for some reason it does not work if you try to define a callable function using the dummy variable directly, like

f(dummy_var) = sols[0].rhs()

You can get the dummy variable by

dummy_var = sols[0].rhs().variables()[0]

And then define a callable function changing the dummy variable to a proper symbolic one.

var('z')
f(z) = sols[0].rhs().subs({dummy_var:z})

Now you can simply do f(0), f(1) or whatever you want.

PS, for some reason it does not work if you try to define a callable function using the dummy variable directly, like

f(dummy_var) = sols[0].rhs()

EDIT:

Another possibility is to use the solveset from sympy

from sympy import solveset
solveset(sy(t)._sympy_())

It gives the solution as a union of sets.