集合

基本集合

class sympy.sets.sets.Set(*args)[源代码][源代码]

任何集合类型的基类。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

property boundary

一个集合的边界或前沿。

示例

>>> from sympy import Interval
>>> Interval(0, 1).boundary
{0, 1}
>>> Interval(0, 1, True, False).boundary
{0, 1}
property closure

返回集合闭包的属性方法。闭包定义为集合本身及其边界的并集。

示例

>>> from sympy import S, Interval
>>> S.Reals.closure
Reals
>>> Interval(0, 1).closure
Interval(0, 1)
complement(universe)[源代码][源代码]

相对于给定全集的 ‘self’ 的补集。

示例

>>> from sympy import Interval, S
>>> Interval(0, 1).complement(S.Reals)
Union(Interval.open(-oo, 0), Interval.open(1, oo))
>>> Interval(0, 1).complement(S.UniversalSet)
Complement(UniversalSet, Interval(0, 1))
contains(other)[源代码][源代码]

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

示例

>>> from sympy import Interval, S
>>> from sympy.abc import x
>>> Interval(0, 1).contains(0.5)
True

作为一种快捷方式,可以使用 in 运算符,但这将引发错误,除非获得肯定的 true 或 false。

>>> Interval(0, 1).contains(x)
(0 <= x) & (x <= 1)
>>> x in Interval(0, 1)
Traceback (most recent call last):
...
TypeError: did not evaluate to a bool: None

‘in’ 的结果是一个布尔值,而不是一个 SymPy 值

>>> 1 in Interval(0, 2)
True
>>> _ is S.true
False
property inf

self 的下确界。

示例

>>> from sympy import Interval, Union
>>> Interval(0, 1).inf
0
>>> Union(Interval(0, 1), Interval(2, 3)).inf
0
property interior

返回集合内部的属性方法。集合 S 的内部由 S 中所有不属于 S 边界点的点组成。

示例

>>> from sympy import Interval
>>> Interval(0, 1).interior
Interval.open(0, 1)
>>> Interval(0, 1).boundary.interior
EmptySet
intersect(other)[源代码][源代码]

返回 ‘self’ 和 ‘other’ 的交集。

示例

>>> from sympy import Interval
>>> Interval(1, 3).intersect(Interval(1, 2))
Interval(1, 2)
>>> from sympy import imageset, Lambda, symbols, S
>>> n, m = symbols('n m')
>>> a = imageset(Lambda(n, 2*n), S.Integers)
>>> a.intersect(imageset(Lambda(m, 2*m + 1), S.Integers))
EmptySet
intersection(other)[源代码][源代码]

别名 intersect()

property is_closed

一个检查集合是否闭合的属性方法。

示例

>>> from sympy import Interval
>>> Interval(0, 1).is_closed
True
is_disjoint(other)[源代码][源代码]

如果 selfother 不相交,则返回 True。

参考文献

示例

>>> from sympy import Interval
>>> Interval(0, 2).is_disjoint(Interval(1, 2))
False
>>> Interval(0, 2).is_disjoint(Interval(3, 4))
True
property is_open

检查集合是否为开集的属性方法。

示例

>>> from sympy import S
>>> S.Reals.is_open
True
>>> S.Rationals.is_open
False
is_proper_subset(other)[源代码][源代码]

如果 selfother 的真子集,则返回 True。

示例

>>> from sympy import Interval
>>> Interval(0, 0.5).is_proper_subset(Interval(0, 1))
True
>>> Interval(0, 1).is_proper_subset(Interval(0, 1))
False
is_proper_superset(other)[源代码][源代码]

如果 selfother 的真超集,则返回 True。

示例

>>> from sympy import Interval
>>> Interval(0, 1).is_proper_superset(Interval(0, 0.5))
True
>>> Interval(0, 1).is_proper_superset(Interval(0, 1))
False
is_subset(other)[源代码][源代码]

如果 selfother 的子集,则返回 True。

示例

>>> from sympy import Interval
>>> Interval(0, 0.5).is_subset(Interval(0, 1))
True
>>> Interval(0, 1).is_subset(Interval(0, 1, left_open=True))
False
is_superset(other)[源代码][源代码]

如果 selfother 的超集,则返回 True。

示例

>>> from sympy import Interval
>>> Interval(0, 0.5).is_superset(Interval(0, 1))
False
>>> Interval(0, 1).is_superset(Interval(0, 1, left_open=True))
True
isdisjoint(other)[源代码][源代码]

别名 is_disjoint()

issubset(other)[源代码][源代码]

别名为 is_subset()

issuperset(other)[源代码][源代码]

别名 is_superset()

property kind

集合的种类

示例

>>> from sympy import Interval, Matrix, FiniteSet, EmptySet, ProductSet, PowerSet
>>> FiniteSet(Matrix([1, 2])).kind
SetKind(MatrixKind(NumberKind))
>>> Interval(1, 2).kind
SetKind(NumberKind)
>>> EmptySet.kind
SetKind()

一个 sympy.sets.powerset.PowerSet 是一个集合的集合:

>>> PowerSet({1, 2, 3}).kind
SetKind(SetKind(NumberKind))

一个 ProductSet 表示其他集合元素元组的集合。它的类型是 sympy.core.containers.TupleKind,由这些集合元素的类型参数化:

>>> p = ProductSet(FiniteSet(1, 2), FiniteSet(3, 4))
>>> list(p)
[(1, 3), (2, 3), (1, 4), (2, 4)]
>>> p.kind
SetKind(TupleKind(NumberKind, NumberKind))

当集合中的所有元素不具有相同种类时,种类将被返回为 SetKind(UndefinedKind)

>>> FiniteSet(0, Matrix([1, 2])).kind
SetKind(UndefinedKind)

集合元素的类型由 SetKindelement_kind 属性给出:

>>> Interval(1, 2).kind.element_kind
NumberKind
property measure

self 的 (勒贝格) 测度

示例

>>> from sympy import Interval, Union
>>> Interval(0, 1).measure
1
>>> Union(Interval(0, 1), Interval(2, 3)).measure
2
powerset()[源代码][源代码]

