← All challenges
easysympy/sympy · v1.1

Issue with a substitution that leads to an undefined expression

Try this bug with AI

Fix it in the original repo with an AI agent and get feedback on how you worked.

2 free rounds each week

Round mode
  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to135 XP
Sign up or sign in to start

Read the sample report

From a simulated Django round

You changed code before reproducing the bug.

Run the failing test before the first edit, so you know the failure you are fixing and can tell when it is gone.

Problem statement
Python 3.6.4 |Anaconda custom (64-bit)| (default, Dec 21 2017, 15:39:08) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from sympy import *

In [2]: a,b = symbols('a,b')

In [3]: r = (1/(a+b) + 1/(a-b))/(1/(a+b) - 1/(a-b))

In [4]: r.subs(b,a)
Out[4]: 1

In [6]: import sympy

In [7]: sympy.__version__
Out[7]: '1.1.1'

If b is substituted by a, r is undefined. It is possible to calculate the limit
r.limit(b,a) # -1

But whenever a subexpression of r is undefined, r itself is undefined.

The environment starts at commit 5c1644ff85e1 (sympy/sympy 1.1), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.