2016-04-07 19 views
2

Aşağıdaki örnekte de gördüğünüz gibi, SymPy, taban tam sayı değilse logaritmaları değerlendirir.Taban olarak bir kayan noktalı logaritmaları değerlendirmiyor

IPython console for SymPy 1.0 (Python 2.7.10-64-bit) (ground types: python) 

These commands were executed: 
>>> from __future__ import division 
>>> from sympy import * 
>>> x, y, z, t = symbols('x y z t') 
>>> k, m, n = symbols('k m n', integer=True) 
>>> f, g, h = symbols('f g h', cls=Function) 
>>> init_printing() 

In [1]: log(4, 3) 
Out[1]: 
log(4) 
────── 
log(3) 


In [2]: log(4, 1/2) 
Out[2]: -1.44269504088896⋅log(4) <<< What I get 

Benim istediğim:

log(4) 
──────── 
log(1/2) 

Bunu nasıl başarabiliriz?

cevap

3

Bir SymPy Rational değil, bir float gerekir:

log(4, Rational(1, 2)) 
İlgili konular