Christopher Smith
Christopher Smith
Nice find! I was wondering where this was being mishandled so badly in another issue/PR. The change is straightforward, I think:  (The docstring was just there to demonstrate that...
Go ahead and give it a try. Unanticipated effects is the bane of my experience with SymPy. If there is something wrong, tests will fail. The change I recommended was...
``` **Status:** Started ``` Original comment: http://code.google.com/p/sympy/issues/detail?id=3530#c1 Original author: https://code.google.com/u/117933771799683895267/
An [answer](https://stackoverflow.com/a/73734252/1089161) was suggested at the issue. Note that * on your second attempt you misused `solveset`. * The output of `nonlinsolve` is probably fine but you have to select...
> * not sure of what is wrong in my second attempt of solveset You passed a list (`[eq1,eq2]`), not an expression or relational, for `f`: 
I do not know how to work well with the sets/imagesets. But here is one way: 
``` as_leading_term is your workhorse: >>> eq=(x+1)**10000 >>> eq.as_leading_term(x) 1 >>> eq.subs(x,1/x).as_leading_term(x).subs(x, 1/x) x**10000 >>> ((2*x+1)**100).subs(x,1/x).as_leading_term(x).subs(x, 1/x) 1267650600228229401496703205376*x**100 If you only want the degree, try: def degree(e, x): return -e.subs(x,...
``` But watch out if it's not a "polynomial": >>> -(exp(x)).subs(x, 1/x).leadterm(x)[0] Traceback (most recent call last): File "", line 1, in File "sympy\core\expr.py", line 2536, in leadterm should have...
``` **Labels:** EasyToFix ``` Original comment: http://code.google.com/p/sympy/issues/detail?id=3223#c3 Original author: https://code.google.com/u/117933771799683895267/
Here's a more explicit example of what I showed above: ``` >>> def deg(e, s): ... try: ... return -e.subs(x,1/x).leadterm(x)[1] ... except: ... return e.subs(x, 1/x).as_leading_term(x).subs(x, 1/x).as_base_exp()[1]/s.as_base_exp()[1] ... >>> deg(exp(x)**2+2*exp(x)+x,...