← All challenges
hardsympy/sympy · v1.8

`refine()` does not understand how to simplify complex arguments

mathsymbolicbase 748ce73479
Mode

60 minutes, the full token budget.

  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to310 XP

Opens VS Code with an AI agent in a new tab. Prompts, tokens, tool calls and test runs are recorded and scored.

Problem statement

Just learned about the refine-function, which would come in handy frequently for me. But
refine() does not recognize that argument functions simplify for real numbers.

>>> from sympy import *                                                     
>>> var('a,x')                                                              
>>> J = Integral(sin(x)*exp(-a*x),(x,0,oo))                                     
>>> J.doit()
	Piecewise((1/(a**2 + 1), 2*Abs(arg(a)) < pi), (Integral(exp(-a*x)*sin(x), (x, 0, oo)), True))
>>> refine(J.doit(),Q.positive(a))                                                 
        Piecewise((1/(a**2 + 1), 2*Abs(arg(a)) < pi), (Integral(exp(-a*x)*sin(x), (x, 0, oo)), True))
>>> refine(abs(a),Q.positive(a))                                            
	a
>>> refine(arg(a),Q.positive(a))                                            
	arg(a)

I cann't find any open issues identifying this. Easy to fix, though.

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