On Friday, June 2, 2017 at 6:33:12 AM UTC-6, Stan wrote:
>
> I asked this question before on ask.sagemath (
> https://ask.sagemath.org/question/37744/why-is-assume-so-slow/) but 
> haven't found an answer yet, so perhaps someone here has an idea.
>
> Basically, declaring assumptions using `assume()`  or within `var('x', 
> domain='real') takes an awful lot of time, e.g.:
>
> variables = ['a_' + str(i) for i in srange(10)]
> for var1 in variables: var(var1, domain='real')
>
> If I increase the number of variables, the time needed increases more than 
> proportionally. See 
> https://cocalc.com/projects/34b4b62a-2621-47c8-9bda-cde3a855f995/files/test_assumptions.ipynb
>  
>
> Does anyone know why this is and how this could be accelerated?
>

There's a good chance that this is supposed to slow down, since the 
assumption data base probably needs to be checked for inconsistencies. As 
the data base grows, this gets more expensive. It's a little excessive, 
though. The amount of interaction with the maxima library increases too!

D=(SR.symbol("x"+str(i)) for i in range(10000)).next
%prun assume(D(), 'real')
      245    0.048    0.000    0.051    0.000 maxima_lib.py:408(_eval_line)
       85    0.002    0.000    0.002    0.000 
maxima_lib.py:270(max_to_string)
       24    0.001    0.000    0.001    0.000 {sage.symbolic.ring.var}
       92    0.001    0.000    0.004    0.000 {repr}
        3    0.001    0.000    0.011    0.004 {method 'simplify_factorial' 
of 'sage.symbolic.expression.Expression' objects}
       13    0.001    0.000    0.007    0.001 
calculus.py:1957(symbolic_expression_from_maxima_string)

Doing it another time:
%prun assume(D(), 'real')
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      372    0.074    0.000    0.079    0.000 maxima_lib.py:408(_eval_line)
      118    0.003    0.000    0.003    0.000 
maxima_lib.py:270(max_to_string)
       48    0.002    0.000    0.002    0.000 {sage.symbolic.ring.var}
      158    0.001    0.000    0.006    0.000 {repr}
       24    0.001    0.000    0.008    0.000 
calculus.py:1957(symbolic_expression_from_maxima_string)
        2    0.001    0.000    0.089    0.044 {cmp}
   151/35    0.001    0.000    0.003    0.000 
expression_conversions.py:155(__call__)


-- 
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.

Reply via email to