找到 self 的幂集。

参考文献

示例

>>> from sympy import EmptySet, FiniteSet, Interval

空集的幂集:

>>> A = EmptySet
>>> A.powerset()
{EmptySet}

一个有限集的幂集:

>>> A = FiniteSet(1, 2)
>>> a, b, c = FiniteSet(1), FiniteSet(2), FiniteSet(1, 2)
>>> A.powerset() == FiniteSet(a, b, c, EmptySet)
True

一个区间的幂集:

>>> Interval(1, 2).powerset()
PowerSet(Interval(1, 2))
property sup

self 的上确界。

示例

>>> from sympy import Interval, Union
>>> Interval(0, 1).sup
1
>>> Union(Interval(0, 1), Interval(2, 3)).sup
3
symmetric_difference(other)[源代码][源代码]

返回 selfother 的对称差集。

参考文献

示例

>>> from sympy import Interval, S
>>> Interval(1, 3).symmetric_difference(S.Reals)
Union(Interval.open(-oo, 1), Interval.open(3, oo))
>>> Interval(1, 10).symmetric_difference(S.Reals)
Union(Interval.open(-oo, 1), Interval.open(10, oo))
>>> from sympy import S, EmptySet
>>> S.Reals.symmetric_difference(EmptySet)
Reals
union(other)[源代码][源代码]

返回 selfother 的并集。

示例

作为一种快捷方式,可以使用 + 运算符:

>>> from sympy import Interval, FiniteSet
>>> Interval(0, 1).union(Interval(2, 3))
Union(Interval(0, 1), Interval(2, 3))
>>> Interval(0, 1) + Interval(2, 3)
Union(Interval(0, 1), Interval(2, 3))
>>> Interval(1, 2, True, True) + FiniteSet(2, 3)
Union({3}, Interval.Lopen(1, 2))

同样,可以使用 - 运算符进行集合差集运算:

>>> Interval(0, 2) - Interval(0, 1)
Interval.Lopen(1, 2)
>>> Interval(1, 3) - FiniteSet(2)
Union(Interval.Ropen(1, 2), Interval.Lopen(2, 3))
sympy.sets.sets.imageset(*args)[源代码][源代码]

返回在变换 f 下的集合的图像。

示例

>>> from sympy import S, Interval, imageset, sin, Lambda
>>> from sympy.abc import x
>>> imageset(x, 2*x, Interval(0, 2))
Interval(0, 4)
>>> imageset(lambda x: 2*x, Interval(0, 2))
Interval(0, 4)
>>> imageset(Lambda(x, sin(x)), Interval(-2, 1))
ImageSet(Lambda(x, sin(x)), Interval(-2, 1))
>>> imageset(sin, Interval(-2, 1))
ImageSet(Lambda(x, sin(x)), Interval(-2, 1))
>>> imageset(lambda y: x + y, Interval(-2, 1))
ImageSet(Lambda(y, x + y), Interval(-2, 1))

应用于整数集合的表达式被简化以尽可能少地显示负数,线性表达式被转换为标准形式。如果这不是所期望的,则应使用未计算的 ImageSet。

>>> imageset(x, -2*x + 5, S.Integers)
ImageSet(Lambda(x, 2*x + 1), Integers)

基本集

class sympy.sets.sets.Interval(
start,
end,
left_open=False,
right_open=False,
)[源代码][源代码]

将一个实区间表示为集合。

用法:

返回一个以 startend 为端点的区间。

对于 left_open=True (默认 left_openFalse),区间将在左侧开放。同样地,对于 right_open=True,区间将在右侧开放。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

end

区间的右端点。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_left_unbounded

如果左端点为负无穷大,则返回 True

is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_right_unbounded

如果右端点为正无穷大,则返回 True

is_transcendental
is_zero
kind

集合的种类

left_open

如果区间是左开的,则为真。

measure

self 的 (勒贝格) 测度

right_open

如果区间是右开的,则为真。

start

区间的左端点。

sup

self 的上确界。

方法

Lopen(a, b)

返回一个不包括左边界的时间间隔。

Ropen(a, b)

返回一个不包括右边界的时间间隔。

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(x)

用不等式和逻辑运算符重写一个区间。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

open(a, b)

返回一个不包括边界的区间。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

to_mpi

注释

  • 仅支持真正的端点

  • Interval(a, b)\(a > b\) 时将返回空集

  • 使用 evalf() 方法将一个区间转换为 mpmath 的 mpi 区间实例

参考文献

示例

>>> from sympy import Symbol, Interval
>>> Interval(0, 1)
Interval(0, 1)
>>> Interval.Ropen(0, 1)
Interval.Ropen(0, 1)
>>> Interval.Ropen(0, 1)
Interval.Ropen(0, 1)
>>> Interval.Lopen(0, 1)
Interval.Lopen(0, 1)
>>> Interval.open(0, 1)
Interval.open(0, 1)
>>> a = Symbol('a', real=True)
>>> Interval(0, a)
Interval(0, a)
classmethod Lopen(a, b)[源代码][源代码]

返回一个不包括左边界的时间间隔。

classmethod Ropen(a, b)[源代码][源代码]

返回一个不包括右边界的时间间隔。

as_relational(x)[源代码][源代码]

用不等式和逻辑运算符重写一个区间。

property end

区间的右端点。

此属性采用与 sup 属性相同的值。

示例

>>> from sympy import Interval
>>> Interval(0, 1).end
1
property is_left_unbounded

如果左端点为负无穷大,则返回 True

property is_right_unbounded

如果右端点为正无穷大,则返回 True

property left_open

如果区间是左开的,则为真。

示例

>>> from sympy import Interval
>>> Interval(0, 1, left_open=True).left_open
True
>>> Interval(0, 1, left_open=False).left_open
False
classmethod open(a, b)[源代码][源代码]

返回一个不包括边界的区间。

property right_open

如果区间是右开的,则为真。

示例

>>> from sympy import Interval
>>> Interval(0, 1, right_open=True).right_open
True
>>> Interval(0, 1, right_open=False).right_open
False
property start

