# Predicates#

## Common#

### Tautological#

class sympy.assumptions.predicates.common.IsTruePredicate(*args, **kwargs)[source]#

Generic predicate.

Explanation

ask(Q.is_true(x)) is true iff x is true. This only makes sense if x is a boolean object.

Examples

>>> from sympy import ask, Q
>>> from sympy.abc import x, y
True


Wrapping another applied predicate just returns the applied predicate.

>>> Q.is_true(Q.even(x))
Q.even(x)


Wrapping binary relation classes in SymPy core returns applied binary relational predicates.

>>> from sympy import Eq, Gt
>>> Q.is_true(Eq(x, y))
Q.eq(x, y)
>>> Q.is_true(Gt(x, y))
Q.gt(x, y)


Notes

This class is designed to wrap the boolean objects so that they can behave as if they are applied predicates. Consequently, wrapping another applied predicate is unnecessary and thus it just returns the argument. Also, binary relation classes in SymPy core have binary predicates to represent themselves and thus wrapping them with Q.is_true converts them to these applied predicates.

Handler

Multiply dispatched method: IsTrueHandler

Wrapper allowing to query the truth value of a boolean expression.

handler = <dispatched IsTrueHandler>#

### Commutative#

class sympy.assumptions.predicates.common.CommutativePredicate(*args, **kwargs)[source]#

Commutative predicate.

Explanation

ask(Q.commutative(x)) is true iff x commutes with any other object with respect to multiplication operation.

Handler

Multiply dispatched method: CommutativeHandler

Handler for key ‘commutative’.

handler = <dispatched CommutativeHandler>#

## Calculus#

### Finite#

class sympy.assumptions.predicates.calculus.FinitePredicate(*args, **kwargs)[source]#

Finite number predicate.

Explanation

Q.finite(x) is true if x is a number but neither an infinity nor a NaN. In other words, ask(Q.finite(x)) is true for all numerical x having a bounded absolute value.

Examples

>>> from sympy import Q, ask, S, oo, I, zoo
>>> from sympy.abc import x
False
False
False
True
True
True
None


Handler

Multiply dispatched method: FiniteHandler

Handler for Q.finite. Test that an expression is bounded respect to all its variables.

References

R7

https://en.wikipedia.org/wiki/Finite

handler = <dispatched FiniteHandler>#

### Infinite#

class sympy.assumptions.predicates.calculus.InfinitePredicate(*args, **kwargs)[source]#

Infinite number predicate.

Q.infinite(x) is true iff the absolute value of x is infinity.

Handler

Multiply dispatched method: InfiniteHandler

Handler for Q.infinite key.

handler = <dispatched InfiniteHandler>#

## Matrix#

### Symmetric#

class sympy.assumptions.predicates.matrices.SymmetricPredicate(*args, **kwargs)[source]#

Symmetric matrix predicate.

Explanation

Q.symmetric(x) is true iff x is a square matrix and is equal to its transpose. Every square diagonal matrix is a symmetric matrix.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 2, 2)
>>> Y = MatrixSymbol('Y', 2, 3)
>>> Z = MatrixSymbol('Z', 2, 2)
True
>>> ask(Q.symmetric(X + Z), Q.symmetric(X) & Q.symmetric(Z))
True
False


Handler

Multiply dispatched method: SymmetricHandler

Handler for Q.symmetric.

References

R8

https://en.wikipedia.org/wiki/Symmetric_matrix

handler = <dispatched SymmetricHandler>#

### Invertible#

class sympy.assumptions.predicates.matrices.InvertiblePredicate(*args, **kwargs)[source]#

Invertible matrix predicate.

Explanation

Q.invertible(x) is true iff x is an invertible matrix. A square matrix is called invertible only if its determinant is 0.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 2, 2)
>>> Y = MatrixSymbol('Y', 2, 3)
>>> Z = MatrixSymbol('Z', 2, 2)
False
True
True


Handler

Multiply dispatched method: InvertibleHandler

Handler for Q.invertible.

References

R9

https://en.wikipedia.org/wiki/Invertible_matrix

