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.Wed, 27 Nov 2019 12:37:51 +0100Equation solver with assumehttps://ask.sagemath.org/question/48899/equation-solver-with-assume/Odd behaviour: the following gives a solution:
x, c, k = var('x, c, k')
assume(k > 0)
assume(k, "integer")
solve(x**k == (k/c), x)
but the following does not:
x, c, k = var('x, c, k')
assume(k > 0)
assume(k, "real")
solve(x**k == (k/c), x)
I should be able to remove the assume(k, "datatype") completely, right?Tue, 26 Nov 2019 21:10:48 +0100https://ask.sagemath.org/question/48899/equation-solver-with-assume/Answer by Emmanuel Charpentier for <p>Odd behaviour: the following gives a solution: </p>
<pre><code>x, c, k = var('x, c, k')
assume(k > 0)
assume(k, "integer")
solve(x**k == (k/c), x)
</code></pre>
<p>but the following does not:</p>
<pre><code>x, c, k = var('x, c, k')
assume(k > 0)
assume(k, "real")
solve(x**k == (k/c), x)
</code></pre>
<p>I should be able to remove the assume(k, "datatype") completely, right?</p>
https://ask.sagemath.org/question/48899/equation-solver-with-assume/?answer=48905#post-id-48905since you `assume(k>0)`, which is meaningless if `k` is not real, you implicitly assume that it is real:
sage: x, c, k = var('x, c, k')
....: assume(k > 0)
....:
sage: k.is_real()
True
the following failure of Maxima's solver is unrelated to this assumption. This weakness of Maxima's solver has been known for a long time.
This equation can nevertheless be solved with a little help from the user:
sage: (x**k==k/c).log().log_expand().solve(x)
[x == e^(-log(c)/k + log(k)/k)]
And further tidied:
sage: (x**k==k/c).log().log_expand().solve(x)[0].canonicalize_radical()
x == k^(1/k)/c^(1/k)Wed, 27 Nov 2019 12:37:51 +0100https://ask.sagemath.org/question/48899/equation-solver-with-assume/?answer=48905#post-id-48905