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.Wed, 18 Jul 2012 11:01:12 +0200Existence of a limithttps://ask.sagemath.org/question/9158/existence-of-a-limit/How does one (i.e. automatically in an own program) recognize existence of a limit?
So far I've discovered that **-oo, oo, ind, und** cause the non-existence, I just dunno how to test these "values". Obvious
if limit(f, x=oo, dir='+') == und:
...
does not work...
Sage 5.1
Kubuntu 12.04Wed, 18 Jul 2012 07:04:23 +0200https://ask.sagemath.org/question/9158/existence-of-a-limit/Answer by twch for <p>How does one (i.e. automatically in an own program) recognize existence of a limit?</p>
<p>So far I've discovered that <strong>-oo, oo, ind, und</strong> cause the non-existence, I just dunno how to test these "values". Obvious</p>
<pre><code>if limit(f, x=oo, dir='+') == und:
...
</code></pre>
<p>does not work...</p>
<p>Sage 5.1
Kubuntu 12.04</p>
https://ask.sagemath.org/question/9158/existence-of-a-limit/?answer=13829#post-id-13829Hi as far as I understand the problem is that oo so on are symbolic expressios. If you try to compare them with == sage returns as a new symbolic expression the symbolic equationion:
var('x,y')
print x==y
print type(x==y)
returns
x == y
<type 'sage.symbolic.expression.Expression'>
A soultion seems to be to cast the symbolic equation to a boolean:
print bool(x==y)
print bool(x==x)
which returns
False
True
Wed, 18 Jul 2012 09:25:09 +0200https://ask.sagemath.org/question/9158/existence-of-a-limit/?answer=13829#post-id-13829Comment by Mathemage for <p>Hi as far as I understand the problem is that oo so on are symbolic expressios. If you try to compare them with == sage returns as a new symbolic expression the symbolic equationion:</p>
<pre><code>var('x,y')
print x==y
print type(x==y)
</code></pre>
<p>returns</p>
<pre><code>x == y
<type 'sage.symbolic.expression.Expression'>
</code></pre>
<p>A soultion seems to be to cast the symbolic equation to a boolean:</p>
<pre><code>print bool(x==y)
print bool(x==x)
</code></pre>
<p>which returns</p>
<pre><code>False
True
</code></pre>
https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19387#post-id-19387ThanX, the `SR('ind')` *hack* solved my problem :-)Wed, 18 Jul 2012 11:01:12 +0200https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19387#post-id-19387Comment by kcrisman for <p>Hi as far as I understand the problem is that oo so on are symbolic expressios. If you try to compare them with == sage returns as a new symbolic expression the symbolic equationion:</p>
<pre><code>var('x,y')
print x==y
print type(x==y)
</code></pre>
<p>returns</p>
<pre><code>x == y
<type 'sage.symbolic.expression.Expression'>
</code></pre>
<p>A soultion seems to be to cast the symbolic equation to a boolean:</p>
<pre><code>print bool(x==y)
print bool(x==x)
</code></pre>
<p>which returns</p>
<pre><code>False
True
</code></pre>
https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19388#post-id-19388@Tobias; that doesn't really solve the problem, though it probably is good enough for some of the checking purposes.Wed, 18 Jul 2012 10:36:20 +0200https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19388#post-id-19388Comment by twch for <p>Hi as far as I understand the problem is that oo so on are symbolic expressios. If you try to compare them with == sage returns as a new symbolic expression the symbolic equationion:</p>
<pre><code>var('x,y')
print x==y
print type(x==y)
</code></pre>
<p>returns</p>
<pre><code>x == y
<type 'sage.symbolic.expression.Expression'>
</code></pre>
<p>A soultion seems to be to cast the symbolic equation to a boolean:</p>
<pre><code>print bool(x==y)
print bool(x==x)
</code></pre>
<p>which returns</p>
<pre><code>False
True
</code></pre>
https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19390#post-id-19390I dont know if this is the correct way to fix this problem (I'm also no expert with these symbolic expression) but
print bool(SR('ind')==limit(sin(x),x=oo))
Seems to solve the problem for me.Wed, 18 Jul 2012 10:27:52 +0200https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19390#post-id-19390Comment by kcrisman for <p>Hi as far as I understand the problem is that oo so on are symbolic expressios. If you try to compare them with == sage returns as a new symbolic expression the symbolic equationion:</p>
<pre><code>var('x,y')
print x==y
print type(x==y)
</code></pre>
<p>returns</p>
<pre><code>x == y
<type 'sage.symbolic.expression.Expression'>
</code></pre>
<p>A soultion seems to be to cast the symbolic equation to a boolean:</p>
<pre><code>print bool(x==y)
print bool(x==x)
</code></pre>
<p>which returns</p>
<pre><code>False
True
</code></pre>
https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19389#post-id-19389Hmm, that's true. We allow it as a result from Maxima for e.g. lim(sin(1/x),x=0) or your example, but I guess we just print it out. I've made this http://trac.sagemath.org/sage_trac/ticket/13269, though I'm not sure what exactly could be done.Wed, 18 Jul 2012 10:35:02 +0200https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19389#post-id-19389Comment by Mathemage for <p>Hi as far as I understand the problem is that oo so on are symbolic expressios. If you try to compare them with == sage returns as a new symbolic expression the symbolic equationion:</p>
<pre><code>var('x,y')
print x==y
print type(x==y)
</code></pre>
<p>returns</p>
<pre><code>x == y
<type 'sage.symbolic.expression.Expression'>
</code></pre>
<p>A soultion seems to be to cast the symbolic equation to a boolean:</p>
<pre><code>print bool(x==y)
print bool(x==x)
</code></pre>
<p>which returns</p>
<pre><code>False
True
</code></pre>
https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19392#post-id-19392Unfortunately, `ind` is unknown to sage for some reason:
sage: bool( lim(sin(x), x=oo) == ind)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
NameError: name 'ind' is not defined
Wed, 18 Jul 2012 10:06:14 +0200https://ask.sagemath.org/question/9158/existence-of-a-limit/?comment=19392#post-id-19392