handler = <dispatched InvertibleHandler>#

### Orthogonal#

class sympy.assumptions.predicates.matrices.OrthogonalPredicate(*args, **kwargs)[source]#

Orthogonal matrix predicate.

Explanation

Q.orthogonal(x) is true iff x is an orthogonal matrix. A square matrix M is an orthogonal matrix if it satisfies M^TM = MM^T = I where M^T is the transpose matrix of M and I is an identity matrix. Note that an orthogonal matrix is necessarily invertible.

Examples

>>> from sympy import Q, ask, MatrixSymbol, Identity
>>> X = MatrixSymbol('X', 2, 2)
>>> Y = MatrixSymbol('Y', 2, 3)
>>> Z = MatrixSymbol('Z', 2, 2)
False
True
True
True


Handler

Multiply dispatched method: OrthogonalHandler

Handler for key ‘orthogonal’.

References

R10

https://en.wikipedia.org/wiki/Orthogonal_matrix

handler = <dispatched OrthogonalHandler>#

### Unitary#

class sympy.assumptions.predicates.matrices.UnitaryPredicate(*args, **kwargs)[source]#

Unitary matrix predicate.

Explanation

Q.unitary(x) is true iff x is a unitary matrix. Unitary matrix is an analogue to orthogonal matrix. A square matrix M with complex elements is unitary if :math:M^TM = MM^T= I where :math:M^T is the conjugate transpose matrix of M.

Examples

>>> from sympy import Q, ask, MatrixSymbol, Identity
>>> X = MatrixSymbol('X', 2, 2)
>>> Y = MatrixSymbol('Y', 2, 3)
>>> Z = MatrixSymbol('Z', 2, 2)
False
True
True


Handler

Multiply dispatched method: UnitaryHandler

Handler for key ‘unitary’.

References

R11

https://en.wikipedia.org/wiki/Unitary_matrix

handler = <dispatched UnitaryHandler>#

### Positive Definite#

class sympy.assumptions.predicates.matrices.PositiveDefinitePredicate(*args, **kwargs)[source]#

Positive definite matrix predicate.

Explanation

If $$M$$ is a $$n \times n$$ symmetric real matrix, it is said to be positive definite if $$Z^TMZ$$ is positive for every non-zero column vector $$Z$$ of $$n$$ real numbers.

Examples

>>> from sympy import Q, ask, MatrixSymbol, Identity
>>> X = MatrixSymbol('X', 2, 2)
>>> Y = MatrixSymbol('Y', 2, 3)
>>> Z = MatrixSymbol('Z', 2, 2)
False
True
>>> ask(Q.positive_definite(X + Z), Q.positive_definite(X) &
...     Q.positive_definite(Z))
True


Handler

Multiply dispatched method: PositiveDefiniteHandler

Handler for key ‘positive_definite’.

References

R12

https://en.wikipedia.org/wiki/Positive-definite_matrix

handler = <dispatched PositiveDefiniteHandler>#

### Upper triangular#

class sympy.assumptions.predicates.matrices.UpperTriangularPredicate(*args, **kwargs)[source]#

Upper triangular matrix predicate.

Explanation

A matrix $$M$$ is called upper triangular matrix if $$M_{ij}=0$$ for $$i<j$$.

Examples

>>> from sympy import Q, ask, ZeroMatrix, Identity
True
True


Handler

Multiply dispatched method: UpperTriangularHandler

Handler for key ‘upper_triangular’.

References

R13

http://mathworld.wolfram.com/UpperTriangularMatrix.html

handler = <dispatched UpperTriangularHandler>#

### Lower triangular#

class sympy.assumptions.predicates.matrices.LowerTriangularPredicate(*args, **kwargs)[source]#

Lower triangular matrix predicate.

Explanation

A matrix $$M$$ is called lower triangular matrix if $$M_{ij}=0$$ for $$i>j$$.

Examples

>>> from sympy import Q, ask, ZeroMatrix, Identity
True
True


Handler

Multiply dispatched method: LowerTriangularHandler

