# Revision history [back]

The answer of fidbc using list comprehension is all needed. This is a python native solution.

But just to see how versatile sage is, we can use a tacit conversion of the given tuple to a vector over a declared field. (We use the constructor for this class, which is vector.) The field may be RR, reals with default precision, or RealField(100) if we want to set our precision. For the purist, if we really need a tuple back, there is also a conversion back to tuple...

So the one-liner would be tuple( vector( RR, ( sin(1), cos(1), pi/4 ) ) ) . (With or without the conversion to tuple.

Sample code following the same idea:

sage: t = ( sin(1), cos(1), pi/4 )
sage: vector( RR, t )
(0.841470984807897, 0.540302305868140, 0.785398163397448)
sage: type( _ )
<type 'sage.modules.free_module_element.FreeModuleElement_generic_dense'>
sage: tuple( vector( RR, t ) )
(0.841470984807897, 0.540302305868140, 0.785398163397448)
sage: type( _ )
<type 'tuple'>
sage: IR = RealField( 100 )
sage: tuple( vector( IR, t ) )
(0.84147098480789650665250232163,
0.54030230586813971740093660744,
0.78539816339744830961566084582)