简体   繁体   English

为什么SymPy不了解日志产品

[英]Why doesn't SymPy understand log product

Why does the following return False ? 为什么以下返回False

import sympy as sp

x = sp.Symbol('x')
y = sp.Symbol('y')

sp.log(x*y) == sp.log(x) + sp.log(y)

There is an underlying assumption for this rule that your variables are positive. 此规则有一个基本假设,即您的变量为正。 SymPy won't perform this simplification (correctly) if this is not indicated. 如果未指示,SymPy将不会(正确)执行此简化操作。

To make this assumption clear to SymPy, 为了使这个假设对SymPy明确,

x = sp.Symbol('x', positive=True)
y = sp.Symbol('y', positive=True)

Now read this Q/A on equality in SymPy to see that you ought to be simplify ing in your comparison. 现在,请阅读此有关SymPy中的相等性的Q / A,以了解比较中应该simplify

>>> sp.simplify(sp.log(x*y) - (sp.log(x) + sp.log(y))) == 0
True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM