Python Solve Nonlinear Equation