First time here? Check out the FAQ!

Ask Your Question
2

Solving returns x

asked 8 years ago

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.

Preview: (hide)

Comments

+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 ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

tmonteil gravatar image

updated 8 years ago

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.

Preview: (hide)
link

Comments

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 ( 8 years ago )

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 ( 8 years ago )

+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 ( 8 years ago )

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

Stats

Asked: 8 years ago

Seen: 874 times

Last updated: May 20 '17