import sympy as sym x = sym.symbols('x') E = sym.solve(x**3 - 2*x - 1, x) print('All solutions: ', E) print('The last solution among the solutions: ', E[-1])