区间的左端点。

此属性采用与 inf 属性相同的值。

示例

>>> from sympy import Interval
>>> Interval(0, 1).start
0
class sympy.sets.sets.FiniteSet(*args, **kwargs)[源代码][源代码]

表示一组有限的 Sympy 表达式。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(symbol)

用等式和逻辑运算符重写有限集。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

参考文献

示例

>>> from sympy import FiniteSet, Symbol, Interval, Naturals0
>>> FiniteSet(1, 2, 3, 4)
{1, 2, 3, 4}
>>> 3 in FiniteSet(1, 2, 3, 4)
True
>>> FiniteSet(1, (1, 2), Symbol('x'))
{1, x, (1, 2)}
>>> FiniteSet(Interval(1, 2), Naturals0, {1, 2})
FiniteSet({1, 2}, Interval(1, 2), Naturals0)
>>> members = [1, 2, 3, 4]
>>> f = FiniteSet(*members)
>>> f
{1, 2, 3, 4}
>>> f - FiniteSet(2)
{1, 3, 4}
>>> f + FiniteSet(2, 5)
{1, 2, 3, 4, 5}
as_relational(symbol)[源代码][源代码]

用等式和逻辑运算符重写有限集。

复合集

class sympy.sets.sets.Union(*args, **kwargs)[源代码][源代码]

表示一个集合的并集作为 集合

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

身份
inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(symbol)

用等式和逻辑运算符重写一个并集。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

flatten(seq)

返回序列,使得序列中没有任何元素的类型为 \(cls\)

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

make_args(expr)

返回一组参数,使得 cls(*arg_set) == expr。

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

参见

Intersection

参考文献

示例

>>> from sympy import Union, Interval
>>> Union(Interval(1, 2), Interval(3, 4))
Union(Interval(1, 2), Interval(3, 4))

Union 构造函数总是会尝试合并重叠的区间,如果可能的话。例如:

>>> Union(Interval(1, 2), Interval(2, 3))
Interval(1, 3)
as_relational(symbol)[源代码][源代码]

用等式和逻辑运算符重写一个并集。

class sympy.sets.sets.Intersection(*args, evaluate=None)[源代码][源代码]

表示集合的交集作为一个 集合

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

身份
inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(symbol)

用等式和逻辑运算符重写一个交集

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

flatten(seq)

返回序列,使得序列中没有任何元素的类型为 \(cls\)

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

make_args(expr)

返回一组参数,使得 cls(*arg_set) == expr。

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

参见

Union

参考文献

示例

>>> from sympy import Intersection, Interval
>>> Intersection(Interval(1, 3), Interval(2, 4))
Interval(2, 3)

我们经常使用 .intersect 方法

>>> Interval(1,3).intersect(Interval(2,4))
Interval(2, 3)
as_relational(symbol)[源代码][源代码]

用等式和逻辑运算符重写一个交集

class sympy.sets.sets.ProductSet(*sets, **assumptions)[源代码][源代码]

表示集合的笛卡尔积。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable

一个测试集合是否可迭代的属性方法。

is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

集合
sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

as_relational

复制

could_extract_minus_sign

展平

is_hypergeometric

注释

  • 将大多数操作传递给参数集

参考文献

示例

>>> from sympy import Interval, FiniteSet, ProductSet
>>> I = Interval(0, 5); S = FiniteSet(1, 2, 3)
>>> ProductSet(I, S)
ProductSet(Interval(0, 5), {1, 2, 3})
>>> (2, 2) in ProductSet(I, S)
True
>>> Interval(0, 1) * Interval(0, 1) # The unit square
ProductSet(Interval(0, 1), Interval(0, 1))
>>> coin = FiniteSet('H', 'T')
>>> set(coin**2)
{(H, H), (H, T), (T, H), (T, T)}

笛卡尔积不满足交换律或结合律,例如:

>>> I*S == S*I
False
>>> (I*I)*I == I*(I*I)
False
property is_iterable

一个测试集合是否可迭代的方法。如果集合是可迭代的,则返回 True,否则返回 False。

示例

>>> from sympy import FiniteSet, Interval
>>> I = Interval(0, 1)
>>> A = FiniteSet(1, 2, 3, 4, 5)
>>> I.is_iterable
False
>>> A.is_iterable
True
class sympy.sets.sets.Complement(a, b, evaluate=True)[源代码][源代码]

表示一个集合与另一个集合的差集或相对补集。

\[A - B = \{x \in A \mid x \notin B\}\]

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(symbol)

用等式和逻辑运算符重写一个补码

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

reduce(A, B)

简化一个 补码

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

参考文献

示例

>>> from sympy import Complement, FiniteSet
>>> Complement(FiniteSet(0, 1, 2), FiniteSet(1))
{0, 2}
as_relational(symbol)[源代码][源代码]

用等式和逻辑运算符重写一个补码

static reduce(A, B)[源代码][源代码]

简化一个 补码

class sympy.sets.sets.SymmetricDifference(a, b, evaluate=True)[源代码][源代码]

表示在任一集合中且不在它们交集中的元素集合。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(symbol)

用等式和逻辑运算符重写对称差集

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

reduce

参见

Complement, Union

参考文献

示例

>>> from sympy import SymmetricDifference, FiniteSet
>>> SymmetricDifference(FiniteSet(1, 2, 3), FiniteSet(3, 4, 5))
{1, 2, 4, 5}
as_relational(symbol)[源代码][源代码]

用等式和逻辑运算符重写对称差集

class sympy.sets.sets.DisjointUnion(*sets)[源代码][源代码]

表示有限个集合的不交并(也称为外部不交并)。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

集合
sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

参考文献

https://zh.wikipedia.org/wiki/不相交并集

示例