Handler for key ‘lower_triangular’.

References

R14

http://mathworld.wolfram.com/LowerTriangularMatrix.html

handler = <dispatched LowerTriangularHandler>#

### Diagonal#

class sympy.assumptions.predicates.matrices.DiagonalPredicate(*args, **kwargs)[source]#

Diagonal matrix predicate.

Explanation

Q.diagonal(x) is true iff x is a diagonal matrix. A diagonal matrix is a matrix in which the entries outside the main diagonal are all zero.

Examples

>>> from sympy import Q, ask, MatrixSymbol, ZeroMatrix
>>> X = MatrixSymbol('X', 2, 2)
True
...     Q.upper_triangular(X))
True


Handler

Multiply dispatched method: DiagonalHandler

Handler for key ‘diagonal’.

References

R15

https://en.wikipedia.org/wiki/Diagonal_matrix

handler = <dispatched DiagonalHandler>#

### Full rank#

class sympy.assumptions.predicates.matrices.FullRankPredicate(*args, **kwargs)[source]#

Fullrank matrix predicate.

Explanation

Q.fullrank(x) is true iff x is a full rank matrix. A matrix is full rank if all rows and columns of the matrix are linearly independent. A square matrix is full rank iff its determinant is nonzero.

Examples

>>> from sympy import Q, ask, MatrixSymbol, ZeroMatrix, Identity
>>> X = MatrixSymbol('X', 2, 2)
True
False
True


Handler

Multiply dispatched method: FullRankHandler

Handler for key ‘fullrank’.

handler = <dispatched FullRankHandler>#

### Square#

class sympy.assumptions.predicates.matrices.SquarePredicate(*args, **kwargs)[source]#

Square matrix predicate.

Explanation

Q.square(x) is true iff x is a square matrix. A square matrix is a matrix with the same number of rows and columns.

Examples

>>> from sympy import Q, ask, MatrixSymbol, ZeroMatrix, Identity
>>> X = MatrixSymbol('X', 2, 2)
>>> Y = MatrixSymbol('X', 2, 3)
True
False
True
True


Handler

Multiply dispatched method: SquareHandler

Handler for Q.square.

References

R16

https://en.wikipedia.org/wiki/Square_matrix

handler = <dispatched SquareHandler>#

### Integer elements#

class sympy.assumptions.predicates.matrices.IntegerElementsPredicate(*args, **kwargs)[source]#

Integer elements matrix predicate.

Explanation

Q.integer_elements(x) is true iff all the elements of x are integers.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 4, 4)
True


Handler

Multiply dispatched method: IntegerElementsHandler

Handler for key ‘integer_elements’.

handler = <dispatched IntegerElementsHandler>#

### Real elements#

class sympy.assumptions.predicates.matrices.RealElementsPredicate(*args, **kwargs)[source]#

Real elements matrix predicate.

Explanation

Q.real_elements(x) is true iff all the elements of x are real numbers.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 4, 4)
True


Handler

Multiply dispatched method: RealElementsHandler

Handler for key ‘real_elements’.

handler = <dispatched RealElementsHandler>#

### Complex elements#

class sympy.assumptions.predicates.matrices.ComplexElementsPredicate(*args, **kwargs)[source]#

Complex elements matrix predicate.

Explanation

Q.complex_elements(x) is true iff all the elements of x are complex numbers.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 4, 4)
True
True


Handler

Multiply dispatched method: ComplexElementsHandler

Handler for key ‘complex_elements’.

handler = <dispatched ComplexElementsHandler>#

### Singular#

class sympy.assumptions.predicates.matrices.SingularPredicate(*args, **kwargs)[source]#

Singular matrix predicate.

A matrix is singular iff the value of its determinant is 0.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 4, 4)
False
True


Handler

Multiply dispatched method: SingularHandler

Predicate fore key ‘singular’.

References

R17

http://mathworld.wolfram.com/SingularMatrix.html

handler = <dispatched SingularHandler>#

### Normal#

class sympy.assumptions.predicates.matrices.NormalPredicate(*args, **kwargs)[source]#

