Hi sympy-folk,

Aaron managed to track down the specific doctests that were causing the
problem, and it seems to be related to caching.
After some experimentation I've managed to produce a non quantum module
related set of commands that give the same result:

In [1]: x = Symbol('x', real=True)

In [2]: x_2 = Symbol('x_2', real=True)

In [3]: L = Symbol('L', real=True, positive=True)

In [4]: (x+1+1/x**5).extract_leading_order(x)
Out[4]:
⎛⎛1    ⎛1 ⎞⎞ ⎞
⎜⎜──, O⎜──⎟⎟,⎟
⎜⎜ 5   ⎜ 5⎟⎟ ⎟
⎝⎝x    ⎝x ⎠⎠ ⎠

In [5]: integrate(x_2*sin(n*pi*x_2/L)**2*2/L, (x_2, 0, L))
Out[5]:
            ⎛ 2       2  ⎞
            ⎜L       L   ⎟
          2⋅⎜── - ───────⎟
            ⎜4       2  2⎟
   L        ⎝     4⋅π ⋅n ⎠
─────── + ────────────────
   2  2          L
2⋅π ⋅n

The really strange part is that if you make the second variable x_1 or x_3,
the expression simplifies fine! The problem seems to be specifically with
the variable name x_2. Any idea why that might be?

Thanks!

Tomo

On Mon, Aug 22, 2011 at 3:36 PM, Tomo Lazovich <lazov...@fas.harvard.edu>wrote:

> Hi everyone,
>
> I just did a rebase of my final pull request because there were some merge
> conflicts, and I'm not getting a strange doctest failure that I don't
> understand.
>
> When I run ./bin/doctest, it tells me that this doctest (
> https://github.com/lazovich/sympy/blob/represent2/sympy/physics/quantum/piab.py#L80)
> is failing, giving:
>
> Failed example:
>     represent(p_bra*XOp()*p, basis=XKet)
> Expected:
>     L/2
> Got:
>     L/(2*pi**2*n**2) + 2*(L**2/4 - L**2/(4*pi**2*n**2))/L
>
> If you look at the top of piab.py, L carries the positive assumption with
> it. If you work this expression out by hand, you'll see it simplifies to
> L/2.
>
> The strange part, though, is that I get the correct L/2 output when I run
> it myself at the command line, both in the python terminal and in isympy:
>
> >>> from sympy.physics.quantum import *>>> from sympy.physics.quantum.piab 
> >>> import *>>> p = PIABKet()>>> p_bra = PIABBra()>>> 
> >>> represent(p_bra*XOp()*p, basis=XKet)L/2
>
>  Any idea why there would be a discrepancy between what I run in my
> terminal and the result from doctesting?
>
> Thanks for your help!
>
> Tomo
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to