Subrings of the Symbolic Ring¶
Subrings of the symbolic ring can be created via the
subring()
method of
SR
. This will call SymbolicSubring
of this module.
The following kinds of subrings are supported:
A symbolic subring of expressions, whose variables are contained in a given set of symbolic variables (see
SymbolicSubringAcceptingVars
). E.g.sage: SR.subring(accepting_variables=('a', 'b')) Symbolic Subring accepting the variables a, b
>>> from sage.all import * >>> SR.subring(accepting_variables=('a', 'b')) Symbolic Subring accepting the variables a, b
A symbolic subring of expressions, whose variables are disjoint to a given set of symbolic variables (see
SymbolicSubringRejectingVars
). E.g.sage: SR.subring(rejecting_variables=('r', 's')) Symbolic Subring rejecting the variables r, s
>>> from sage.all import * >>> SR.subring(rejecting_variables=('r', 's')) Symbolic Subring rejecting the variables r, s
The subring of symbolic constants (see
SymbolicConstantsSubring
). E.g.sage: SR.subring(no_variables=True) Symbolic Constants Subring
>>> from sage.all import * >>> SR.subring(no_variables=True) Symbolic Constants Subring
AUTHORS:
Daniel Krenn (2015)
Classes and Methods¶
- class sage.symbolic.subring.GenericSymbolicSubring(vars)[source]¶
Bases:
SymbolicRing
An abstract base class for a symbolic subring.
INPUT:
vars
– tuple of symbolic variables
- has_valid_variable(variable)[source]¶
Return whether the given
variable
is valid in this subring.INPUT:
variable
– a symbolic variable
OUTPUT: boolean
EXAMPLES:
sage: from sage.symbolic.subring import GenericSymbolicSubring sage: GenericSymbolicSubring(vars=tuple()).has_valid_variable(x) Traceback (most recent call last): ... NotImplementedError: Not implemented in this abstract base class
>>> from sage.all import * >>> from sage.symbolic.subring import GenericSymbolicSubring >>> GenericSymbolicSubring(vars=tuple()).has_valid_variable(x) Traceback (most recent call last): ... NotImplementedError: Not implemented in this abstract base class
- class sage.symbolic.subring.GenericSymbolicSubringFunctor(vars)[source]¶
Bases:
ConstructionFunctor
A base class for the functors constructing symbolic subrings.
INPUT:
vars
– tuple, set, or other iterable of symbolic variables
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: SymbolicSubring(no_variables=True).construction()[0] # indirect doctest Subring<accepting no variable>
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> SymbolicSubring(no_variables=True).construction()[Integer(0)] # indirect doctest Subring<accepting no variable>
- coercion_reversed = True¶
- merge(other)[source]¶
Merge this functor with
other
if possible.INPUT:
other
– a functor
OUTPUT: a functor or
None
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: F = SymbolicSubring(accepting_variables=('a',)).construction()[0] sage: F.merge(F) is F True
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> F = SymbolicSubring(accepting_variables=('a',)).construction()[Integer(0)] >>> F.merge(F) is F True
- rank = 11¶
- class sage.symbolic.subring.SymbolicConstantsSubring(vars)[source]¶
Bases:
SymbolicSubringAcceptingVars
The symbolic subring consisting of symbolic constants.
- has_valid_variable(variable)[source]¶
Return whether the given
variable
is valid in this subring.INPUT:
variable
– a symbolic variable
OUTPUT: boolean
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: S = SymbolicSubring(no_variables=True) sage: S.has_valid_variable('a') False sage: S.has_valid_variable('r') False sage: S.has_valid_variable('x') False
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> S = SymbolicSubring(no_variables=True) >>> S.has_valid_variable('a') False >>> S.has_valid_variable('r') False >>> S.has_valid_variable('x') False
- class sage.symbolic.subring.SymbolicSubringAcceptingVars(vars)[source]¶
Bases:
GenericSymbolicSubring
The symbolic subring consisting of symbolic expressions in the given variables.
- construction()[source]¶
Return the functorial construction of this symbolic subring.
OUTPUT:
A tuple whose first entry is a construction functor and its second is the symbolic ring.
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: SymbolicSubring(accepting_variables=('a',)).construction() (Subring<accepting a>, Symbolic Ring)
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> SymbolicSubring(accepting_variables=('a',)).construction() (Subring<accepting a>, Symbolic Ring)
- has_valid_variable(variable)[source]¶
Return whether the given
variable
is valid in this subring.INPUT:
variable
– a symbolic variable
OUTPUT: boolean
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: S = SymbolicSubring(accepting_variables=('a',)) sage: S.has_valid_variable('a') True sage: S.has_valid_variable('r') False sage: S.has_valid_variable('x') False
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> S = SymbolicSubring(accepting_variables=('a',)) >>> S.has_valid_variable('a') True >>> S.has_valid_variable('r') False >>> S.has_valid_variable('x') False
- class sage.symbolic.subring.SymbolicSubringAcceptingVarsFunctor(vars)[source]¶
Bases:
GenericSymbolicSubringFunctor
- merge(other)[source]¶
Merge this functor with
other
if possible.INPUT:
other
– a functor
OUTPUT: a functor or
None
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: F = SymbolicSubring(accepting_variables=('a',)).construction()[0] sage: G = SymbolicSubring(rejecting_variables=('r',)).construction()[0] sage: F.merge(F) is F True sage: F.merge(G) is G True
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> F = SymbolicSubring(accepting_variables=('a',)).construction()[Integer(0)] >>> G = SymbolicSubring(rejecting_variables=('r',)).construction()[Integer(0)] >>> F.merge(F) is F True >>> F.merge(G) is G True
- class sage.symbolic.subring.SymbolicSubringFactory[source]¶
Bases:
UniqueFactory
A factory creating a symbolic subring.
INPUT:
Specify one of the following keywords to create a subring.
accepting_variables
– (default:None
) a tuple or other iterable of variables. If specified, then a symbolic subring of expressions in only these variables is created.rejecting_variables
– (default:None
) a tuple or other iterable of variables. If specified, then a symbolic subring of expressions in variables distinct to these variables is created.no_variables
– boolean (default:False
); if set, then a symbolic subring of constant expressions (i.e., expressions without a variable) is created.
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: V = var('a, b, c, r, s, t, x, y, z')
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> V = var('a, b, c, r, s, t, x, y, z')
sage: A = SymbolicSubring(accepting_variables=(a, b, c)); A Symbolic Subring accepting the variables a, b, c sage: tuple((v, v in A) for v in V) ((a, True), (b, True), (c, True), (r, False), (s, False), (t, False), (x, False), (y, False), (z, False))
>>> from sage.all import * >>> A = SymbolicSubring(accepting_variables=(a, b, c)); A Symbolic Subring accepting the variables a, b, c >>> tuple((v, v in A) for v in V) ((a, True), (b, True), (c, True), (r, False), (s, False), (t, False), (x, False), (y, False), (z, False))
sage: R = SymbolicSubring(rejecting_variables=(r, s, t)); R Symbolic Subring rejecting the variables r, s, t sage: tuple((v, v in R) for v in V) ((a, True), (b, True), (c, True), (r, False), (s, False), (t, False), (x, True), (y, True), (z, True))
>>> from sage.all import * >>> R = SymbolicSubring(rejecting_variables=(r, s, t)); R Symbolic Subring rejecting the variables r, s, t >>> tuple((v, v in R) for v in V) ((a, True), (b, True), (c, True), (r, False), (s, False), (t, False), (x, True), (y, True), (z, True))
sage: C = SymbolicSubring(no_variables=True); C Symbolic Constants Subring sage: tuple((v, v in C) for v in V) ((a, False), (b, False), (c, False), (r, False), (s, False), (t, False), (x, False), (y, False), (z, False))
>>> from sage.all import * >>> C = SymbolicSubring(no_variables=True); C Symbolic Constants Subring >>> tuple((v, v in C) for v in V) ((a, False), (b, False), (c, False), (r, False), (s, False), (t, False), (x, False), (y, False), (z, False))
- create_key_and_extra_args(accepting_variables=None, rejecting_variables=None, no_variables=False, **kwds)[source]¶
Given the arguments and keyword, create a key that uniquely determines this object.
See
SymbolicSubringFactory
for details.
- create_object(version, key, **kwds)[source]¶
Create an object from the given arguments.
See
SymbolicSubringFactory
for details.
- class sage.symbolic.subring.SymbolicSubringRejectingVars(vars)[source]¶
Bases:
GenericSymbolicSubring
The symbolic subring consisting of symbolic expressions whose variables are none of the given variables.
- construction()[source]¶
Return the functorial construction of this symbolic subring.
OUTPUT:
A tuple whose first entry is a construction functor and its second is the symbolic ring.
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: SymbolicSubring(rejecting_variables=('r',)).construction() (Subring<rejecting r>, Symbolic Ring)
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> SymbolicSubring(rejecting_variables=('r',)).construction() (Subring<rejecting r>, Symbolic Ring)
- has_valid_variable(variable)[source]¶
Return whether the given
variable
is valid in this subring.INPUT:
variable
– a symbolic variable
OUTPUT: boolean
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: S = SymbolicSubring(rejecting_variables=('r',)) sage: S.has_valid_variable('a') True sage: S.has_valid_variable('r') False sage: S.has_valid_variable('x') True
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> S = SymbolicSubring(rejecting_variables=('r',)) >>> S.has_valid_variable('a') True >>> S.has_valid_variable('r') False >>> S.has_valid_variable('x') True
- class sage.symbolic.subring.SymbolicSubringRejectingVarsFunctor(vars)[source]¶
Bases:
GenericSymbolicSubringFunctor
- merge(other)[source]¶
Merge this functor with
other
if possible.INPUT:
other
– a functor
OUTPUT: a functor or
None
EXAMPLES:
sage: from sage.symbolic.subring import SymbolicSubring sage: F = SymbolicSubring(accepting_variables=('a',)).construction()[0] sage: G = SymbolicSubring(rejecting_variables=('r',)).construction()[0] sage: G.merge(G) is G True sage: G.merge(F) is G True
>>> from sage.all import * >>> from sage.symbolic.subring import SymbolicSubring >>> F = SymbolicSubring(accepting_variables=('a',)).construction()[Integer(0)] >>> G = SymbolicSubring(rejecting_variables=('r',)).construction()[Integer(0)] >>> G.merge(G) is G True >>> G.merge(F) is G True