from sympy.abc import a, s, u, t from sympy import solve expr = u*t+1/2*a*t**2-s solve(expr,t,dict = True)