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.Sat, 20 May 2017 19:33:09 +0200Solving returns xhttps://ask.sagemath.org/question/37640/solving-returns-x/> sage: solve(4.94 * 1.062^x == 15, x)
> [531^x == 750/247*500^x]
There are other questions that appear to have the same problem, but honestly I don't understand the answers, and this is a much simpler equation. Why doesn't Sage solve it? I can do it in Maple and by hand in vanilla Python with the math module.Sat, 20 May 2017 09:48:15 +0200https://ask.sagemath.org/question/37640/solving-returns-x/Comment by mforets for <blockquote>
<p>sage: solve(4.94 * 1.062^x == 15, x)</p>
<p>[531^x == 750/247*500^x]</p>
</blockquote>
<p>There are other questions that appear to have the same problem, but honestly I don't understand the answers, and this is a much simpler equation. Why doesn't Sage solve it? I can do it in Maple and by hand in vanilla Python with the math module.</p>
https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37641#post-id-37641+1 because I have the same question too; notice that: `var('a b c'); solve(c*a^x == b, x)` does produce the good `[x == log(b/c)/log(a)]`, however a simple formula such as `solve((3/2)^x == 6, x, explicit_solutions=True)` produces the empty set, `[]`, instead of `log(6)/log(3/2)`.Sat, 20 May 2017 11:39:58 +0200https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37641#post-id-37641Answer by tmonteil for <blockquote>
<p>sage: solve(4.94 * 1.062^x == 15, x)</p>
<p>[531^x == 750/247*500^x]</p>
</blockquote>
<p>There are other questions that appear to have the same problem, but honestly I don't understand the answers, and this is a much simpler equation. Why doesn't Sage solve it? I can do it in Maple and by hand in vanilla Python with the math module.</p>
https://ask.sagemath.org/question/37640/solving-returns-x/?answer=37647#post-id-37647`sympy` is able to solve this:
sage: eq = 4.94 * 1.062^x - 15
sage: import sympy
sage: sympy.solve(eq._sympy_())
[18.4640471949033]
This kind of workaroud seems pretty frequent, perhaps should Sage rely more on `sympy` when possible.Sat, 20 May 2017 16:58:41 +0200https://ask.sagemath.org/question/37640/solving-returns-x/?answer=37647#post-id-37647Comment by mforets for <p><code>sympy</code> is able to solve this:</p>
<pre><code>sage: eq = 4.94 * 1.062^x - 15
sage: import sympy
sage: sympy.solve(eq._sympy_())
[18.4640471949033]
</code></pre>
<p>This kind of workaroud seems pretty frequent, perhaps should Sage rely more on <code>sympy</code> when possible.</p>
https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37649#post-id-37649see also [#22322](https://trac.sagemath.org/ticket/22322). on a separate note, since `solve` is meant to work with symbolics, perhaps one would expect `[(-log(750) + log(247))/(-log(531) + log(500))]` in a use case like `solve(eq, algorithm='sympy')`.. or to raise an error.Sat, 20 May 2017 18:26:04 +0200https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37649#post-id-37649Comment by tmonteil for <p><code>sympy</code> is able to solve this:</p>
<pre><code>sage: eq = 4.94 * 1.062^x - 15
sage: import sympy
sage: sympy.solve(eq._sympy_())
[18.4640471949033]
</code></pre>
<p>This kind of workaroud seems pretty frequent, perhaps should Sage rely more on <code>sympy</code> when possible.</p>
https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37650#post-id-37650Well, 4.94 should be considered as a float, not a decimal, so i really prefer a numerical answer in this case. This is another story for `(3/2)^x - 6` where numbers are integer, and in this case, `sympy` gives a symbolic answer:
sage: eq = (3/2)^x - 6
sage: sage: import sympy
sage: sympy.solve(eq._sympy_())
[-log(6)/(-log(3) + log(2))]
The fact that Sage's symbolics mixes exact and inexact representations is imho a bad choice:
sage: pi + 0.1
pi + 0.100000000000000Sat, 20 May 2017 18:53:46 +0200https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37650#post-id-37650Comment by mforets for <p><code>sympy</code> is able to solve this:</p>
<pre><code>sage: eq = 4.94 * 1.062^x - 15
sage: import sympy
sage: sympy.solve(eq._sympy_())
[18.4640471949033]
</code></pre>
<p>This kind of workaroud seems pretty frequent, perhaps should Sage rely more on <code>sympy</code> when possible.</p>
https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37651#post-id-37651+1 . i thought about that because of the current behaviour with inexact coefficients:
sage: solve(1.5*x-1, x)
[x == (2/3)]
sage: solve(1.77775*x^2-1.987*x-24.5, x)
[x == -2/7111*sqrt(178167669) + 3974/7111, x == 2/7111*sqrt(178167669) + 3974/7111]Sat, 20 May 2017 19:33:09 +0200https://ask.sagemath.org/question/37640/solving-returns-x/?comment=37651#post-id-37651