From 7d10eb25d7e5e61f56d9f55c64cc136f9c76619a Mon Sep 17 00:00:00 2001 From: RuchitJagodara Date: Fri, 8 Dec 2023 21:47:14 +0530 Subject: [PATCH 1/4] Changed the default domain of SR.var() to complex This is a fix to the issue trac:`36833`. Variables whose domain is not defined should be considered in the complex plane by default as described in the documentation. --- src/sage/symbolic/ring.pyx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx index f3f32b9c922..486cc5689b1 100644 --- a/src/sage/symbolic/ring.pyx +++ b/src/sage/symbolic/ring.pyx @@ -748,7 +748,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): if asm.has(symbol): asm.forget() - def var(self, name, latex_name=None, n=None, domain=None): + def var(self, name, latex_name=None, n=None, domain="complex"): r""" Return a symbolic variable as an element of the symbolic ring. @@ -862,6 +862,16 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): Traceback (most recent call last): ... ValueError: cannot specify n for multiple symbol names + + Check that :trac:`36833` is fixed: Variables whose domain is not + defined should be considered in complex plane as described in documentation:: + + sage: y = SR.var("y"); y + y + sage: f = y * conjugate(y); f + f + sage: f.factor() + y*conjugate(y) """ if isinstance(name, Expression): return name From 6db405d58e13affe5e2da108c967053163de0270 Mon Sep 17 00:00:00 2001 From: RuchitJagodara Date: Wed, 13 Dec 2023 13:31:47 +0530 Subject: [PATCH 2/4] Try domain=real by default for SR.var() function Check whether the default domain=real working or not. --- src/sage/symbolic/ring.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx index 486cc5689b1..c2f9f50afd0 100644 --- a/src/sage/symbolic/ring.pyx +++ b/src/sage/symbolic/ring.pyx @@ -748,7 +748,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): if asm.has(symbol): asm.forget() - def var(self, name, latex_name=None, n=None, domain="complex"): + def var(self, name, latex_name=None, n=None, domain=None): r""" Return a symbolic variable as an element of the symbolic ring. From 4261ff7b1e6cdcbc525504978546b61edf9b8c22 Mon Sep 17 00:00:00 2001 From: RuchitJagodara Date: Tue, 2 Jan 2024 12:20:59 +0530 Subject: [PATCH 3/4] Changed the documentation Changed the documentation of var function. --- src/sage/symbolic/ring.pyx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx index c2f9f50afd0..32d0d5afdd1 100644 --- a/src/sage/symbolic/ring.pyx +++ b/src/sage/symbolic/ring.pyx @@ -760,7 +760,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): - ``n`` -- (optional) positive integer; number of symbolic variables, indexed from `0` to `n-1` - - ``domain`` -- (optional) specify the domain of the variable(s); it is the complex plane + - ``domain`` -- (optional) specify the domain of the variable(s); it is None by default, and possible options are (non-exhaustive list, see note below): ``'real'``, ``'complex'``, ``'positive'``, ``'integer'`` and ``'noninteger'`` @@ -862,16 +862,6 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): Traceback (most recent call last): ... ValueError: cannot specify n for multiple symbol names - - Check that :trac:`36833` is fixed: Variables whose domain is not - defined should be considered in complex plane as described in documentation:: - - sage: y = SR.var("y"); y - y - sage: f = y * conjugate(y); f - f - sage: f.factor() - y*conjugate(y) """ if isinstance(name, Expression): return name From 2877712e564d3a1459e4434280c797af14897939 Mon Sep 17 00:00:00 2001 From: RuchitJagodara Date: Tue, 2 Jan 2024 21:20:19 +0530 Subject: [PATCH 4/4] Changed the documentation --- src/sage/symbolic/ring.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx index 32d0d5afdd1..ba08f9ea239 100644 --- a/src/sage/symbolic/ring.pyx +++ b/src/sage/symbolic/ring.pyx @@ -780,7 +780,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): EXAMPLES: - Create a variable `zz` (complex by default):: + Create a variable `zz`:: sage: zz = SR.var('zz'); zz zz