>>> from sympy import DisjointUnion, FiniteSet, Interval, Union, Symbol
>>> A = FiniteSet(1, 2, 3)
>>> B = Interval(0, 5)
>>> DisjointUnion(A, B)
DisjointUnion({1, 2, 3}, Interval(0, 5))
>>> DisjointUnion(A, B).rewrite(Union)
Union(ProductSet({1, 2, 3}, {0}), ProductSet(Interval(0, 5), {1}))
>>> C = FiniteSet(Symbol('x'), Symbol('y'), Symbol('z'))
>>> DisjointUnion(C, C)
DisjointUnion({x, y, z}, {x, y, z})
>>> DisjointUnion(C, C).rewrite(Union)
ProductSet({x, y, z}, {0, 1})

单例集

class sympy.sets.sets.EmptySet[源代码][源代码]

表示空集。空集作为单例可用作 S.EmptySet

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

as_relational

复制

could_extract_minus_sign

is_hypergeometric

参见

UniversalSet

参考文献

示例

>>> from sympy import S, Interval
>>> S.EmptySet
EmptySet
>>> Interval(1, 2).intersect(S.EmptySet)
EmptySet
class sympy.sets.sets.UniversalSet[源代码][源代码]

表示所有事物的集合。全集作为一个单例可用,即 S.UniversalSet

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

as_relational

复制

could_extract_minus_sign

is_hypergeometric

参见

EmptySet

参考文献

示例

>>> from sympy import S, Interval
>>> S.UniversalSet
UniversalSet
>>> Interval(1, 2).intersect(S.UniversalSet)
Interval(1, 2)

特殊集合

class sympy.sets.fancysets.Rationals[源代码][源代码]

表示有理数。这个集合也可以作为单例 S.Rationals 使用。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

示例

>>> from sympy import S
>>> S.Half in S.Rationals
True
>>> iterable = iter(S.Rationals)
>>> [next(iterable) for i in range(12)]
[0, 1, -1, 1/2, 2, -1/2, -2, 1/3, 3, -1/3, -3, 2/3]
class sympy.sets.fancysets.Naturals[源代码][源代码]

表示自然数(或计数数),这些是从1开始的全部正整数。这个集合也可以作为单例 S.Naturals 使用。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

as_relational

复制

could_extract_minus_sign

is_hypergeometric

参见

Naturals0

非负整数(即包括0)

Integers

还包括负整数

示例

>>> from sympy import S, Interval, pprint
>>> 5 in S.Naturals
True
>>> iterable = iter(S.Naturals)
>>> next(iterable)
1
>>> next(iterable)
2
>>> next(iterable)
3
>>> pprint(S.Naturals.intersect(Interval(0, 10)))
{1, 2, ..., 10}
class sympy.sets.fancysets.Naturals0[源代码][源代码]

表示所有非负整数,包括零。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

as_relational

复制

could_extract_minus_sign

is_hypergeometric

参见

Naturals

正整数;不包括0

Integers

还包括负整数

class sympy.sets.fancysets.Integers[源代码][源代码]

表示所有整数:正数、负数和零。这个集合也可以作为单例 S.Integers 使用。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

as_relational

复制

could_extract_minus_sign

is_hypergeometric

参见

Naturals0

非负整数

Integers

正整数、负整数和零

示例

>>> from sympy import S, Interval, pprint
>>> 5 in S.Naturals
True
>>> iterable = iter(S.Integers)
>>> next(iterable)
0
>>> next(iterable)
1
>>> next(iterable)
-1
>>> next(iterable)
2
>>> pprint(S.Integers.intersect(Interval(-4, 4)))
{-4, -3, ..., 4}
class sympy.sets.fancysets.Reals[源代码][源代码]

表示从负无穷到正无穷的所有实数,包括所有整数、有理数和无理数。这个集合也可以作为单例 S.Reals 使用。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

end

区间的右端点。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_left_unbounded

如果左端点为负无穷大,则返回 True

is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_right_unbounded

如果右端点为正无穷大,则返回 True

is_transcendental
is_zero
kind

集合的种类

left_open

如果区间是左开的,则为真。

measure

self 的 (勒贝格) 测度

right_open

如果区间是右开的,则为真。

start

区间的左端点。

sup

self 的上确界。

方法

Lopen(a, b)

返回一个不包括左边界的时间间隔。

Ropen(a, b)

返回一个不包括右边界的时间间隔。

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(x)

用不等式和逻辑运算符重写一个区间。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

open(a, b)

返回一个不包括边界的区间。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

to_mpi

参见

ComplexRegion

示例

>>> from sympy import S, Rational, pi, I
>>> 5 in S.Reals
True
>>> Rational(-1, 2) in S.Reals
True
>>> pi in S.Reals
True
>>> 3*I in S.Reals
False
>>> S.Reals.contains(pi)
True
class sympy.sets.fancysets.Complexes[源代码][源代码]

所有复数的 集合

属性:
a_interval

当自身为矩形形式时,返回 \(x\) 区间的并集,或当自身为极坐标形式时,返回 \(r\) 区间的并集。

args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

b_interval

当自身处于矩形形式时,返回 \(y\) 区间的并集,或者当自身处于极坐标形式时,返回 \(theta\) 区间的并集。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

表达式
expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

psets

返回一个集合元组 (ProductSets) 作为 self 的输入。

sets

将原始输入集返回给 self。

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

from_real(sets)

将给定的实数子集转换为复数区域。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

示例

>>> from sympy import S, I
>>> S.Complexes
Complexes
>>> 1 + I in S.Complexes
True
class sympy.sets.fancysets.ImageSet(flambda, *sets)[源代码][源代码]

数学函数下集合的图像。变换必须作为一个Lambda函数给出,该函数具有与其操作的集合元素数量相同的参数,例如,在作用于整数集合时为1个参数,在作用于复数区域时为2个参数。

这个函数通常不会被直接调用,而是从 imageset 中调用。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

base_pset
base_set
基础集合
boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

lamda
measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

示例

>>> from sympy import Symbol, S, pi, Dummy, Lambda
>>> from sympy import FiniteSet, ImageSet, Interval
>>> x = Symbol('x')
>>> N = S.Naturals
>>> squares = ImageSet(Lambda(x, x**2), N) # {x**2 for x in N}
>>> 4 in squares
True
>>> 5 in squares
False
>>> FiniteSet(0, 1, 2, 3, 4, 5, 6, 7, 9, 10).intersect(squares)
{1, 4, 9}
>>> square_iterable = iter(squares)
>>> for i in range(4):
...     next(square_iterable)
1
4
9
16

