Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to solve the following equation in python with sympy.

13000*1.44**x =1000000

I tried:

x = symbols('x', real=True) 
print(solveset(Eq(130000*1.44**x, 1000000), x))

Now this does gives:

ConditionSet(x, Eq(1.44**x - 100/13, 0), Complexes)

Is this equation not suitable for solveset? Do I need to solve this with fsolve?

Thanks in advance


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
804 views
Welcome To Ask or Share your Answers For Others

1 Answer

The reason you are getting this answer is because there are infinitely many solutions over the complex numbers. Assuming you just want real numbers, try using solveset_real:

from sympy.solvers.solveset import solveset_real

x = symbols('x', real=True)
print(solveset_real(Eq(130000*1.44**x, 1000000), x))

gets you

FiniteSet(2.74240747387354*log(100/13))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...