Normal matrix predicate.

A matrix is normal if it commutes with its conjugate transpose.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 4, 4)
True


Handler

Multiply dispatched method: NormalHandler

Predicate fore key ‘normal’.

References

R18

https://en.wikipedia.org/wiki/Normal_matrix

handler = <dispatched NormalHandler>#

### Triangular#

class sympy.assumptions.predicates.matrices.TriangularPredicate(*args, **kwargs)[source]#

Triangular matrix predicate.

Explanation

Q.triangular(X) is true if X is one that is either lower triangular or upper triangular.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 4, 4)
True
True


Handler

Multiply dispatched method: TriangularHandler

Predicate fore key ‘triangular’.

References

R19

https://en.wikipedia.org/wiki/Triangular_matrix

handler = <dispatched TriangularHandler>#

### Unit triangular#

class sympy.assumptions.predicates.matrices.UnitTriangularPredicate(*args, **kwargs)[source]#

Unit triangular matrix predicate.

Explanation

A unit triangular matrix is a triangular matrix with 1s on the diagonal.

Examples

>>> from sympy import Q, ask, MatrixSymbol
>>> X = MatrixSymbol('X', 4, 4)
True


Handler

Multiply dispatched method: UnitTriangularHandler

Predicate fore key ‘unit_triangular’.

handler = <dispatched UnitTriangularHandler>#

## Number Theory#

### Even#

class sympy.assumptions.predicates.ntheory.EvenPredicate(*args, **kwargs)[source]#

Even number predicate.

Explanation

ask(Q.even(x)) is true iff x belongs to the set of even integers.

Examples

>>> from sympy import Q, ask, pi
True
True
False
False


Handler

Multiply dispatched method: EvenHandler

Handler for key ‘even’.

handler = <dispatched EvenHandler>#

### Odd#

class sympy.assumptions.predicates.ntheory.OddPredicate(*args, **kwargs)[source]#

Odd number predicate.

Explanation

ask(Q.odd(x)) is true iff x belongs to the set of odd numbers.

Examples

>>> from sympy import Q, ask, pi
False
False
True
False


Handler

Multiply dispatched method: OddHandler

Handler for key ‘odd’. Test that an expression represents an odd number.

handler = <dispatched OddHandler>#

### Prime#

class sympy.assumptions.predicates.ntheory.PrimePredicate(*args, **kwargs)[source]#

Prime number predicate.

Explanation

ask(Q.prime(x)) is true iff x is a natural number greater than 1 that has no positive divisors other than 1 and the number itself.

Examples

>>> from sympy import Q, ask
False
False
True
False
False


Handler

Multiply dispatched method: PrimeHandler

Handler for key ‘prime’. Test that an expression represents a prime number. When the expression is an exact number, the result (when True) is subject to the limitations of isprime() which is used to return the result.

handler = <dispatched PrimeHandler>#

### Composite#

class sympy.assumptions.predicates.ntheory.CompositePredicate(*args, **kwargs)[source]#

Composite number predicate.

Explanation

ask(Q.composite(x)) is true iff x is a positive integer and has at least one positive divisor other than 1 and the number itself.

Examples

>>> from sympy import Q, ask
False
False
False
True


Handler

Multiply dispatched method: CompositeHandler

Handler for key ‘composite’.

handler = <dispatched CompositeHandler>#

## Order#

### Positive#

class sympy.assumptions.predicates.order.PositivePredicate(*args, **kwargs)[source]#

Positive real number predicate.

Explanation

Q.positive(x) is true iff x is real and $$x > 0$$, that is if x is in the interval $$(0, \infty)$$. In particular, infinity is not positive.

A few important facts about positive numbers:

• Note that Q.nonpositive and ~Q.positive are not the same

thing. ~Q.positive(x) simply means that x is not positive, whereas Q.nonpositive(x) means that x is real and not positive, i.e., Q.nonpositive(x) is logically equivalent to $$Q.negative(x) | Q.zero(x)$$. So for example, ~Q.positive(I) is true, whereas Q.nonpositive(I) is false.

