本文整理汇总了Python中sympy.separatevars函数的典型用法代码示例。如果您正苦于以下问题:Python separatevars函数的具体用法?Python separatevars怎么用?Python separatevars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了separatevars函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_separatevars_advanced_factor
def test_separatevars_advanced_factor():
x,y,z = symbols('x,y,z')
assert separatevars(1 + log(x)*log(y) + log(x) + log(y)) == (log(x) + 1)*(log(y) + 1)
assert separatevars(1 + x - log(z) - x*log(z) - exp(y)*log(z) - x*exp(y)*log(z) + x*exp(y) + exp(y)) == \
-((x + 1)*(log(z) - 1)*(exp(y) + 1))
x, y = symbols('x,y', positive=True)
assert separatevars(1 + log(x**log(y)) + log(x*y)) == (log(x) + 1)*(log(y) + 1)
示例2: test_separatevars_advanced_factor
def test_separatevars_advanced_factor():
# If factor() is ever improved to factor non-symbolic expressions, this
# should XPASS
assert separatevars(1 + log(x)*log(y) + log(x) + log(y)) == (log(x) + 1)*(log(y) + 1)
assert separatevars(1 + x - log(z) - x*log(z) - exp(y)*log(z) - \
x*exp(y)*log(z) + x*exp(y) + exp(y)) == \
(1 + x)*(1 - log(z))*(1 + exp(y))
x, y = symbols('xy', positive=True)
assert separatevars(1 + log(x**log(y)) + log(x*y)) == (log(x) + 1)*(log(y) + 1)
示例3: test_separatevars
def test_separatevars():
x,y,z,n = symbols('xyzn')
assert separatevars(2*n*x*z+2*x*y*z) == 2*x*z*(n+y)
assert separatevars(x*z+x*y*z) == x*z*(1+y)
assert separatevars(pi*x*z+pi*x*y*z) == pi*x*z*(1+y)
assert separatevars(x*y**2*sin(x) + x*sin(x)*sin(y)) == x*(sin(y) + y**2)*sin(x)
assert separatevars(x*exp(x+y)+x*exp(x)) == x*(1 + exp(y))*exp(x)
assert separatevars((x*(y+1))**z) == x**z*(1 + y)**z
assert separatevars(1+x+y+x*y) == (x+1)*(y+1)
assert separatevars(y / pi * exp(-(z - x) / cos(n))) == y * exp((x - z) / cos(n)) / pi
# 1759
p=Symbol('p',positive=True)
assert separatevars(sqrt(p**2 + x*p**2)) == p*sqrt(1 + x)
assert separatevars(sqrt(y*(p**2 + x*p**2))) == p*sqrt(y)*sqrt(1 + x)
示例4: test_separatevars
def test_separatevars():
x,y,z,n = symbols('xyzn')
assert separatevars(2*n*x*z+2*x*y*z) == 2*x*z*(n+y)
assert separatevars(x*z+x*y*z) == x*z*(1+y)
assert separatevars(pi*x*z+pi*x*y*z) == pi*x*z*(1+y)
assert separatevars(x*y**2*sin(x) + x*sin(x)*sin(y)) == x*(sin(y) + y**2)*sin(x)
assert separatevars(x*exp(x+y)+x*exp(x)) == x*(1 + exp(y))*exp(x)
assert separatevars((x*(y+1))**z) == x**z*(1 + y)**z
assert separatevars(1+x+y+x*y) == (x+1)*(y+1)
示例5: test_separatevars
def test_separatevars():
x,y,z,n = symbols('x,y,z,n')
assert separatevars(2*n*x*z+2*x*y*z) == 2*x*z*(n+y)
assert separatevars(x*z+x*y*z) == x*z*(1+y)
assert separatevars(pi*x*z+pi*x*y*z) == pi*x*z*(1+y)
assert separatevars(x*y**2*sin(x) + x*sin(x)*sin(y)) == x*(sin(y) + y**2)*sin(x)
assert separatevars(x*exp(x+y)+x*exp(x)) == x*(1 + exp(y))*exp(x)
assert separatevars((x*(y+1))**z).is_Pow # != x**z*(1 + y)**z
assert separatevars(1+x+y+x*y) == (x+1)*(y+1)
assert separatevars(y / pi * exp(-(z - x) / cos(n))) == y * exp((x - z) / cos(n)) / pi
# 1759
p=Symbol('p',positive=True)
assert separatevars(sqrt(p**2 + x*p**2)) == p*sqrt(1 + x)
assert separatevars(sqrt(y*(p**2 + x*p**2))) == p*sqrt(y*(1 + x))
assert separatevars(sqrt(y*(p**2 + x*p**2)), force=True) == p*sqrt(y)*sqrt(1 + x)
# 1766
assert separatevars(sqrt(x*y)).is_Pow
assert separatevars(sqrt(x*y), force=True) == sqrt(x)*sqrt(y)
# 1858
# any type sequence for symbols is fine
assert separatevars(((2*x+2)*y), dict=True, symbols=()) == {'coeff': 2, x: x + 1, y: y}
# separable
assert separatevars(((2*x+2)*y), dict=True, symbols=[]) == {'coeff': 2, x: x + 1, y: y}
assert separatevars(((2*x+2)*y), dict=True) == {'coeff': 2, x: x + 1, y: y}
assert separatevars(((2*x+2)*y), dict=True, symbols=None) == {'coeff': 2*y*(x + 1)}
# not separable
assert separatevars(2*x+y, dict=True, symbols=()) is None
assert separatevars(2*x+y, dict=True) is None
assert separatevars(2*x+y, dict=True, symbols=None) == {'coeff': 2*x + y}