[sage-devel] problem with abs on integration

2017-10-08 Thread Stephen Weppner
Really strange error, a change from (x+2) to (x-2) causes an error? This is 
Sage 8.0. This worked 2 years ago but broken now.


#This works:
var ('x,a')
assume(a, 'real')
assume (a > 0)
Psi = sqrt(a)* exp(-a*(abs(x+2)))
integral(Psi^2,x, -oo,oo)

(x, a) 1

#This does not work , changed a "+" sign to "-" sign
var ('x,a')
assume(a, 'real')
assume (a > 0)
Psi = sqrt(a)* exp(-a*(abs(x-2)))
integral(Psi^2,x, -oo,oo)

(x, a) Error in lines 5-5 Traceback (most recent call last): File 
"/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 996, 
in execute exec compile(block+'\n', '', 'single') in namespace, locals File 
"", line 1, in  File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/misc/functional.py", 
line 721, in integral return x.integral(*args, **kwds) File 
"sage/symbolic/expression.pyx", line 12275, in 
sage.symbolic.expression.Expression.integral 
(/ext/sage/sage-8.0/src/build/cythonized/sage/symbolic/expression.cpp:69945) 
return integral(self, *args, **kwds) File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py",
 
line 799, in integrate return definite_integral(expression, v, a, b, 
hold=hold) File "sage/symbolic/function.pyx", line 996, in 
sage.symbolic.function.BuiltinFunction.__call__ 
(/ext/sage/sage-8.0/src/build/cythonized/sage/symbolic/function.cpp:11397) 
res = super(BuiltinFunction, self).__call__( File 
"sage/symbolic/function.pyx", line 486, in 
sage.symbolic.function.Function.__call__ 
(/ext/sage/sage-8.0/src/build/cythonized/sage/symbolic/function.cpp:6440) 
res = g_function_evalv(self._serial, vec, hold) File 
"sage/symbolic/function.pyx", line 1085, in 
sage.symbolic.function.BuiltinFunction._evalf_or_eval_ 
(/ext/sage/sage-8.0/src/build/cythonized/sage/symbolic/function.cpp:12757) 
return self._eval0_(*args) File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py",
 
line 181, in _eval_ return integrator(*args) File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py",
 
line 34, in maxima_integrator result = maxima.sr_integral(expression, v, a, 
b) File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py",
 
line 805, in sr_integral return 
max_to_sr(maxima_eval(([max_integrate],[sr_to_max(SR(a)) for a in args]))) 
File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py",
 
line 1702, in max_to_sr args=[max_to_sr(a) for a in max_args] File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py",
 
line 1702, in max_to_sr args=[max_to_sr(a) for a in max_args] File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py",
 
line 1702, in max_to_sr args=[max_to_sr(a) for a in max_args] File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py",
 
line 1693, in max_to_sr sage_expr=SR(maxima(expr)) File 
"sage/structure/parent.pyx", line 934, in 
sage.structure.parent.Parent.__call__ 
(/ext/sage/sage-8.0/src/build/cythonized/sage/structure/parent.c:9799) 
return mor._call_(x) File "sage/structure/coerce_maps.pyx", line 282, in 
sage.structure.coerce_maps.NamedConvertMap._call_ 
(/ext/sage/sage-8.0/src/build/cythonized/sage/structure/coerce_maps.c:6299) 
cdef Element e = method(C) File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_abstract.py",
 
line 1257, in _symbolic_ return R(self._sage_()) File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_abstract.py",
 
line 1232, in _sage_ maxima=self.parent()) File 
"/ext/sage/sage-8.0/local/lib/python2.7/site-packages/sage/calculus/calculus.py",
 
line 2151, in symbolic_expression_from_maxima_string raise 
TypeError("unable to make sense of Maxima expression '%s' in Sage"%s) 
TypeError: unable to make sense of Maxima expression 
'if(-(_SAGE_VAR_x-2)>0,(e^-(4*_SAGE_VAR_a)*(e^(2*_SAGE_VAR_a*_SAGE_VAR_x)-2*e^(4*_SAGE_VAR_a)))/(2*_SAGE_VAR_a),-e^(4*_SAGE_VAR_a-2*_SAGE_VAR_a*_SAGE_VAR_x)/(2*_SAGE_VAR_a))'
 
in Sage

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: sets and sorted tuples, possibly python 3 related

2017-10-08 Thread 'Martin R' via sage-devel
Am Sonntag, 8. Oktober 2017 14:10:21 UTC+2 schrieb Maarten Derickx:
>
> In Python 3 you can still sort. But the elements that you are sorting have 
> to be of the same type. So no mixing of lists with strings, integers and 
> tuples anymore. But sorting a list of strings is no problem.


OK, I'll take this as the real answer.
 

> For the given ticket I would not replace the internal representation and 
> just stick to fixing the hash function.
>
>
I am pretty sure that I want to change the internal representation.  As I 
wrote on the ticket, I am using perfect matchings a lot, and 

sage: PerfectMatching([[3,1],[2,4]])
[(3, 1), (2, 4)]


is a huge pain, because I tend to forget that the output of 
PerfectMatching(some_function_producing_a_perfect_matching_on_1234)[0] is 
(essentially) random.

Moreover, this is inconsistent with at least SetPartitions, Subsets, 
Graphs, Posets, where a mathematical set is either representet as a set or 
as a sorted list.

Martin

>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: sets and sorted tuples, possibly python 3 related

2017-10-08 Thread Maarten Derickx
In Python 3 you can still sort. But the elements that you are sorting have to 
be of the same type. So no mixing of lists with strings, integers and tuples 
anymore. But sorting a list of strings is no problem.

For the given ticket I would not replace the internal representation and just 
stick to fixing the hash function.

Looking for what the best internal representation is, is not something that has 
nice precut answers and requires a lot of performance testing. If you care 
about speed I would make the improved internal representation for performance 
reasons a separate ticket.

Things to test would be:
1. Initialisation time of matchings
2. A subset to your liking of the most important high level functions of 
matchings
3. Some low level access function of matchings
4. All of the above for both small and big matchings.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: sets and sorted tuples, possibly python 3 related

2017-10-08 Thread 'Martin R' via sage-devel
One further thing to consider: for some methods of PerfectMatching (eg., 
crossings) we need a totally ordered ground set.

Does frozenset respect a total order, if there is one - eg. over the 
integers?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.