| Hosted by CoCalc | Download
parent(I)
Symbolic Ring
parent(i)
Symbolic Ring
w = x^4 - (1+3*i)*x^3 - (2-4*i)*x^2 + (6-2*i)*x - 4 - 4*i S1=[t.rhs() for t in solve(w,x)];S1 bool(sqrt(2*I)==1+I)
[-1/2*sqrt(2*I) + 3/2*I - 1/2, 1/2*sqrt(2*I) + 3/2*I - 1/2, -I + 1, I + 1] True
S2=[SR(t[0]) for t in w.roots(ring=QQbar)];S2
[-1 + 1*I, 2*I, 1 - 1*I, 1 + 1*I]
bool(sqrt(2*I)==1+I)
True
S1R=[t.subs({sqrt(2*I):1+I}) for t in S1];S1R
[I - 1, 2*I, -I + 1, I + 1]
for i in range(len(S2)): a = S1R[i]; b = S2[i] print i, a print a, parent(a) print b, parent(b) print a - b
0 I - 1 I - 1 Symbolic Ring -1 + 1*I Symbolic Ring
Error in lines 1-6 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 6, in <module> File "sage/structure/element.pyx", line 1667, in sage.structure.element.RingElement.__sub__ (/projects/sage/sage-6.10/src/build/cythonized/sage/structure/element.c:15995) return (<ModuleElement>left)._sub_(<ModuleElement>right) File "sage/symbolic/expression.pyx", line 2949, in sage.symbolic.expression.Expression._sub_ (/projects/sage/sage-6.10/src/build/cythonized/sage/symbolic/expression.cpp:20841) x = gsub(left._gobj, _right._gobj) File "sage/structure/element.pyx", line 1651, in sage.structure.element.RingElement.__add__ (/projects/sage/sage-6.10/src/build/cythonized/sage/structure/element.c:15852) return coercion_model.bin_op(left, right, add) File "sage/structure/coerce.pyx", line 1069, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (/projects/sage/sage-6.10/src/build/cythonized/sage/structure/coerce.c:9736) raise TypeError(arith_error_message(x,y,op)) TypeError: unsupported operand parent(s) for '+': 'Number Field in I with defining polynomial x^2 + 1' and 'Algebraic Field'
parent(b.pyobject())
Algebraic Field
parent(a.pyobject())
Number Field in I with defining polynomial x^2 + 1
parent(I.pyobject())
Number Field in I with defining polynomial x^2 + 1
parent((x^2+1).roots()[0][0].pyobject())
Number Field in I with defining polynomial x^2 + 1
reset() a = (x^2+1).roots(ring=QQbar)[1][0] b = I.pyobject() a, b
(1*I, I)
a + b
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "sage/structure/element.pyx", line 1651, in sage.structure.element.RingElement.__add__ (/projects/sage/sage-6.10/src/build/cythonized/sage/structure/element.c:15852) return coercion_model.bin_op(left, right, add) File "sage/structure/coerce.pyx", line 1069, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (/projects/sage/sage-6.10/src/build/cythonized/sage/structure/coerce.c:9736) raise TypeError(arith_error_message(x,y,op)) TypeError: unsupported operand parent(s) for '+': 'Algebraic Field' and 'Number Field in I with defining polynomial x^2 + 1'
%timeit a+1
625 loops, best of 3: 28.9 µs per loop
%timeit b+1
625 loops, best of 3: 1.19 µs per loop