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.Wed, 31 Jul 2013 13:31:28 -0500Testing inequalities in sagehttp://ask.sagemath.org/question/10388/testing-inequalities-in-sage/I wanted to show if:
$$ |a+b| \leq |a| + |b|$$
So I wrote this in sage:
var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
The result is False.
I had expected the result to be True. What is the correct way to test this in sage?
Thank you in advance for any help provided.Fri, 26 Jul 2013 01:22:04 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/Comment by jack77 for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17230#post-id-17230@eviatar-bach returning False in case can't be determined whether a relation holds seems to me unwise ; This should be changed to a tristate-answer, whatever the third state is Sat, 27 Jul 2013 13:49:32 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17230#post-id-17230Comment by rickhg12hs for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17237#post-id-17237Interesting, $bool(abs(a) >= a)$ is $True$, but $bool(abs(a+b) >= (a+b))$ is $False$. Weird.Fri, 26 Jul 2013 09:43:32 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17237#post-id-17237Comment by ensaba for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17236#post-id-17236Also, assume(a<0,b>0) results in false too: http://pastebin.com/7Gg5xMA8Fri, 26 Jul 2013 10:00:46 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17236#post-id-17236Comment by Eviatar Bach for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17235#post-id-17235If it can't be determined whether a relation holds, `False` will be returned.Fri, 26 Jul 2013 14:54:52 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17235#post-id-17235Comment by rickhg12hs for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17234#post-id-17234This is disturbing: $$assume(a, 'real')$$ $$assume(b, 'real')$$ $$bool(sqrt((a+b)^2) == sqrt(a^2) + sqrt(b^2))$$ is $$True$$ ????Fri, 26 Jul 2013 15:59:43 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17234#post-id-17234Comment by ensaba for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17224#post-id-17224Since there is enough information to determine the truth value of the triangle inequality, should I file a big report?Sun, 28 Jul 2013 16:13:39 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17224#post-id-17224Comment by Eviatar Bach for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17222#post-id-17222jack77, I agree. This is something I've thought about changing. You can see an old discussion at https://groups.google.com/forum/#!topic/sage-devel/vNxnHSeRBW4. I think reopening the issue on sage-devel is a good idea.Sun, 28 Jul 2013 19:58:06 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17222#post-id-17222Comment by rickhg12hs for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17223#post-id-17223Perhaps this will get more attention if you post it to the Google Group sage-support. If you do, put a link to this AskSage post so they can read the discussion. https://groups.google.com/forum/m/#!forum/sage-supportSun, 28 Jul 2013 17:22:13 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17223#post-id-17223Answer by tmonteil for <p>I wanted to show if:
$$ |a+b| \leq |a| + |b|$$</p>
<p>So I wrote this in sage:</p>
<pre><code>var('a','b')
eqn1=abs(a+b)
eqn2=abs(a)+abs(b)
bool(eqn1<=eqn2)
</code></pre>
<p>The result is False.</p>
<p>I had expected the result to be True. What is the correct way to test this in sage?</p>
<p>Thank you in advance for any help provided.</p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?answer=15289#post-id-15289As explained in [this answer](http://ask.sagemath.org/question/2641/compare-symbolic-expressions?answer=3636#3636), there is currently no way for Sage to say "I do not know the result", hence the answer 'False', which means 'False or Unknown'.
**EDIT** See [trac ticket 17700](https://trac.sagemath.org/ticket/17700)Wed, 31 Jul 2013 03:43:47 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?answer=15289#post-id-15289Comment by jack77 for <p>As explained in <a href="http://ask.sagemath.org/question/2641/compare-symbolic-expressions?answer=3636#3636">this answer</a>, there is currently no way for Sage to say "I do not know the result", hence the answer 'False', which means 'False or Unknown'.</p>
<p><strong>EDIT</strong> See <a href="https://trac.sagemath.org/ticket/17700">trac ticket 17700</a></p>
http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17209#post-id-17209but it should! Wed, 31 Jul 2013 13:31:28 -0500http://ask.sagemath.org/question/10388/testing-inequalities-in-sage/?comment=17209#post-id-17209