• See the documentation of Q.real for more information about

related facts.

Examples

>>> from sympy import Q, ask, symbols, I
>>> x = symbols('x')
>>> ask(Q.positive(x), Q.real(x) & ~Q.negative(x) & ~Q.zero(x))
True
True
False
True


Handler

Multiply dispatched method: PositiveHandler

Handler for key ‘positive’. Test that an expression is strictly greater than zero.

handler = <dispatched PositiveHandler>#

### Negative#

class sympy.assumptions.predicates.order.NegativePredicate(*args, **kwargs)[source]#

Negative number predicate.

Explanation

Q.negative(x) is true iff x is a real number and $$x < 0$$, that is, it is in the interval $$(-\infty, 0)$$. Note in particular that negative infinity is not negative.

A few important facts about negative numbers:

• Note that Q.nonnegative and ~Q.negative are not the same

thing. ~Q.negative(x) simply means that x is not negative, whereas Q.nonnegative(x) means that x is real and not negative, i.e., Q.nonnegative(x) is logically equivalent to Q.zero(x) | Q.positive(x). So for example, ~Q.negative(I) is true, whereas Q.nonnegative(I) is false.

• See the documentation of Q.real for more information about

related facts.

Examples

>>> from sympy import Q, ask, symbols, I
>>> x = symbols('x')
>>> ask(Q.negative(x), Q.real(x) & ~Q.positive(x) & ~Q.zero(x))
True
True
False
True


Handler

Multiply dispatched method: NegativeHandler

Handler for Q.negative. Test that an expression is strictly less than zero.

handler = <dispatched NegativeHandler>#

### Zero#

class sympy.assumptions.predicates.order.ZeroPredicate(*args, **kwargs)[source]#

Zero number predicate.

Explanation

ask(Q.zero(x)) is true iff the value of x is zero.

Examples

>>> from sympy import ask, Q, oo, symbols
>>> x, y = symbols('x, y')
True
True
None
False
True


Handler

Multiply dispatched method: ZeroHandler

Handler for key ‘zero’.

handler = <dispatched ZeroHandler>#

### Nonzero#

class sympy.assumptions.predicates.order.NonZeroPredicate(*args, **kwargs)[source]#

Nonzero real number predicate.

Explanation

ask(Q.nonzero(x)) is true iff x is real and x is not zero. Note in particular that Q.nonzero(x) is false if x is not real. Use ~Q.zero(x) if you want the negation of being zero without any real assumptions.

A few important facts about nonzero numbers:

• Q.nonzero is logically equivalent to Q.positive | Q.negative.

• See the documentation of Q.real for more information about

related facts.

Examples

>>> from sympy import Q, ask, symbols, I, oo
>>> x = symbols('x')
None
True
False
False
False
True
False


Handler

Multiply dispatched method: NonZeroHandler

Handler for key ‘zero’. Test that an expression is not identically zero.

handler = <dispatched NonZeroHandler>#

### Nonpositive#

class sympy.assumptions.predicates.order.NonPositivePredicate(*args, **kwargs)[source]#

Nonpositive real number predicate.

Explanation

ask(Q.nonpositive(x)) is true iff x belongs to the set of negative numbers including zero.

• Note that Q.nonpositive and ~Q.positive are not the same

thing. ~Q.positive(x) simply means that x is not positive, whereas Q.nonpositive(x) means that x is real and not positive, i.e., Q.nonpositive(x) is logically equivalent to $$Q.negative(x) | Q.zero(x)$$. So for example, ~Q.positive(I) is true, whereas Q.nonpositive(I) is false.

Examples

>>> from sympy import Q, ask, I

>>> ask(Q.nonpositive(-1))
True
True
False
False
False


Handler

Multiply dispatched method: NonPositiveHandler

Handler for key ‘nonpositive’.

handler = <dispatched NonPositiveHandler>#

### Nonnegative#

class sympy.assumptions.predicates.order.NonNegativePredicate(*args, **kwargs)[source]#

Nonnegative real number predicate.

Explanation