如果你想为 \(x\) = 2, 1/2 等获取值(在将其作为参数传递之前,请检查 \(x\) 值是否在 base_set 中)

>>> squares.lamda(2)
4
>>> squares.lamda(S(1)/2)
1/4
>>> n = Dummy('n')
>>> solutions = ImageSet(Lambda(n, n*pi), S.Integers) # solutions of sin(x) = 0
>>> dom = Interval(-1, 1)
>>> dom.intersect(solutions)
{0}
class sympy.sets.fancysets.Range(*args)[源代码][源代码]

表示一个整数范围。可以调用为 Range(stop)Range(start, stop)Range(start, stop, step);当 step 未给出时,默认为 1。

Range(stop) 等同于 Range(0, stop, 1),并且停止值(就像Python的范围一样)不包含在Range值中。

>>> from sympy import Range
>>> list(Range(3))
[0, 1, 2]

步长也可以是负数:

>>> list(Range(10, 0, -2))
[10, 8, 6, 4, 2]

停止值被规范化,因此等效的范围总是具有相同的参数:

>>> Range(0, 10, 3)
Range(0, 12, 3)

允许无限范围。oo-oo 永远不会包含在集合中(Range 始终是 Integers 的子集)。如果起始点是无限的,那么最终值是 stop - step。要迭代这样的范围,需要将其反转:

>>> from sympy import oo
>>> r = Range(-oo, 1)
>>> r[-1]
0
>>> next(iter(r))
Traceback (most recent call last):
...
TypeError: Cannot iterate over Range with infinite start
>>> next(iter(r.reversed))
0

虽然 Range 是一个 集合 (并且支持正常的集合操作),但它保持了元素的顺序,并且可以在使用 range 的上下文中使用。

>>> from sympy import Interval
>>> Range(0, 10, 2).intersect(Interval(3, 7))
Range(4, 8, 2)
>>> list(_)
[4, 6]

尽管对 Range 进行切片总是会返回一个 Range – 可能是空的 – 任何空交集都会返回一个空集:

>>> Range(3)[:0]
Range(0, 0, 1)
>>> Range(3).intersect(Interval(4, oo))
EmptySet
>>> Range(3).intersect(Range(4, oo))
EmptySet

Range 将接受符号参数,但在显示 Range 之外的功能支持非常有限:

>>> from sympy import Symbol, pprint
>>> from sympy.abc import i, j, k
>>> Range(i, j, k).start
i
>>> Range(i, j, k).inf
Traceback (most recent call last):
...
ValueError: invalid method for symbolic range

使用整数符号时,将获得更好的成功:

>>> n = Symbol('n', integer=True)
>>> r = Range(n, n + 20, 3)
>>> r.inf
n
>>> pprint(r)
{n, n + 3, ..., n + 18}
属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_iterable
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

reversed

返回一个顺序相反的等效范围。

大小
开始
步骤
停止
sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_relational(x)

用等式和逻辑运算符重写一个范围。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

as_relational(x)[源代码][源代码]

用等式和逻辑运算符重写一个范围。

property reversed

返回一个顺序相反的等效范围。

示例

>>> from sympy import Range
>>> Range(10).reversed
Range(9, -1, -1)
class sympy.sets.fancysets.ComplexRegion(sets, polar=False)[源代码][源代码]

表示所有复数的集合。它可以表示复平面的区域,既可以是极坐标形式,也可以是直角坐标形式。

  • 极坐标形式输入是 rtheta 区间的 ProductSet 或 ProductSets 的并集形式,并使用标志 polar=True

    \[Z = \{z \in \mathbb{C} \mid z = r\times (\cos(\theta) + I\sin(\theta)), r \in [\texttt{r}], \theta \in [\texttt{theta}]\}\]
  • 矩形形式输入 是以 x 和 y 区间的产品集或产品集的并集形式,表示平面中复数的实部和虚部。默认输入类型为矩形形式。

\[Z = \{z \in \mathbb{C} \mid z = x + Iy, x \in [\operatorname{re}(z)], y \in [\operatorname{im}(z)]\}\]
属性:
a_interval

当自身为矩形形式时,返回 \(x\) 区间的并集,或当自身为极坐标形式时,返回 \(r\) 区间的并集。

args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

b_interval

当自身处于矩形形式时,返回 \(y\) 区间的并集,或者当自身处于极坐标形式时,返回 \(theta\) 区间的并集。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

psets

返回一个集合元组 (ProductSets) 作为 self 的输入。

sets

将原始输入集返回给 self。

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

from_real(sets)

将给定的实数子集转换为复数区域。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

示例

>>> from sympy import ComplexRegion, Interval, S, I, Union
>>> a = Interval(2, 3)
>>> b = Interval(4, 6)
>>> c1 = ComplexRegion(a*b)  # Rectangular Form
>>> c1
CartesianComplexRegion(ProductSet(Interval(2, 3), Interval(4, 6)))
  • c1 表示复平面上由坐标 (2, 4), (3, 4), (3, 6) 和 (2, 6) 四个顶点围成的矩形区域。

>>> c = Interval(1, 8)
>>> c2 = ComplexRegion(Union(a*b, b*c))
>>> c2
CartesianComplexRegion(Union(ProductSet(Interval(2, 3), Interval(4, 6)), ProductSet(Interval(4, 6), Interval(1, 8))))
  • c2 表示复平面上两个矩形区域的并集。其中一个由 c1 的坐标包围,另一个由坐标 (4, 1), (6, 1), (6, 8) 和 (4, 8) 包围。

>>> 2.5 + 4.5*I in c1
True
>>> 2.5 + 6.5*I in c1
False
>>> r = Interval(0, 1)
>>> theta = Interval(0, 2*S.Pi)
>>> c2 = ComplexRegion(r*theta, polar=True)  # Polar Form
>>> c2  # unit Disk
PolarComplexRegion(ProductSet(Interval(0, 1), Interval.Ropen(0, 2*pi)))
  • c2 表示复平面中以原点为中心的单位圆盘内的区域。

