Ask Your Question

Solving returns x

asked 2017-05-20 09:48:15 +0200

Ross1856 gravatar image

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 flag offensive 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).

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

1 Answer

Sort by ┬╗ oldest newest most voted

answered 2017-05-20 16:58:41 +0200

tmonteil gravatar image

updated 2017-05-20 17:02:50 +0200

sympy is able to solve this:

sage: eq = 4.94 * 1.062^x - 15
sage: import sympy
sage: sympy.solve(eq._sympy_())

This kind of workaroud seems pretty frequent, perhaps should Sage rely more on sympy when possible.

edit flag offensive delete link 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.

mforets gravatar imagemforets ( 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
tmonteil gravatar imagetmonteil ( 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]
mforets gravatar imagemforets ( 2017-05-20 19:33:09 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-05-20 09:48:15 +0200

Seen: 532 times

Last updated: May 20 '17