ask(Q.nonnegative(x)) is true iff x belongs to the set of positive numbers including zero.

• Note that Q.nonnegative and ~Q.negative are not the same

thing. ~Q.negative(x) simply means that x is not negative, whereas Q.nonnegative(x) means that x is real and not negative, i.e., Q.nonnegative(x) is logically equivalent to Q.zero(x) | Q.positive(x). So for example, ~Q.negative(I) is true, whereas Q.nonnegative(I) is false.

Examples

>>> from sympy import Q, ask, I
True
True
False
False
False


Handler

Multiply dispatched method: NonNegativeHandler

Handler for Q.nonnegative.

handler = <dispatched NonNegativeHandler>#

## Sets#

### Integer#

class sympy.assumptions.predicates.sets.IntegerPredicate(*args, **kwargs)[source]#

Integer predicate.

Explanation

Q.integer(x) is true iff x belongs to the set of integer numbers.

Examples

>>> from sympy import Q, ask, S
True
False


Handler

Multiply dispatched method: IntegerHandler

Handler for Q.integer.

Test that an expression belongs to the field of integer numbers.

References

R20

https://en.wikipedia.org/wiki/Integer

handler = <dispatched IntegerHandler>#

### Rational#

class sympy.assumptions.predicates.sets.RationalPredicate(*args, **kwargs)[source]#

Rational number predicate.

Explanation

Q.rational(x) is true iff x belongs to the set of rational numbers.

Examples

>>> from sympy import ask, Q, pi, S
True
True
False


Handler

Multiply dispatched method: RationalHandler

Handler for Q.rational.

Test that an expression belongs to the field of rational numbers.

References

R21

https://en.wikipedia.org/wiki/Rational_number

handler = <dispatched RationalHandler>#

### Irrational#

class sympy.assumptions.predicates.sets.IrrationalPredicate(*args, **kwargs)[source]#

Irrational number predicate.

Explanation

Q.irrational(x) is true iff x is any real number that cannot be expressed as a ratio of integers.

Examples

>>> from sympy import ask, Q, pi, S, I
False
False
True
False


Handler

Multiply dispatched method: IrrationalHandler

Handler for Q.irrational.

Test that an expression is irrational numbers.

References

R22

https://en.wikipedia.org/wiki/Irrational_number

handler = <dispatched IrrationalHandler>#

### Real#

class sympy.assumptions.predicates.sets.RealPredicate(*args, **kwargs)[source]#

Real number predicate.

Explanation

Q.real(x) is true iff x is a real number, i.e., it is in the interval $$(-\infty, \infty)$$. Note that, in particular the infinities are not real. Use Q.extended_real if you want to consider those as well.

A few important facts about reals:

• Every real number is positive, negative, or zero. Furthermore,

because these sets are pairwise disjoint, each real number is exactly one of those three.

• Every real number is also complex.

• Every real number is finite.

• Every real number is either rational or irrational.

• Every real number is either algebraic or transcendental.

• The facts Q.negative, Q.zero, Q.positive,

Q.nonnegative, Q.nonpositive, Q.nonzero, Q.integer, Q.rational, and Q.irrational all imply Q.real, as do all facts that imply those facts.

• The facts Q.algebraic, and Q.transcendental do not imply

Q.real; they imply Q.complex. An algebraic or transcendental number may or may not be real.

• The “non” facts (i.e., Q.nonnegative, Q.nonzero,

Q.nonpositive and Q.noninteger) are not equivalent to not the fact, but rather, not the fact and Q.real. For example, Q.nonnegative means ~Q.negative & Q.real. So for example, I is not nonnegative, nonzero, or nonpositive.

Examples

>>> from sympy import Q, ask, symbols
>>> x = symbols('x')
True
True


Handler

Multiply dispatched method: RealHandler

Handler for Q.real.

Test that an expression belongs to the field of real numbers.

References

R23

https://en.wikipedia.org/wiki/Real_number

handler = <dispatched RealHandler>#

### Extended real#

class sympy.assumptions.predicates.sets.ExtendedRealPredicate(*args, **kwargs)[source]#

