Sympy: How To Save Solution From "solve" For Reuse?
I am using python3 with sympy 0.7.4.1. I couldn't figure out how to save solution for future use (I can't find anything useful in the manuel or on google). For example, I have some
Solution 1:
First note that in general, you can have multiple solutions. This is why set=True is returning a set of tuples (instead of just a single tuple), and dict=True is returning a list of dicts (instead of just one).
The easiest one is dict=True. To access the solutions, do something like
sols = solve([t1 + t2 + t3, eq1, eq2], [t1, t2, t3])
sols[0][t1] # This is t1 in the first solution
If there were more solutions, they would be sols[1]
, sols[2]
, and so on. In each case, the key in the dictionary is the symbol that that solution equals, like t1
or t2
.
Post a Comment for "Sympy: How To Save Solution From "solve" For Reuse?"