Ask Your Question

# How to solve nonlinear equation having floating values?

I'm trying to solve equation which simplifies to this form:

a^x = b

eg. solve([(123)^y==(234234)],y)

which returns [y == log(234234)/log(123)]

but solve([(123.123)^y==(234234.123)],y) (having floating point constants) returns

[123123^y == 234234123*1000^(y - 1)]


How do I get it to return the answer in terms of log.

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted You can convert the floating point constants to rationals and use Sympy:

sage: y = var("y")
sage: a = 123.123
sage: b = 234234.123
sage: solve(QQ(a)^y==QQ(b), y, algorithm="sympy")
[y == (log(234234123) - 3*log(10))/(log(123123) - 3*log(10))]


It seems that Sympy can also provide a numerical solution if its domain is restricted:

sage: solve(a^y==b, y, algorithm="sympy", domain="real")
[y == 2.56879371128374]

more

## Your Answer

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

Add Answer

## Stats

Asked: 2020-06-22 04:02:26 +0200

Seen: 66 times

Last updated: Jun 23 '20