Extended real predicate.

Explanation

Q.extended_real(x) is true iff x is a real number or $$\{-\infty, \infty\}$$.

See documentation of Q.real for more information about related facts.

Examples

>>> from sympy import ask, Q, oo, I
True
False
True


Handler

Multiply dispatched method: ExtendedRealHandler

Handler for Q.extended_real.

Test that an expression belongs to the field of extended real

numbers, that is real numbers union {Infinity, -Infinity}.

handler = <dispatched ExtendedRealHandler>#

### Hermitian#

class sympy.assumptions.predicates.sets.HermitianPredicate(*args, **kwargs)[source]#

Hermitian predicate.

Explanation

ask(Q.hermitian(x)) is true iff x belongs to the set of Hermitian operators.

Handler

Multiply dispatched method: HermitianHandler

Handler for Q.hermitian.

Test that an expression belongs to the field of Hermitian operators.

References

R24

http://mathworld.wolfram.com/HermitianOperator.html

handler = <dispatched HermitianHandler>#

### Complex#

class sympy.assumptions.predicates.sets.ComplexPredicate(*args, **kwargs)[source]#

Complex number predicate.

Explanation

Q.complex(x) is true iff x belongs to the set of complex numbers. Note that every complex number is finite.

Examples

>>> from sympy import Q, Symbol, ask, I, oo
>>> x = Symbol('x')
True
True
False


Handler

Multiply dispatched method: ComplexHandler

Handler for Q.complex.

Test that an expression belongs to the field of complex numbers.

References

R25

https://en.wikipedia.org/wiki/Complex_number

handler = <dispatched ComplexHandler>#

### Imaginary#

class sympy.assumptions.predicates.sets.ImaginaryPredicate(*args, **kwargs)[source]#

Imaginary number predicate.

Explanation

Q.imaginary(x) is true iff x can be written as a real number multiplied by the imaginary unit I. Please note that 0 is not considered to be an imaginary number.

Examples

>>> from sympy import Q, ask, I
True
False
False


Handler

Multiply dispatched method: ImaginaryHandler

Handler for Q.imaginary.

Test that an expression belongs to the field of imaginary numbers,

that is, numbers in the form x*I, where x is real.

References

R26

https://en.wikipedia.org/wiki/Imaginary_number

handler = <dispatched ImaginaryHandler>#

### Antihermitian#

class sympy.assumptions.predicates.sets.AntihermitianPredicate(*args, **kwargs)[source]#

Antihermitian predicate.

Explanation

Q.antihermitian(x) is true iff x belongs to the field of antihermitian operators, i.e., operators in the form x*I, where x is Hermitian.

Handler

Multiply dispatched method: AntiHermitianHandler

Handler for Q.antihermitian.

Test that an expression belongs to the field of anti-Hermitian

operators, that is, operators in the form x*I, where x is Hermitian.

References

R27

http://mathworld.wolfram.com/HermitianOperator.html

handler = <dispatched AntiHermitianHandler>#

### Algebraic#

class sympy.assumptions.predicates.sets.AlgebraicPredicate(*args, **kwargs)[source]#

Algebraic number predicate.

Explanation

Q.algebraic(x) is true iff x belongs to the set of algebraic numbers. x is algebraic if there is some polynomial in p(x)\in \mathbb\{Q\}[x] such that p(x) = 0.

Examples

>>> from sympy import ask, Q, sqrt, I, pi
True
True
False


Handler

References

R28

https://en.wikipedia.org/wiki/Algebraic_number

AlgebraicHandler = <dispatched AlgebraicHandler>#

### Transcendental#

class sympy.assumptions.predicates.sets.TranscendentalPredicate(*args, **kwargs)[source]#

Transcedental number predicate.

Explanation

Q.transcendental(x) is true iff x belongs to the set of transcendental numbers. A transcendental number is a real or complex number that is not algebraic.

Handler

Multiply dispatched method: Transcendental

Handler for Q.transcendental key.

handler = <dispatched Transcendental>#