How to make sympy acknowledge that 0/0 is a division by zero
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Drifting Through My Dreams
--
Chapters
00:00 How To Make Sympy Acknowledge That 0/0 Is A Division By Zero
00:52 Accepted Answer Score 2
01:25 Thank you
--
Full question
https://stackoverflow.com/questions/5007...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #sympy
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Drifting Through My Dreams
--
Chapters
00:00 How To Make Sympy Acknowledge That 0/0 Is A Division By Zero
00:52 Accepted Answer Score 2
01:25 Thank you
--
Full question
https://stackoverflow.com/questions/5007...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #sympy
#avk47
ACCEPTED ANSWER
Score 2
As you noticed, the issue is that x/x evaluates to 1 immediately, so a subsequent substitution of x by 0 is not really happening. 
A way to avoid evaluation is to pass evaluate=False flag to the product of x with 1/x:
>>> expr = Mul(x, 1/x, evaluate=False)
>>> expr
x/x
>>> expr.subs(x, 0)
nan    
The result is "Not A Number", meaning this does not evaluate to a number.
(In SymPy, all division is multiplication by reciprocal quantity: there are Add, Mul, Pow but no Div or Sub).