Bob Wonderly wrote:
> Using Sage I solved a long list of equations and put the solutions (s) 
> in a list; e.g.:
> 
> sage: for j in range(52,54,1):
>      q = slst[j]
>      j=q[0]; k=(q[1]); s=(q[2])
>      (q,j,k,s)
> .....:
> ([52, 30, 2081203288L], 52, 30, 2081203288L)
> ([53, 53, 17903198518682712L], 53, 53, 17903198518682712L)
> 
> Now I want to plug j and s into the list of y equations so that I can do 
> further calculations involving i. But Sage appears to be getting hung on 
> the s being long:
> 
> sage: for j in range(52,54,1):
>      q = slst[j]
>      j=q[0]; k=(q[1]); s=(q[2])
>      y = 2*(2**k)*i + s
>      (j,k,s,y)
> .....:
> ....
> ....
> TypeError: unsupported operand parent(s) for '+': 'Symbolic Ring' and 
> '<type 'long'>'
> 
> When I take the s out of the equation for y it's OK:
> 
> sage: for j in range(52,54,1):
>      q = slst[j]
>      j=q[0]; k=(q[1]); s=(q[2])
>      y = 2*(2**k)*i
>      (j,k,s,y)
> .....:
> (52, 30, 2081203288L, 2147483648*i)
> (53, 53, 17903198518682712L, 18014398509481984*i)
> 
> FWIW:
> 
> sage: type(j), type(k), type(s), type(y), type(i)
> 
> 
> (<type 'int'>,
>   <type 'int'>,
>   <type 'long'>,
>   <class 'sage.calculus.calculus.SymbolicArithmetic'>,
>   <class 'sage.calculus.calculus.SymbolicVariable'>)
> 
> None of the tricks I tried have convinced Sage and y that s is OK.


Can you try converting s to an element that Sage knows by saying:

y = 2*(2**k)*i + Integer(s)

That said, I reproduced your error with just:

sage: var("b")+long(2)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/grout/sage/devel/sage-main/sage/plot/<ipython console> in <module>()

/home/grout/sage/devel/sage-main/sage/plot/element.pyx in 
sage.structure.element.ModuleElement.__add__ 
(sage/structure/element.c:5748)()

/home/grout/sage/devel/sage-main/sage/plot/coerce.pyx in 
sage.structure.coerce.CoercionModel_cache_maps.bin_op 
(sage/structure/coerce.c:6364)()

TypeError: unsupported operand parent(s) for '+': 'Symbolic Ring' and 
'<type 'long'>'


Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to