>>> 0.5 + 0.5*I in c2
True
>>> 1 + 2*I in c2
False
>>> unit_disk = ComplexRegion(Interval(0, 1)*Interval(0, 2*S.Pi), polar=True)
>>> upper_half_unit_disk = ComplexRegion(Interval(0, 1)*Interval(0, S.Pi), polar=True)
>>> intersection = unit_disk.intersect(upper_half_unit_disk)
>>> intersection
PolarComplexRegion(ProductSet(Interval(0, 1), Interval(0, pi)))
>>> intersection == upper_half_unit_disk
True
property a_interval

当自身为矩形形式时,返回 \(x\) 区间的并集,或当自身为极坐标形式时,返回 \(r\) 区间的并集。

示例

>>> from sympy import Interval, ComplexRegion, Union
>>> a = Interval(2, 3)
>>> b = Interval(4, 5)
>>> c = Interval(1, 7)
>>> C1 = ComplexRegion(a*b)
>>> C1.a_interval
Interval(2, 3)
>>> C2 = ComplexRegion(Union(a*b, b*c))
>>> C2.a_interval
Union(Interval(2, 3), Interval(4, 5))
property b_interval

当自身处于矩形形式时,返回 \(y\) 区间的并集,或者当自身处于极坐标形式时,返回 \(theta\) 区间的并集。

示例

>>> from sympy import Interval, ComplexRegion, Union
>>> a = Interval(2, 3)
>>> b = Interval(4, 5)
>>> c = Interval(1, 7)
>>> C1 = ComplexRegion(a*b)
>>> C1.b_interval
Interval(4, 5)
>>> C2 = ComplexRegion(Union(a*b, b*c))
>>> C2.b_interval
Interval(1, 7)
classmethod from_real(sets)[源代码][源代码]

将给定的实数子集转换为复数区域。

示例

>>> from sympy import Interval, ComplexRegion
>>> unit = Interval(0,1)
>>> ComplexRegion.from_real(unit)
CartesianComplexRegion(ProductSet(Interval(0, 1), {0}))
property psets

返回一个集合元组 (ProductSets) 作为 self 的输入。

示例

>>> from sympy import Interval, ComplexRegion, Union
>>> a = Interval(2, 3)
>>> b = Interval(4, 5)
>>> c = Interval(1, 7)
>>> C1 = ComplexRegion(a*b)
>>> C1.psets
(ProductSet(Interval(2, 3), Interval(4, 5)),)
>>> C2 = ComplexRegion(Union(a*b, b*c))
>>> C2.psets
(ProductSet(Interval(2, 3), Interval(4, 5)), ProductSet(Interval(4, 5), Interval(1, 7)))
property sets

将原始输入集返回给 self。

示例

>>> from sympy import Interval, ComplexRegion, Union
>>> a = Interval(2, 3)
>>> b = Interval(4, 5)
>>> c = Interval(1, 7)
>>> C1 = ComplexRegion(a*b)
>>> C1.sets
ProductSet(Interval(2, 3), Interval(4, 5))
>>> C2 = ComplexRegion(Union(a*b, b*c))
>>> C2.sets
Union(ProductSet(Interval(2, 3), Interval(4, 5)), ProductSet(Interval(4, 5), Interval(1, 7)))
class sympy.sets.fancysets.CartesianComplexRegion(sets)[源代码][源代码]

表示复平面中正方形区域的集合。

\[Z = \{z \in \mathbb{C} \mid z = x + Iy, x \in [\operatorname{re}(z)], y \in [\operatorname{im}(z)]\}\]
属性:
a_interval

当自身为矩形形式时,返回 \(x\) 区间的并集,或当自身为极坐标形式时,返回 \(r\) 区间的并集。

args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

b_interval

当自身处于矩形形式时,返回 \(y\) 区间的并集,或者当自身处于极坐标形式时,返回 \(theta\) 区间的并集。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

表达式
expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

psets

返回一个集合元组 (ProductSets) 作为 self 的输入。

sets

将原始输入集返回给 self。

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

from_real(sets)

将给定的实数子集转换为复数区域。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

示例

>>> from sympy import ComplexRegion, I, Interval
>>> region = ComplexRegion(Interval(1, 3) * Interval(4, 6))
>>> 2 + 5*I in region
True
>>> 5*I in region
False
class sympy.sets.fancysets.PolarComplexRegion(sets)[源代码][源代码]

表示复平面极区域的集合。

\[Z = \{z \in \mathbb{C} \mid z = r\times (\cos(\theta) + I\sin(\theta)), r \in [\texttt{r}], \theta \in [\texttt{theta}]\}\]
属性:
a_interval

当自身为矩形形式时,返回 \(x\) 区间的并集,或当自身为极坐标形式时,返回 \(r\) 区间的并集。

args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

b_interval

当自身处于矩形形式时,返回 \(y\) 区间的并集,或者当自身处于极坐标形式时,返回 \(theta\) 区间的并集。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

表达式
expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

psets

返回一个集合元组 (ProductSets) 作为 self 的输入。

sets

将原始输入集返回给 self。

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

from_real(sets)

将给定的实数子集转换为复数区域。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

示例

>>> from sympy import ComplexRegion, Interval, oo, pi, I
>>> rset = Interval(0, oo)
>>> thetaset = Interval(0, pi)
>>> upper_half_plane = ComplexRegion(rset * thetaset, polar=True)
>>> 1 + I in upper_half_plane
True
>>> 1 - I in upper_half_plane
False
sympy.sets.fancysets.normalize_theta_set(theta)[源代码][源代码]

规范化实数集 \(theta\) 在区间 \([0, 2\pi)\) 内。它返回 \(theta\) 在集合中的规范化值。对于区间,返回的最大周期为 \([0, 2\pi]\),即对于 \(theta\) 等于 \([0, 10\pi]\),返回的规范化值将为 \([0, 2\pi)\)。目前不支持端点为非 pi 倍数的区间。

