# Revision history [back]

You can use the numerical_approx functions/methods. Type "help(numerical_approx)" for a full description. It can be called in lots of ways -- too many, probably! -- and you can specify the precision in bits or in decimal digits:

sage: q = sin(2*pi/30)
sage:
sage: numerical_approx(q)
0.207911690817759
sage: q.numerical_approx()
0.207911690817759
sage: q.n()
0.207911690817759
sage:
sage: q.n(prec=100) # bits
0.20791169081775933710174228441
sage: q.n(digits=50) # decimal digits
0.20791169081775933710174228440512516621658476062772


You can also use

sage: n(q)
0.207911690817759
sage: N(q)
0.207911690817759


but I'll be honest, I don't like that very much. I use n and N all the time as variables, so these aren't very useful for me.

You can use the numerical_approx functions/methods. Type "help(numerical_approx)" for a full description. It can be called in lots of ways -- too many, probably! -- and you can specify the precision in bits or in decimal digits:

sage: q = sin(2*pi/30)
sage:
sage: numerical_approx(q)
0.207911690817759
sage: q.numerical_approx()
0.207911690817759
sage: q.n()
0.207911690817759
sage:
sage: q.n(prec=100) # bits
0.20791169081775933710174228441
sage: q.n(digits=50) # decimal digits
0.20791169081775933710174228440512516621658476062772


You can also use

sage: n(q)
0.207911690817759
sage: N(q)
0.207911690817759


but I'll be honest, I don't like that very much. I use n and N all the time as variables, so these aren't very useful for me.

UPDATE:

I should have mentioned another way -- you can often coerce objects from one form to another by calling the desired ring. So these work too:

sage: RR
Real Field with 53 bits of precision
sage: RR(q)
0.207911690817759
sage: RealField(100)
Real Field with 100 bits of precision
sage: RealField(100)(q)
0.20791169081775933710174228441