ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 31 Jul 2013 13:31:00 -0500Compare symbolic expressionshttps://ask.sagemath.org/question/10185/compare-symbolic-expressions/Following is the problem I am trying to solve:
I have multiple complex symbolic expressions f1(x1,x2,...,xn),f2(x1,x2,...,xn),...,fn(x1,x2,...,xn) which are functions of symbolic variables x1,x2,...,xn. I also have some constraints for the symbolic variables, e.g. 0 is smaller than x1, 2 is smaller than x2, x2 is integer, etc. How can I find out for two selected symbolic expressions which one is larger for given constraints?
I've tried something like:
<code> assume(0<x1,2<x2)
assume(x2,'integer')
bool(f1>f2) </code>
It seems to work for more simple symbolic expressions. For more complex symbolic expressions (where a solution definitely exists) SAGE seems not to be able to compare the expressions. Is there a way to overcome this?
Mon, 03 Jun 2013 04:51:40 -0500https://ask.sagemath.org/question/10185/compare-symbolic-expressions/Answer by tmonteil for <p>Following is the problem I am trying to solve:</p>
<p>I have multiple complex symbolic expressions f1(x1,x2,...,xn),f2(x1,x2,...,xn),...,fn(x1,x2,...,xn) which are functions of symbolic variables x1,x2,...,xn. I also have some constraints for the symbolic variables, e.g. 0 is smaller than x1, 2 is smaller than x2, x2 is integer, etc. How can I find out for two selected symbolic expressions which one is larger for given constraints?</p>
<p>I've tried something like:</p>
<p><code> assume(0<x1,2<x2)< p="">
</code></p><p><code>assume(x2,'integer')</code></p><code>
</code><p><code>bool(f1>f2) </code></p>
<p>It seems to work for more simple symbolic expressions. For more complex symbolic expressions (where a solution definitely exists) SAGE seems not to be able to compare the expressions. Is there a way to overcome this?</p>
https://ask.sagemath.org/question/10185/compare-symbolic-expressions/?answer=15017#post-id-15017There is no general algorithm able to decide whether a symbolically defined function is positive even in a single variable, and using only `log2, exp(x), pi, sin(x), x, +, - , *, o`, see for example [this paper](http://www.jstor.org/stable/2271358).
Note that, when Sage is able to prove `(f1>f2)`, it outputs `True`, otherwise, it will output `False`. This means that when Sage outputs "`False`", it means "`False or Unknown`".
Now, if you have a concrete example, someone may help you to decide in that particular case.
Mon, 03 Jun 2013 05:04:10 -0500https://ask.sagemath.org/question/10185/compare-symbolic-expressions/?answer=15017#post-id-15017Comment by jack77 for <p>There is no general algorithm able to decide whether a symbolically defined function is positive even in a single variable, and using only <code>log2, exp(x), pi, sin(x), x, +, - , *, o</code>, see for example <a href="http://www.jstor.org/stable/2271358">this paper</a>. </p>
<p>Note that, when Sage is able to prove <code>(f1>f2)</code>, it outputs <code>True</code>, otherwise, it will output <code>False</code>. This means that when Sage outputs "<code>False</code>", it means "<code>False or Unknown</code>".</p>
<p>Now, if you have a concrete example, someone may help you to decide in that particular case.</p>
https://ask.sagemath.org/question/10185/compare-symbolic-expressions/?comment=17210#post-id-17210I'm sorry, but this design is a failure - to return False when the result is Unknown. This should definitely be fixed.Wed, 31 Jul 2013 13:31:00 -0500https://ask.sagemath.org/question/10185/compare-symbolic-expressions/?comment=17210#post-id-17210