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.Tue, 04 Sep 2012 17:31:01 +0200Similar limits give very different behaviorhttps://ask.sagemath.org/question/9294/similar-limits-give-very-different-behavior/The following code produces the expected right answer:
sage: var('x,h')
sage: f(x) = sin(x^2)
sage: lim((f(x+h)-f(x))/h, h=0)
The answer, of course, is 2*x*cos(x^2). However, the following code fails to complete:
sage: lim((f(pi+h)-f(pi))/h, h=0)
Sage just thinks and thinks and does not come up with an answer. This happens on two different versions I have access to, 5.2 and 5.0. What is happening?Tue, 04 Sep 2012 15:55:43 +0200https://ask.sagemath.org/question/9294/similar-limits-give-very-different-behavior/Answer by achrzesz for <p>The following code produces the expected right answer:</p>
<pre><code>sage: var('x,h')
sage: f(x) = sin(x^2)
sage: lim((f(x+h)-f(x))/h, h=0)
</code></pre>
<p>The answer, of course, is 2<em>x</em>cos(x^2). However, the following code fails to complete:</p>
<pre><code>sage: lim((f(pi+h)-f(pi))/h, h=0)
</code></pre>
<p>Sage just thinks and thinks and does not come up with an answer. This happens on two different versions I have access to, 5.2 and 5.0. What is happening?</p>
https://ask.sagemath.org/question/9294/similar-limits-give-very-different-behavior/?answer=14000#post-id-14000 sage: from sympy import Symbol, limit
sage: h=Symbol('h')
sage: limit((sin((pi+h)^2)-sin(pi^2))/h,h,0)
2*pi*cos(pi**2)Tue, 04 Sep 2012 17:31:01 +0200https://ask.sagemath.org/question/9294/similar-limits-give-very-different-behavior/?answer=14000#post-id-14000Answer by kcrisman for <p>The following code produces the expected right answer:</p>
<pre><code>sage: var('x,h')
sage: f(x) = sin(x^2)
sage: lim((f(x+h)-f(x))/h, h=0)
</code></pre>
<p>The answer, of course, is 2<em>x</em>cos(x^2). However, the following code fails to complete:</p>
<pre><code>sage: lim((f(pi+h)-f(pi))/h, h=0)
</code></pre>
<p>Sage just thinks and thinks and does not come up with an answer. This happens on two different versions I have access to, 5.2 and 5.0. What is happening?</p>
https://ask.sagemath.org/question/9294/similar-limits-give-very-different-behavior/?answer=13999#post-id-13999For what it's worth, Maxima is the one causing the hang.
(%i1) limit( (sin((h + x)^2) - sin(x^2))/h, h, 0);
2
(%o1) 2 x cos(x )
(%i3) limit( (sin((%pi+h)^2)-sin(%pi^2))/h,h,0);
But I can't diagnose it any further than that. Replacing `%pi` with `2` or something does the same (well, unless `x=0`).Tue, 04 Sep 2012 16:59:21 +0200https://ask.sagemath.org/question/9294/similar-limits-give-very-different-behavior/?answer=13999#post-id-13999