Raises:
NotImplementedError

Normalizing theta Set 的算法尚未实现。

ValueError

输入无效,即输入不是一个真正的集合。

RuntimeError

这是一个错误,请报告到github问题追踪器。

示例

>>> from sympy.sets.fancysets import normalize_theta_set
>>> from sympy import Interval, FiniteSet, pi
>>> normalize_theta_set(Interval(9*pi/2, 5*pi))
Interval(pi/2, pi)
>>> normalize_theta_set(Interval(-3*pi/2, pi/2))
Interval.Ropen(0, 2*pi)
>>> normalize_theta_set(Interval(-pi/2, pi/2))
Union(Interval(0, pi/2), Interval.Ropen(3*pi/2, 2*pi))
>>> normalize_theta_set(Interval(-4*pi, 3*pi))
Interval.Ropen(0, 2*pi)
>>> normalize_theta_set(Interval(-3*pi/2, -pi/2))
Interval(pi/2, 3*pi/2)
>>> normalize_theta_set(FiniteSet(0, pi, 3*pi))
{0, pi}

幂集

class sympy.sets.powerset.PowerSet(arg, evaluate=None)[源代码][源代码]

一个表示幂集的符号对象。

参数:
参数设置

要获取权限的集合。

评估布尔

控制评估的标志。

如果对有限集禁用了评估,它可以利用子集测试作为成员测试的优势。

属性:
参数
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

注释

幂集 \(\mathcal{P}(S)\) 定义为包含 \(S\) 的所有子集的集合。

如果集合 \(S\) 是有限集,其幂集将包含 \(2^{\left| S \right|}\) 个元素,其中 \(\left| S \right|\) 表示 \(S\) 的基数。

参考文献

示例

>>> from sympy import PowerSet, S, FiniteSet

一个有限集的幂集:

>>> PowerSet(FiniteSet(1, 2, 3))
PowerSet({1, 2, 3})

空集的幂集:

>>> PowerSet(S.EmptySet)
PowerSet(EmptySet)
>>> PowerSet(PowerSet(S.EmptySet))
PowerSet(PowerSet(EmptySet))

一个无限集的幂集:

>>> PowerSet(S.Reals)
PowerSet(Reals)

将有限集合的幂集评估为其显式形式:

>>> PowerSet(FiniteSet(1, 2, 3)).rewrite(FiniteSet)
FiniteSet(EmptySet, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3})

条件集

class sympy.sets.conditionset.ConditionSet(
sym,
condition,
base_set=UniversalSet,
)[源代码][源代码]

满足给定条件的元素集合。

\[\{x \mid \textrm{条件}(x) = \texttt{真}, x \in S\}\]
属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

base_set
bound_symbols
boundary

一个集合的边界或前沿。

canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

closure

返回集合闭包的属性方法。

条件
expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

inf

self 的下确界。

interior

返回集合内部的属性方法。

is_Complement
is_EmptySet
is_Intersection
is_UniversalSet
is_algebraic
is_antihermitian
is_closed

一个检查集合是否闭合的属性方法。

is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_empty
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_finite_set
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_open

检查集合是否为开集的属性方法。

is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero
kind

集合的种类

measure

self 的 (勒贝格) 测度

sup

self 的上确界。

sym

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

complement(universe)

相对于给定全集的 'self' 的补集。

contains(other)

返回一个 SymPy 值,指示 other 是否包含在 self 中:如果包含则返回 true,如果不包含则返回 false,否则返回一个未求值的 Contains 表达式(或者,在 ConditionSet 和 FiniteSet/Intervals 的并集的情况下,返回一个表示包含条件的表达式)。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

evalf([n, subs, maxn, chop, strict, quad, ...])

将给定的公式计算到 n 位精度。

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

intersect(other)

返回 'self' 和 'other' 的交集。

intersection(other)

别名 intersect()

is_disjoint(other)

如果 selfother 不相交,则返回 True。

is_proper_subset(other)

如果 selfother 的真子集,则返回 True。

is_proper_superset(other)

如果 selfother 的真超集,则返回 True。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

is_subset(other)

如果 selfother 的子集,则返回 True。

is_superset(other)

如果 selfother 的超集,则返回 True。

isdisjoint(other)

别名 is_disjoint()

issubset(other)

别名为 is_subset()

issuperset(other)

别名 is_superset()

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

n([n, subs, maxn, chop, strict, quad, verbose])

将给定的公式计算到 n 位精度。

powerset()

找到 self 的幂集。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

symmetric_difference(other)

返回 selfother 的对称差集。

union(other)

返回 selfother 的并集。

xreplace(rule)

替换表达式中对象的出现。

as_relational

复制

could_extract_minus_sign

is_hypergeometric

注释

应避免使用带有假设的符号,否则条件可能在不考虑集合的情况下进行评估:

>>> n = Symbol('n', negative=True)
>>> cond = (n > 0); cond
False
>>> ConditionSet(n, cond, S.Integers)
EmptySet

只有自由符号可以通过使用 \(subs\) 进行更改:

>>> c = ConditionSet(x, x < 1, {x, z})
>>> c.subs(x, y)
ConditionSet(x, x < 1, {y, z})

要检查 pi 是否在 c 中,使用:

>>> pi in c
False

如果没有指定基集,则隐含使用全集:

>>> ConditionSet(x, x < 1).base_set
UniversalSet

只能使用符号或类似符号的表达式:

>>> ConditionSet(x + 1, x + 1 < 1, S.Integers)
Traceback (most recent call last):
...
ValueError: non-symbol dummy not recognized in condition

当基础集是 ConditionSet 时,符号将在可能的情况下统一,优先考虑最外层的符号:

>>> ConditionSet(x, x < y, ConditionSet(z, z + y < 2, S.Integers))
ConditionSet(x, (x < y) & (x + y < 2), Integers)

示例

