ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 14 Nov 2014 23:58:44 +0100Bizarre errorhttps://ask.sagemath.org/question/24863/bizarre-error/I'm sorry that the function in question is rather messy, but the problem is rather specific. I'm setting a constant 'c' and evaluating the local maximum of a function like so:
c = 1E6
find_local_maximum(lambda f: abs(1000*(2*pi*f*i)/(0.1*(2*pi*f*i)^2+1000*(2*pi*f*i)+c)), 1000, 3000)
In this case, I get the expected output. If I set `c = 1E7`, or a nearby value, like `c = 1.123E7` or `c = 3E7`, I get the following error:
RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.
Now, if I set `c = 5E7`or `c = 1E8`, I get no error.
It's also worth noting that `find_local_minimum` with the exact same set of values and function does not have this same issue. Finally, the type of c is `sage.rings.real_mpfr.RealLiteral` in each case.
What could be causing this problem? Is there a workaround or a potential bug fix?Thu, 13 Nov 2014 20:22:49 +0100https://ask.sagemath.org/question/24863/bizarre-error/Answer by vdelecroix for <p>I'm sorry that the function in question is rather messy, but the problem is rather specific. I'm setting a constant 'c' and evaluating the local maximum of a function like so:</p>
<pre><code>c = 1E6
find_local_maximum(lambda f: abs(1000*(2*pi*f*i)/(0.1*(2*pi*f*i)^2+1000*(2*pi*f*i)+c)), 1000, 3000)
</code></pre>
<p>In this case, I get the expected output. If I set <code>c = 1E7</code>, or a nearby value, like <code>c = 1.123E7</code> or <code>c = 3E7</code>, I get the following error:</p>
<pre><code>RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.
</code></pre>
<p>Now, if I set <code>c = 5E7</code>or <code>c = 1E8</code>, I get no error.</p>
<p>It's also worth noting that <code>find_local_minimum</code> with the exact same set of values and function does not have this same issue. Finally, the type of c is <code>sage.rings.real_mpfr.RealLiteral</code> in each case. </p>
<p>What could be causing this problem? Is there a workaround or a potential bug fix?</p>
https://ask.sagemath.org/question/24863/bizarre-error/?answer=24869#post-id-24869Hello,
I got the same problem (using sage-6.4).
At least, here is a workaround using **fast_callable** (which is also much faster)
sage: expr = abs(1000*(2*pi*f*i)/(0.1*(2*pi*f*i)^2+1000*(2*pi*f*i)+c))
sage: g = fast_callable(expr.subs(c=1E6), domain=CDF, vars=[f])
sage: find_local_maximum(g, 1000, 3000)
(1.0, (1591.549431507781+0j))
sage: g = fast_callable(expr.subs(c=1E7), domain=CDF, vars=[f])
sage: find_local_maximum(g, 1000, 3000)
(1.0, (1591.549431507781+0j))
**fast_callable** somehow tries to compile your expression in a fast function. If you intend to evaluate a lot an expression it is always a good idea.
One annoying thing is that you need to declare the function to be over complex because you use **i** in your formula.
Vincnet
Fri, 14 Nov 2014 23:58:44 +0100https://ask.sagemath.org/question/24863/bizarre-error/?answer=24869#post-id-24869