Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You use inconsistent notations. This :

uz(z,zc)=u.subs(zDic)
vz(z,zc)=v.subs(zDic)

defines uz and vz as *functions` (well... callable symbolic expressions, to be precise).

sage: uz
(z, zc) |--> 1/8*(z + zc)*(z - zc)^2 + 1/4*(z + zc)*(z - zc)
sage: vz
(z, zc) |--> 1/8*(z + zc)^2*(z - zc) - 1/4*(z + zc)*(z - zc)

So is their sum :

sage: uz + vz
(z, zc) |--> 1/8*(z + zc)^2*(z - zc) + 1/8*(z + zc)*(z - zc)^2

So, f can be defined either by defining f1 as a callable symbolic expression returning the sum of two symbolic expressions, which are the values of the calls to uz and vz :

sage: f1(z, zc) = uz(z, zc) + vz(z, zc) ; f1
(z, zc) |--> 1/8*(z + zc)^2*(z - zc) + 1/8*(z + zc)*(z - zc)^2

or defining f2 as the sum of two callable symbolic expressions. which is a callable symbolic expression :

sage: f2 = uz + vz ; f2
(z, zc) |--> 1/8*(z + zc)^2*(z - zc) + 1/8*(z + zc)*(z - zc)^2

but mixing the two syntaxes is inconsistent :

sage: f3(z, zc) = uz + I*vz
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-41-b7d338745ecf> in <module>
----> 1 __tmp__=var("z,zc"); f3 = symbolic_expression(uz + I*vz).function(z,zc)

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__mul__ (build/cythonized/sage/structure/element.c:12319)()
   1514             return (<Element>left)._mul_(right)
   1515         if BOTH_ARE_ELEMENT(cl):
-> 1516             return coercion_model.bin_op(left, right, mul)
   1517 
   1518         cdef long value

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.bin_op (build/cythonized/sage/structure/coerce.c:10754)()
   1198         # Now coerce to a common parent and do the operation there
   1199         try:
-> 1200             xy = self.canonical_coercion(x, y)
   1201         except TypeError:
   1202             self._record_exception()

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.canonical_coercion (build/cythonized/sage/structure/coerce.c:12595)()
   1330                 if x_elt._parent is y_elt._parent:
   1331                     return x_elt,y_elt
-> 1332             self._coercion_error(x, x_map, x_elt, y, y_map, y_elt)
   1333 
   1334         cdef bint x_numeric = isinstance(x, (int, long, float, complex))

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel._coercion_error (build/cythonized/sage/structure/coerce.c:21330)()
   2029             <class 'str'> 'g'
   2030         """
-> 2031         raise RuntimeError("""There is a bug in the coercion code in Sage.
   2032 Both x (=%r) and y (=%r) are supposed to have identical parents but they don't.
   2033 In fact, x has parent '%s'

RuntimeError: There is a bug in the coercion code in Sage.
Both x (=I) and y (=(z, zc) |--> 1/8*(z + zc)^2*(z - zc) - 1/4*(z + zc)*(z - zc)) are supposed to have identical parents but they don't.
In fact, x has parent 'Symbolic Ring'
whereas y has parent 'Callable function ring with arguments (z, zc)'
Original elements I (parent Number Field in I with defining polynomial x^2 + 1 with I = 1*I) and (z, zc) |--> 1/8*(z + zc)^2*(z - zc) - 1/4*(z + zc)*(z - zc) (parent Callable function ring with arguments (z, zc)) and maps
<class 'sage.structure.coerce_maps.DefaultConvertMap_unique'> (map internal to coercion system -- copy before use)
Coercion map:
  From: Number Field in I with defining polynomial x^2 + 1 with I = 1*I
  To:   Callable function ring with arguments (z, zc)
<class 'NoneType'> None

The error message is pretty well descriptive.

What version of Sage are you using ?

HTH,