Ask Your Question
1

How to solve nonlinear equation having floating values?

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

recoder gravatar image

updated 2020-06-22 21:04:09 +0200

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-06-23 01:37:13 +0200

Juanjo gravatar image

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

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 71 times

Last updated: Jun 23 '20