ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 13 Dec 2014 03:25:42 -0600Can sage help determine if $|f(x) - L| < \epsilon$ is true?http://ask.sagemath.org/question/25218/can-sage-help-determine-if-fx-l-epsilon-is-true/Here's what I want to check:
Given $f(x)$, $\epsilon>0$, $L\in \mathbb{R}$ and $N(\epsilon)$, is
$$n>N(\epsilon) \Rightarrow |f(n)-L | < \epsilon$$
true?
I thought I could accomplish this using symbolic expressions and `assume()`. This is what I've tried:
forget()
var('ep, n')
f(x)=1/(n+7)
N = (1/ep)-7
assume(ep>0)
assume(n>N)
show(abs(f(n)-0)<ep)
bool(abs(f(n)-0)<ep)
But the result of is `False`. What is the proper way to do this in Sage?
Thu, 11 Dec 2014 07:48:54 -0600http://ask.sagemath.org/question/25218/can-sage-help-determine-if-fx-l-epsilon-is-true/Comment by slelievre for <p>Here's what I want to check:</p>
<p>Given $f(x)$, $\epsilon>0$, $L\in \mathbb{R}$ and $N(\epsilon)$, is
$$n>N(\epsilon) \Rightarrow |f(n)-L | < \epsilon$$
true?</p>
<p>I thought I could accomplish this using symbolic expressions and <code>assume()</code>. This is what I've tried:</p>
<pre><code>forget()
var('ep, n')
f(x)=1/(n+7)
N = (1/ep)-7
assume(ep>0)
assume(n>N)
show(abs(f(n)-0)<ep)
bool(abs(f(n)-0)<ep)
</code></pre>
<p>But the result of is <code>False</code>. What is the proper way to do this in Sage? </p>
http://ask.sagemath.org/question/25218/can-sage-help-determine-if-fx-l-epsilon-is-true/?comment=25246#post-id-25246Edited: "< epsilon" instead of "< 3" in the displayed equation. Also, you want f(x) = 1 / (x + 7), not 1 / (n +7).Sat, 13 Dec 2014 02:49:59 -0600http://ask.sagemath.org/question/25218/can-sage-help-determine-if-fx-l-epsilon-is-true/?comment=25246#post-id-25246Answer by slelievre for <p>Here's what I want to check:</p>
<p>Given $f(x)$, $\epsilon>0$, $L\in \mathbb{R}$ and $N(\epsilon)$, is
$$n>N(\epsilon) \Rightarrow |f(n)-L | < \epsilon$$
true?</p>
<p>I thought I could accomplish this using symbolic expressions and <code>assume()</code>. This is what I've tried:</p>
<pre><code>forget()
var('ep, n')
f(x)=1/(n+7)
N = (1/ep)-7
assume(ep>0)
assume(n>N)
show(abs(f(n)-0)<ep)
bool(abs(f(n)-0)<ep)
</code></pre>
<p>But the result of is <code>False</code>. What is the proper way to do this in Sage? </p>
http://ask.sagemath.org/question/25218/can-sage-help-determine-if-fx-l-epsilon-is-true/?answer=25247#post-id-25247Sage has some weaknesses when it comes to dealing with assumptions.
The best I can think of is the following:
sage: var('n eps')
sage: f(n) = 1 /(n + 7)
sage: assume('eps > 0')
sage: N = (1 / eps) - 7
sage: assume(n > N)
sage: sol = solve([abs(f(n)) < eps],n)
sage: sol
[[n < -7, -eps*n - 7*eps - 1 > 0],
[n == -7, -1 > 0],
[-7 < n, eps*n + 7*eps - 1 > 0]]
From there you can continue manipulating each of the "solutions".
Let's look at the second one. It's a bit disappointing that `solve` did not suppress it, given that `-1 > 0` has no solution. But if you solve it again, you get an empty list, indicating "no solution" (beware that it might also mean "no solution found").
sage: a, b, c = sol
sage: b
[n == -7, -1 > 0]
sage: solve(b,n)
[]
For `a`, it's also disappointing that it doesn't get suppressed, since it's easy to derive that `n > -7`.
For `c`, it's also disappointing that it doesn't get simplified, since the second condition follows from the first, and could therefore be suppressed.Sat, 13 Dec 2014 03:25:42 -0600http://ask.sagemath.org/question/25218/can-sage-help-determine-if-fx-l-epsilon-is-true/?answer=25247#post-id-25247