← All challenges
hardsympy/sympy · v1.11

display bug while using pretty_print with sympy.vector object in the terminal

mathsymbolicbase fa9b4b140e
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

The following code jumbles some of the outputs in the terminal, essentially by inserting the unit vector in the middle -

python
from sympy import *
from sympy.vector import CoordSys3D, Del

init_printing()

delop = Del()
CC_ = CoordSys3D("C")
x,    y,    z    = CC_.x, CC_.y, CC_.z
xhat, yhat, zhat = CC_.i, CC_.j, CC_.k

t = symbols("t")
ten = symbols("10", positive=True)
eps, mu = 4*pi*ten**(-11), ten**(-5)

Bx = 2 * ten**(-4) * cos(ten**5 * t) * sin(ten**(-3) * y)
vecB = Bx * xhat
vecE = (1/eps) * Integral(delop.cross(vecB/mu).doit(), t)

pprint(vecB)
print()
pprint(vecE)
print()
pprint(vecE.doit())

Output:

python
⎛     ⎛y_C⎞    ⎛  5  ⎞⎞    
⎜2⋅sin⎜───⎟ i_C⋅cos⎝10 ⋅t⎠⎟
⎜     ⎜  3⎟           ⎟    
⎜     ⎝10 ⎠           ⎟    
⎜─────────────────────⎟    
⎜           4         ⎟    
⎝         10          ⎠    

⎛     ⌠                           ⎞    
⎜     ⎮       ⎛y_C⎞    ⎛  5  ⎞    ⎟ k_C
⎜     ⎮ -2⋅cos⎜───⎟⋅cos⎝10 ⋅t⎠    ⎟    
⎜     ⎮       ⎜  3⎟               ⎟    
⎜  11 ⎮       ⎝10 ⎠               ⎟    
⎜10  ⋅⎮ ─────────────────────── dt⎟    
⎜     ⎮             2             ⎟    
⎜     ⎮           10              ⎟    
⎜     ⌡                           ⎟    
⎜─────────────────────────────────⎟    
⎝               4⋅π               ⎠    

⎛   4    ⎛  5  ⎞    ⎛y_C⎞ ⎞    
⎜-10 ⋅sin⎝10 ⋅t⎠⋅cos⎜───⎟ k_C ⎟
⎜                   ⎜  3⎟ ⎟    
⎜                   ⎝10 ⎠ ⎟    
⎜─────────────────────────⎟    
⎝           2⋅π           ⎠    ```
The environment starts at commit fa9b4b140ec0 (sympy/sympy 1.11), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.