>>> from sympy import Symbol, S, ConditionSet, pi, Eq, sin, Interval
>>> from sympy.abc import x, y, z
>>> sin_sols = ConditionSet(x, Eq(sin(x), 0), Interval(0, 2*pi))
>>> 2*pi in sin_sols
True
>>> pi/2 in sin_sols
False
>>> 3*pi in sin_sols
False
>>> 5 in ConditionSet(x, x**2 > 4, S.Reals)
True

如果值不在基本集合中,结果为假:

>>> 5 in ConditionSet(x, x**2 > 4, Interval(2, 4))
False
class sympy.sets.conditionset.Contains(x, s, evaluate=None)[源代码][源代码]

断言 x 是集合 S 的一个元素。

属性:
args

返回 ‘self’ 的参数元组。

assumptions0

返回对象 \(type\) 假设。

二进制符号
canonical_variables

返回一个字典,将 self.bound_symbols 中定义的任何变量映射到与表达式中任何自由符号不冲突的符号。

expr_free_symbols
free_symbols

从自身的原子中返回那些自由符号。

func

表达式中的顶级函数。

is_algebraic
is_antihermitian
is_commutative
is_comparable

如果 self 可以计算为一个具有精度的实数(或已经是一个实数),则返回 True,否则返回 False。

is_complex
is_composite
is_even
is_extended_negative
is_extended_nonnegative
is_extended_nonpositive
is_extended_nonzero
is_extended_positive
is_extended_real
is_finite
is_hermitian
is_imaginary
is_infinite
is_integer
is_irrational
is_negative
is_noninteger
is_nonnegative
is_nonpositive
is_nonzero
is_odd
is_polar
is_positive
is_prime
is_rational
is_real
is_transcendental
is_zero

方法

as_content_primitive([radical, clear])

一个存根,允许在计算表达式的内容和基本组件时跳过基本参数(如元组)。

as_dummy()

返回表达式,其中任何具有结构绑定符号的对象都被替换为在其出现的对象中唯一的规范符号,并且仅对交换性具有默认假设为True。

as_set()

atoms(*types)

返回构成当前对象的原子。

class_key()

类的好顺序。

compare(other)

如果对象在规范意义上小于、等于或大于其他对象,则返回 -1、0、1。

count(query)

计算匹配的子表达式的数量。

count_ops([visual])

用于返回操作计数的 count_ops 的包装器。

doit(**hints)

评估默认情况下不评估的对象,如极限、积分、求和和乘积。

dummy_eq(other[, symbol])

比较两个表达式并处理哑符号。

equals(other)

如果给定的公式具有相同的真值表,则返回 True

find(query[, group])

查找所有匹配查询的子表达式。

fromiter(args, **assumptions)

从可迭代对象创建一个新对象。

has(*patterns)

测试是否有任何子表达式匹配任何模式。

has_free(*patterns)

如果 self 包含对象 x 作为自由表达式,则返回 True,否则返回 False。

has_xfree(s)

如果 self 有 s 中的任何一个模式作为自由参数,则返回 True,否则返回 False。

is_same(b[, approx])

如果 a 和 b 结构相同则返回 True,否则返回 False。

match(pattern[, old])

模式匹配。

matches(expr[, repl_dict, old])

用于 match() 的辅助方法,用于在 self 中的通配符符号与 expr 中的表达式之间寻找匹配。

rcall(*args)

通过表达式树递归应用于参数。

refine([assumption])

请参阅 sympy.assumptions 中的 refine 函数。

replace(query, value[, map, simultaneous, exact])

self 中匹配的子表达式替换为 value

rewrite(*args[, deep])

使用定义的规则重写 self

simplify(**kwargs)

请参阅 sympy.simplify 中的 simplify 函数。

sort_key([order])

返回一个排序键。

subs(*args, **kwargs)

在简化参数后,在表达式中用新内容替换旧内容。

xreplace(rule)

替换表达式中对象的出现。

复制

could_extract_minus_sign

is_hypergeometric

to_nnf

参考文献

[1]

https://zh.wikipedia.org/wiki/元素_(数学)

示例

>>> from sympy import Symbol, Integer, S, Contains
>>> Contains(Integer(2), S.Integers)
True
>>> Contains(Integer(-2), S.Naturals)
False
>>> i = Symbol('i', integer=True)
>>> Contains(i, S.Naturals)
Contains(i, Naturals)

设置种类

class sympy.sets.conditionset.SetKind(element_kind=None)[源代码][源代码]

SetKind 是所有集合的种类

每个 Set 实例都将由 SetKind 参数化,参数化的依据是 Set 中元素的种类。元素的种类可能是 NumberKindTupleKind 或其他种类。当并非所有元素具有相同种类时,元素的种类将被指定为 UndefinedKind

参数:
element_kind: 种类 (可选)

集合中元素的种类。在一个定义良好的集合中,所有元素将具有相同的种类。否则,种类应为 sympy.core.kind.UndefinedKindelement_kind 参数是可选的,但仅在 EmptySet 的情况下可以省略,其种类为 SetKind()

示例

>>> from sympy import Interval
>>> Interval(1, 2).kind
SetKind(NumberKind)
>>> Interval(1,2).kind.element_kind
NumberKind

集合的迭代

对于集合的并集,\(\{a, b\} \cup \{x, y\}\) 可以被视为 \(\{a, b, x, y\}\) 进行迭代,无论元素的唯一性如何,然而,对于集合的交集,假设 \(\{a, b\} \cap \{x, y\}\)\(\varnothing\)\(\{a, b\}\) 并不总是有效,因为 \(a\)\(b\)\(x\)\(y\) 中的一些可能是也可能不是交集的元素。

对涉及交集、补集或对称差的集合元素进行迭代,会生成(可能重复的)集合元素,前提是所有元素都已知为集合的元素。如果任何元素无法确定为集合的成员,则迭代会引发 TypeError。这种情况与 x in y 会引发错误的情况相同。

尽管这种方式打破了与Python集合迭代器工作方式的一致性,但有几种理由支持这样实现。我们牢记,从现有sympy集合中使用类似 FiniteSet(*s) 的sympy集合理解可能是一种常见用法。这种方法将使 FiniteSet(*s) 与任何符号集合处理方法(如 FiniteSet(*simplify(s)))保持一致。