Ask Your Question
1

Different answers with gaunt()

asked 2013-06-12 04:57:11 -0500

flangeball gravatar image

updated 2013-06-12 05:55:40 -0500

tmonteil gravatar image

Why do the following bits of code give different outputs? (Note the use of Integer() for the second example):

from sage.functions.wigner import gaunt as gauntsage

for l1, l2, l3, m1, m2, m3 in [(l1, l2, l3, m1, m2, m3) for l1 in range(0,2) for l2 in range(0,2) for l3 in range(0,2)     for m1 in range(-3,4) for m2 in range(-3,4) for m3 in range(-3,4)]:
  g = gauntsage(l1, l2, l3, m1, m2, m3)

  if abs(g) > 1e-12:
    print "    GC_table(%d,%d,%d,%d,%d,%d) = %.12f_dp ! %s" % (l1, m1, l2, m2, l3, m3, g, repr(g))

outputs

GC_table(0,0,0,0,0,0) = 0.282094791774_dp ! 1/2/sqrt(pi)
GC_table(0,0,1,-1,1,1) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(0,0,1,0,1,0) = 0.282094791774_dp ! 1/2/sqrt(pi)
GC_table(0,0,1,1,1,-1) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(1,-1,0,0,1,1) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(1,0,0,0,1,0) = 0.282094791774_dp ! 1/2/sqrt(pi)
GC_table(1,1,0,0,1,-1) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(1,-1,1,1,0,0) = -0.282094791774_dp ! -0.5/sqrt(pi)
GC_table(1,0,1,0,0,0) = 0.282094791774_dp ! 1/2/sqrt(pi)
GC_table(1,1,1,-1,0,0) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(1,-1,1,0,1,1) = 0.488602511903_dp ! 1/2*sqrt(3)/sqrt(pi)
GC_table(1,-1,1,1,1,0) = -0.488602511903_dp ! -1/2*sqrt(3)/sqrt(pi)
GC_table(1,0,1,-1,1,1) = -0.488602511903_dp ! -1/2*sqrt(3)/sqrt(pi)
GC_table(1,0,1,1,1,-1) = 0.488602511903_dp ! 1/2*sqrt(3)/sqrt(pi)
GC_table(1,1,1,-1,1,0) = 0.488602511903_dp ! 1/2*sqrt(3)/sqrt(pi)
GC_table(1,1,1,0,1,-1) = -0.488602511903_dp ! -1/2*sqrt(3)/sqrt(pi)

and

from sage.functions.wigner import gaunt as gauntsage

for l1, l2, l3, m1, m2, m3 in [(Integer(l1), Integer(l2), Integer(l3), Integer(m1), Integer(m2), Integer(m3)) for l1 in range(0,2) for l2 in range(0,2) for l3 in range(0,2)     for m1 in range(-3,4) for m2 in range(-3,4) for m3 in range(-3,4)]:
  g = gauntsage(l1, l2, l3, m1, m2, m3)

  if abs(g) > 1e-12:
    print "    GC_table(%d,%d,%d,%d,%d,%d) = %.12f_dp ! %s" % (l1, m1, l2, m2, l3, m3, g, repr(g))

outputs

GC_table(0,0,0,0,0,0) = 0.282094791774_dp ! 1/2/sqrt(pi)
GC_table(0,0,1,-1,1,1) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(0,0,1,0,1,0) = 0.282094791774_dp ! 1/2/sqrt(pi)
GC_table(0,0,1,1,1,-1) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(1,-1,0,0,1,1) = -0.282094791774_dp ! -1/2/sqrt(pi)
GC_table(1,0,0,0,1,0) = 0.282094791774_dp ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-06-12 05:45:46 -0500

kcrisman gravatar image

updated 2013-06-12 05:53:54 -0500

Definitely some kind of bug.

sage: gaunt(1,1,1,0,1,-1)
0
sage: gaunt(int(1),int(1),int(1),int(0),int(1),int(-1))
1/2*sqrt(3)/sqrt(pi)

(Notice you don't have to actually import it to use it.)

The problem is that there is some division going on that doesn't check types.

bigL = (l_1 + l_2 + l_3) / 2

and

sage: (int(1)+int(1)+int(1))/int(2)
1
sage: (1+1+1)/2
3/2

For now you can get around this by using srange (Sage range, as it were):

sage: type(range(0,2)[0])
int
sage: type(srange(0,2)[0])
sage.rings.integer.Integer

This is now ticket 14735.

edit flag offensive delete link more

Comments

Ok, thanks! It did seem odd and wasn't expected behaviour, but I wasn't sure if it was just a known caveat for sage.

flangeball gravatar imageflangeball ( 2013-06-12 05:56:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-06-12 04:57:11 -0500

Seen: 128 times

Last updated: Jun 12 '13