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.Thu, 29 Sep 2022 23:23:30 +0200Failure to check simple conditions using boolean testshttps://ask.sagemath.org/question/64177/failure-to-check-simple-conditions-using-boolean-tests/ Hi folks,
I am currently designing a microeconomics course using SageMath (9.6) on CoCalc. For one exercise, I would like to use boolean tests to determine whether a production function is exhibiting increasing/constant/decreasing returns to scale.
Doing so, I ran into the following oddities (probably linked to one another), which I was hoping someone could help me with :
a = var("a")
assume(a > 1)
assume(a, "real")
# Check that 'a' is positive
print(a.is_positive()) # First oddity
# Check that sqrt(a) < a
print(bool(a**(1/2) < a)) # Second oddity
> False
> False
Both statements should obviously be true. I am getting the same results when running the code on SageMath 9.1 and SageMath 9.4. Am I missing something or are we dealing with a bug ?
Any help will be greatly appreciated.
----------
Mon, 26 Sep 2022 03:11:43 +0200https://ask.sagemath.org/question/64177/failure-to-check-simple-conditions-using-boolean-tests/Comment by ltmb for <p>Hi folks,</p>
<p>I am currently designing a microeconomics course using SageMath (9.6) on CoCalc. For one exercise, I would like to use boolean tests to determine whether a production function is exhibiting increasing/constant/decreasing returns to scale. </p>
<p>Doing so, I ran into the following oddities (probably linked to one another), which I was hoping someone could help me with :</p>
<pre><code>a = var("a")
assume(a > 1)
assume(a, "real")
# Check that 'a' is positive
print(a.is_positive()) # First oddity
# Check that sqrt(a) < a
print(bool(a**(1/2) < a)) # Second oddity
</code></pre>
<blockquote>
<p>False</p>
<p>False</p>
</blockquote>
<p>Both statements should obviously be true. I am getting the same results when running the code on SageMath 9.1 and SageMath 9.4. Am I missing something or are we dealing with a bug ? </p>
<p>Any help will be greatly appreciated.</p>
<hr>
https://ask.sagemath.org/question/64177/failure-to-check-simple-conditions-using-boolean-tests/?comment=64254#post-id-64254I believe I was able to find the answer to my question in another thread :
[https://ask.sagemath.org/question/8378/assume-seems-not-to-work-for-a-specific-case/?answer=12756#post-id-12756](https://ask.sagemath.org/question/8378/assume-seems-not-to-work-for-a-specific-case/?answer=12756#post-id-12756)
Long story short, Maxima is behind both `assume()` and `solve()`. However, it does not rely on the assumptions made elsewhere in its solver. If I understand correctly, this therefore means that the `a` I describe in my assumption(s) is somewhat distinct from the one I initiated and called in the booleans, which is quite interesting.Thu, 29 Sep 2022 23:23:30 +0200https://ask.sagemath.org/question/64177/failure-to-check-simple-conditions-using-boolean-tests/?comment=64254#post-id-64254