Minh Nguyen wrote:
Hi David,
On Tue, Mar 9, 2010 at 10:55 AM, Dr. David Kirkby
<david.kir...@onetel.net> wrote:
<SNIP>
sage -t -long --verbose "devel/sage/sage/interfaces/mathematica.py"
Can you also try this?
sage -t -long -optional --verbose "devel/sage/sage/interfaces/mathematica.py"
Sure - see below:
I'm a bit puzzled by this one:
sage: def math_bessel_K(nu,x):
... return mathematica(nu).BesselK(x).N(20).sage()
...
sage: math_bessel_K(2,I) # optional - mathematica
0.180489972066962*I - 2.592886175491197 # 32-bit
-2.592886175491196978 + 0.1804899720669620266*I # 64-bit
What is supposed to be 32 or 64-bit ? Sage or Mathematica?
I assume Mathematica. I'm surprised the output changes depending on whether
Mathematica is 32 or 64-bit, but I don't have a 32-bit version of Mathematica
about. There may need to be a test if Mathematica is 32 or 64-bit. I know the
home-edition on Windows is 32-bit, even if one has a 64-bit version of Windows.
In contrast, I'm running a 32-bit version of Sage on a 64-bit operating system
with a 64-bit version of Mathematica.
Anyway, this is what I get if I compute the example below which fails miserably.
Note Mathematica is showing the real part of the complex number before the
imaginary part.
Sage seem to be expecting the imaginary component first - perhaps because this
is a 32-bit version of Sage? Since it's a 64-bit operating system, the version
of Mathematica is 64-bit.
In[1]:= N[BesselK[2,I],20]
Out[1]= -2.5928861754911969782 + 0.1804899720669620266 I
(BTW, you can get that result by typing the Bessel input (N[BesselK[2,I],20])
into Wolfram Alpha)
The one which is causing the problem
---------------
sage -t -long -optional --verbose "devel/sage/sage/interfaces/mathematica.py"
Trying:
set_random_seed(0L)
Expecting nothing
ok
Trying:
change_warning_output(sys.stdout)
Expecting nothing
ok
Trying:
m = mathematica###line 44:_sage_ >>> m = mathematica
Expecting nothing
ok
Trying:
a = m(Integer(1)) + m(Integer(1)); a # optional -
mathematica###line 45:_sage_ >>> a = m(1) + m(1); a # optional
- mathematica
Expecting:
2
ok
Trying:
a.parent() # optional - mathematica###line 47:_sage_
>>> a.parent() # optional - mathematica
Expecting:
Mathematica
ok
Trying:
m('1+1') # optional - mathematica###line 49:_sage_
>>> m('1+1') # optional - mathematica
Expecting:
2
ok
Trying:
m(Integer(3))**m(Integer(50)) # optional -
mathematica###line 51:_sage_ >>> m(3)**m(50) # optional
- mathematica
Expecting:
717897987691852588770249
ok
Trying:
m = mathematica###line 57:_sage_ >>> m = mathematica
Expecting nothing
ok
Trying:
m(Integer(2)).Plus(m(Integer(3))) # optional -
mathematica###line 58:_sage_ >>> m(2).Plus(m(3)) # optional
- mathematica
Expecting:
5
ok
Trying:
m(Integer(7)).Times(m(Integer(2)).Plus(m(Integer(3)))) # optional -
mathematica###line 65:_sage_ >>> m(7).Times(m(2).Plus(m(3))) # optional
- mathematica
Expecting:
35
ok
Trying:
m('7(2+3)') # optional - mathematica###line 67:_sage_
>>> m('7(2+3)') # optional - mathematica
Expecting:
35
ok
Trying:
eqn = mathematica('3x + 5 == 14') # optional - mathematica###line 75:_sage_
>>> eqn = mathematica('3x + 5 == 14') # optional - mathematica
Expecting nothing
ok
Trying:
eqn # optional - mathematica###line 76:_sage_
>>> eqn # optional - mathematica
Expecting:
5 + 3*x == 14
ok
Trying:
eqn.Solve('x') # optional - mathematica###line 78:_sage_
>>> eqn.Solve('x') # optional - mathematica
Expecting:
{{x -> 3}}
ok
Trying:
sys = mathematica('{x^2 - 3y == 3, 2x - y == 1}') # optional -
mathematica###line 80:_sage_ >>> sys = mathematica('{x^2 - 3y == 3, 2x - y ==
1}') # optional - mathematica
Expecting nothing
ok
Trying:
print sys # optional - mathematica###line 81:_sage_
>>> print sys # optional - mathematica
Expecting:
2
{x - 3 y == 3, 2 x - y == 1}
ok
Trying:
sys.Solve('{x, y}') # optional - mathematica###line 84:_sage_
>>> sys.Solve('{x, y}') # optional - mathematica
Expecting:
{{y -> -1, x -> 0}, {y -> 11, x -> 6}}
ok
Trying:
c = m(Integer(5)) # optional - mathematica###line
95:_sage_ >>> c = m(5) # optional - mathematica
Expecting nothing
ok
Trying:
print m('b + c x') # optional - mathematica###line 96:_sage_
>>> print m('b + c x') # optional - mathematica
Expecting:
b + c x
ok
Trying:
print m('b') + c*m('x') # optional - mathematica###line 98:_sage_
>>> print m('b') + c*m('x') # optional - mathematica
Expecting:
b + 5 x
ok
Trying:
m = mathematica###line 103:_sage_ >>> m = mathematica
Expecting nothing
ok
Trying:
eq1 = m('x^2 - 3y == 3') # optional - mathematica###line
104:_sage_ >>> eq1 = m('x^2 - 3y == 3') # optional - mathematica
Expecting nothing
ok
Trying:
eq2 = m('2x - y == 1') # optional - mathematica###line
105:_sage_ >>> eq2 = m('2x - y == 1') # optional - mathematica
Expecting nothing
ok
Trying:
v = m([eq1, eq2]); v # optional - mathematica###line
106:_sage_ >>> v = m([eq1, eq2]); v # optional - mathematica
Expecting:
{x^2 - 3*y == 3, 2*x - y == 1}
ok
Trying:
v.Solve(['x', 'y']) # optional - mathematica###line
108:_sage_ >>> v.Solve(['x', 'y']) # optional - mathematica
Expecting:
{{y -> -1, x -> 0}, {y -> 11, x -> 6}}
ok
Trying:
m = mathematica###line 119:_sage_ >>> m = mathematica
Expecting nothing
ok
Trying:
_ = mathematica('f[p_] = p^2'); # optional - mathematica###line
120:_sage_ >>> _ = mathematica('f[p_] = p^2'); # optional - mathematica
Expecting nothing
ok
Trying:
m('f[9]') # optional - mathematica###line
121:_sage_ >>> m('f[9]') # optional - mathematica
Expecting:
81
ok
Trying:
e = mathematica('Exp[x] - 3x == 0') # optional - mathematica###line
131:_sage_ >>> e = mathematica('Exp[x] - 3x == 0') # optional - mathematica
Expecting nothing
ok
Trying:
e.FindRoot(['x', Integer(2)]) # optional -
mathematica###line 132:_sage_ >>> e.FindRoot(['x', 2]) #
optional - mathematica
Expecting:
{x -> 1.512134551657842}
ok
Trying:
gp('solve(x=1,2,exp(x)-3*x)')###line 137:_sage_ >>>
gp('solve(x=1,2,exp(x)-3*x)')
Expecting:
1.512134551657842473896739678
ok
Trying:
mathematica('FindMinimum[x^3 - 6x^2 + 11x - 5, {x,3}]') # optional -
mathematica###line 144:_sage_ >>> mathematica('FindMinimum[x^3 - 6x^2 + 11x -
5, {x,3}]') # optional - mathematica
Expecting:
{0.6150998205402516, {x -> 2.5773502699629733}}
ok
Trying:
f = mathematica('x^3 - 6x^2 + 11x - 5') # optional - mathematica###line
146:_sage_ >>> f = mathematica('x^3 - 6x^2 + 11x - 5') # optional - mathematica
Expecting nothing
ok
Trying:
f.FindMinimum(['x', Integer(3)]) # optional -
mathematica###line 147:_sage_ >>> f.FindMinimum(['x', 3]) #
optional - mathematica
Expecting:
{0.6150998205402516, {x -> 2.5773502699629733}}
ok
Trying:
R = PolynomialRing(ZZ, names=('x',)); (x,) = R._first_ngens(1)###line
157:_sage_ >>> R.<x> = PolynomialRing(ZZ)
Expecting nothing
ok
Trying:
f =
(x**Integer(100)+Integer(17)*x+Integer(5))*(x**Integer(100)-Integer(5)*x+Integer(20))###line
158:_sage_ >>> f = (x**100+17*x+5)*(x**100-5*x+20)
Expecting nothing
ok
Trying:
f###line 159:_sage_ >>> f
Expecting:
x^200 + 12*x^101 + 25*x^100 - 85*x^2 + 315*x + 100
ok
Trying:
g = mathematica(str(f)) # optional - mathematica###line
161:_sage_ >>> g = mathematica(str(f)) # optional - mathematica
Expecting nothing
ok
Trying:
print g # optional - mathematica###line
162:_sage_ >>> print g # optional - mathematica
Expecting:
2 100 101 200
100 + 315 x - 85 x + 25 x + 12 x + x
ok
Trying:
g # optional - mathematica###line
165:_sage_ >>> g # optional - mathematica
Expecting:
100 + 315*x - 85*x^2 + 25*x^100 + 12*x^101 + x^200
ok
Trying:
print g.Factor() # optional - mathematica###line
167:_sage_ >>> print g.Factor() # optional - mathematica
Expecting:
100 100
(20 - 5 x + x ) (5 + 17 x + x )
ok
Trying:
f = mathematica('x^6 + (-y - 2)*x^5 + (y^3 + 2*y)*x^4 - y^4*x^3') #
optional - mathematica###line 173:_sage_ >>> f = mathematica('x^6 + (-y -
2)*x^5 + (y^3 + 2*y)*x^4 - y^4*x^3') # optional - mathematica
Expecting nothing
ok
Trying:
print f.Factor() # optional - mathematica###line
174:_sage_ >>> print f.Factor() # optional - mathematica
Expecting:
3 2 3
x (x - y) (-2 x + x + y )
ok
Trying:
n = mathematica(Integer(2434500)) # optional - mathematica###line
180:_sage_ >>> n = mathematica(2434500) # optional - mathematica
Expecting nothing
ok
Trying:
n.FactorInteger() # optional - mathematica###line
181:_sage_ >>> n.FactorInteger() # optional - mathematica
Expecting:
{{2, 2}, {3, 2}, {5, 3}, {541, 1}}
ok
Trying:
n = mathematica(Integer(2434500)) # optional - mathematica###line
183:_sage_ >>> n = mathematica(2434500) # optional - mathematica
Expecting nothing
ok
Trying:
F = n.FactorInteger(); F # optional - mathematica###line
184:_sage_ >>> F = n.FactorInteger(); F # optional - mathematica
Expecting:
{{2, 2}, {3, 2}, {5, 3}, {541, 1}}
ok
Trying:
F[Integer(1)] # optional - mathematica###line
186:_sage_ >>> F[1] # optional - mathematica
Expecting:
{2, 2}
ok
Trying:
F[Integer(4)] # optional - mathematica###line
188:_sage_ >>> F[4] # optional - mathematica
Expecting:
{541, 1}
ok
Trying:
_ = mathematica.eval("<<NumberTheory`FactorIntegerECM`"); # optional -
mathematica###line 193:_sage_ >>> _ =
mathematica.eval("<<NumberTheory`FactorIntegerECM`"); # optional - mathematica
Expecting nothing
ok
Trying:
mathematica.FactorIntegerECM('932901*939321') # optional -
mathematica###line 194:_sage_ >>>
mathematica.FactorIntegerECM('932901*939321') # optional - mathematica
Expecting:
8396109
ok
Trying:
t = '"%s"'%Integer(10)**Integer(10000) # ten thousand character
string.###line 205:_sage_ >>> t = '"%s"'%10^10000 # ten thousand character
string.
Expecting nothing
ok
Trying:
a = mathematica(t) # optional - mathematica###line 206:_sage_ >>>
a = mathematica(t) # optional - mathematica
Expecting nothing
ok
Trying:
a = mathematica.eval(t) # optional - mathematica###line 207:_sage_ >>>
a = mathematica.eval(t) # optional - mathematica
Expecting nothing
ok
Trying:
x = mathematica(pi/Integer(2)) # optional - mathematica###line
218:_sage_ >>> x = mathematica(pi/2) # optional - mathematica
Expecting nothing
ok
Trying:
print x # optional - mathematica###line 219:_sage_ >>>
print x # optional - mathematica
Expecting:
Pi
--
2
ok
Trying:
loads(dumps(x)) == x # optional - mathematica###line 223:_sage_ >>>
loads(dumps(x)) == x # optional - mathematica
Expecting:
True
ok
Trying:
n = x.N(Integer(50)) # optional - mathematica###line
225:_sage_ >>> n = x.N(50) # optional - mathematica
Expecting nothing
ok
Trying:
print n # optional - mathematica###line 226:_sage_ >>>
print n # optional - mathematica
Expecting:
1.5707963267948966192313216916397514420985846996876
ok
Trying:
loads(dumps(n)) == n # optional - mathematica###line 228:_sage_ >>>
loads(dumps(n)) == n # optional - mathematica
Expecting:
True
ok
Trying:
def math_bessel_K(nu,x):###line 233:_sage_ >>> def math_bessel_K(nu,x):
return mathematica(nu).BesselK(x).N(Integer(20)).sage()
Expecting nothing
ok
Trying:
math_bessel_K(Integer(2),I) # optional -
mathematica###line 236:_sage_ >>> math_bessel_K(2,I) #
optional - mathematica
Expecting:
0.180489972066962*I - 2.592886175491197
**********************************************************************
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/devel/sage/sage/interfaces/mathematica.py",
line 506, in __main__.example_0
Failed example:
math_bessel_K(Integer(2),I) # optional -
mathematica###line 236:_sage_ >>> math_bessel_K(2,I) #
optional - mathematica
Exception raised:
Traceback (most recent call last):
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/ncadoctest.py", line 1231,
in run_one_test
self.run_one_example(test, example, filename, compileflags)
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/sagedoctest.py", line 38,
in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename,
compileflags)
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/ncadoctest.py", line 1172,
in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_0[61]>", line 1, in <module>
math_bessel_K(Integer(2),I) # optional -
mathematica###line 236:_sage_ >>> math_bessel_K(2,I) #
optional - mathematica
File "<doctest __main__.example_0[60]>", line 2, in math_bessel_K
return mathematica(nu).BesselK(x).N(Integer(20)).sage()
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/lib/python/site-packages/sage/interfaces/expect.py",
line 1659, in sage
return self._sage_()
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/lib/python/site-packages/sage/interfaces/mathematica.py",
line 583, in _sage_
raise NotImplementedError, "Unable to parse Mathematica output: %s" %
result
NotImplementedError: Unable to parse Mathematica output:
-2.5928861754911969781676606701890232824936578132383372130575`20.149465350282203
+
0.1804899720669620266296208808383786504962257035154109364317`18.99213497581376*i
Trying:
slist = [[Integer(1), Integer(2)], RealNumber('3.'), Integer(4) + I]###line
242:_sage_ >>> slist = [[1, 2], 3., 4 + I]
Expecting nothing
ok
Trying:
mlist = mathematica(slist); mlist # optional - mathematica###line
243:_sage_ >>> mlist = mathematica(slist); mlist # optional - mathematica
Expecting:
{{1, 2}, 3., 4 + I}
ok
Trying:
slist2 = list(mlist); slist2 # optional - mathematica###line
245:_sage_ >>> slist2 = list(mlist); slist2 # optional - mathematica
Expecting:
[{1, 2}, 3., 4 + I]
ok
Trying:
slist2[Integer(0)] # optional -
mathematica###line 247:_sage_ >>> slist2[0] #
optional - mathematica
Expecting:
{1, 2}
ok
Trying:
slist2[Integer(0)].parent() # optional -
mathematica###line 249:_sage_ >>> slist2[0].parent() #
optional - mathematica
Expecting:
Mathematica
ok
Trying:
slist3 = mlist.sage(); slist3 # optional - mathematica###line
251:_sage_ >>> slist3 = mlist.sage(); slist3 # optional - mathematica
Expecting:
[[1, 2], 3.00000000000000, I + 4]
**********************************************************************
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/devel/sage/sage/interfaces/mathematica.py",
line 520, in __main__.example_0
Failed example:
slist3 = mlist.sage(); slist3 # optional - mathematica###line
251:_sage_ >>> slist3 = mlist.sage(); slist3 # optional - mathematica
Exception raised:
Traceback (most recent call last):
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/ncadoctest.py", line 1231,
in run_one_test
self.run_one_example(test, example, filename, compileflags)
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/sagedoctest.py", line 38,
in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename,
compileflags)
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/ncadoctest.py", line 1172,
in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_0[67]>", line 1, in <module>
slist3 = mlist.sage(); slist3 # optional - mathematica###line
251:_sage_ >>> slist3 = mlist.sage(); slist3 # optional - mathematica
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/lib/python/site-packages/sage/interfaces/expect.py",
line 1659, in sage
return self._sage_()
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/lib/python/site-packages/sage/interfaces/mathematica.py",
line 583, in _sage_
raise NotImplementedError, "Unable to parse Mathematica output: %s" %
result
NotImplementedError: Unable to parse Mathematica output:
{{1, 2}, 3., 4 + i}
Trying:
mathematica('10.^80') # optional - mathematica###line 256:_sage_ >>>
mathematica('10.^80') # optional - mathematica
Expecting:
1.*^80
ok
Trying:
mathematica('10.^80').sage() # optional - mathematica###line 258:_sage_
>>> mathematica('10.^80').sage() # optional - mathematica
Expecting:
1.00000000000000e80
**********************************************************************
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/devel/sage/sage/interfaces/mathematica.py",
line 527, in __main__.example_0
Failed example:
mathematica('10.^80').sage() # optional - mathematica###line 258:_sage_
>>> mathematica('10.^80').sage() # optional - mathematica
Exception raised:
Traceback (most recent call last):
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/ncadoctest.py", line 1231,
in run_one_test
self.run_one_example(test, example, filename, compileflags)
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/sagedoctest.py", line 38,
in run_one_example
OrigDocTestRunner.run_one_example(self, test, example, filename,
compileflags)
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/bin/ncadoctest.py", line 1172,
in run_one_example
compileflags, 1) in test.globs
File "<doctest __main__.example_0[69]>", line 1, in <module>
mathematica('10.^80').sage() # optional - mathematica###line
258:_sage_ >>> mathematica('10.^80').sage() # optional - mathematica
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/lib/python/site-packages/sage/interfaces/expect.py",
line 1659, in sage
return self._sage_()
File
"/export/home/drkirkby/32/sage-4.3.4.alpha0/local/lib/python/site-packages/sage/interfaces/mathematica.py",
line 583, in _sage_
raise NotImplementedError, "Unable to parse Mathematica output: %s" %
result
NotImplementedError: Unable to parse Mathematica output:
1.*^80
Trying:
set_random_seed(0L)
Expecting nothing
ok
Trying:
change_warning_output(sys.stdout)
Expecting nothing
ok
Trying:
set_random_seed(0L)
Expecting nothing
ok
Trying:
change_warning_output(sys.stdout)
Expecting nothing
ok
Trying:
m = mathematica('x^2 + 5*y') # optional -
mathematica###line 565:_sage_ >>> m = mathematica('x^2 + 5*y')
# optional - mathematica
Expecting nothing
ok
Trying:
m.sage() # optional -
mathematica###line 566:_sage_ >>> m.sage()
# optional - mathematica
Expecting:
x^2 + 5*y
ok
Trying:
m = mathematica('Sin[Sqrt[1-x^2]] * (1 - Cos[1/x])^2') # optional -
mathematica###line 571:_sage_ >>> m = mathematica('Sin[Sqrt[1-x^2]] * (1 -
Cos[1/x])^2') # optional - mathematica
Expecting nothing
ok
Trying:
m.sage() # optional -
mathematica###line 572:_sage_ >>> m.sage()
# optional - mathematica
Expecting:
(cos(1/x) - 1)^2*sin(sqrt(-x^2 + 1))
ok
Trying:
set_random_seed(0L)
Expecting nothing
ok
Trying:
change_warning_output(sys.stdout)
Expecting nothing
ok
Trying:
len(mathematica([Integer(1),RealNumber('1.'),Integer(2)])) # optional -
mathematica###line 595:_sage_ >>> len(mathematica([1,1.,2])) # optional -
mathematica
Expecting:
3
ok
Trying:
set_random_seed(0L)
Expecting nothing
ok
Trying:
change_warning_output(sys.stdout)
Expecting nothing
ok
Trying:
P = mathematica('Plot[Sin[x],{x,-2Pi,4Pi}]') # optional -
mathematica###line 609:_sage_ >>> P =
mathematica('Plot[Sin[x],{x,-2Pi,4Pi}]') # optional - mathematica
Expecting nothing
ok
Trying:
show(P) # optional -
mathematica###line 610:_sage_ >>> show(P)
# optional - mathematica
Expecting nothing
*** *** Error: TIMED OUT! PROCESS KILLED! *** ***
*** *** Error: TIMED OUT! *** ***
[1800.5 s]
----------------------------------------------------------------------
The following tests failed:
sage -t -long -optional --verbose
"devel/sage/sage/interfaces/mathematica.py" # Segfault
Total time for all tests: 1800.5 seconds
drkir...@redstart:~/32/sage-4.3.4.alpha0$
--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org