matthijsW
matthijsW

Reputation: 387

Solve non linear equation with one variable Python

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

Upvotes: 2

Views: 409

Answers (1)

Alan Liddell
Alan Liddell

Reputation: 179

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))

Upvotes: 3

Related Questions