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.

edit retag close merge delete

+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).

( 2017-05-20 11:39:58 +0200 )edit

Sort by » oldest newest most voted

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.

more

see also #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.

( 2017-05-20 18:26:04 +0200 )edit

Well, 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.100000000000000

( 2017-05-20 18:53:46 +0200 )edit

+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]

( 2017-05-20 19:33:09 +0200 )edit