You can create floating point numbers of arbitrary precision either with:
sage: num(30).numerical_approx(digits=50)
1.1115734242769381168827592197999999999999999999998e28 +
6.2453192824004807120328885095118650594922021093767e-22*I
Or possibly
sage: R = ComplexField(256) # CC with 256 bits of precision
sage: R(num(30))
1.111573424276938116882759219800000000000000000000000000000000000000000000001e28
-
7.319006134094892699321426349537207000071226148996594953870703227692208589824e-48*I
But since your elements are all algebraic and you perform algebraic
operations, I would rather use QQbar or even better UCF
sage: UCF = UniversalCyclotomicField()
sage: z14 = UCF.zeta(14)
sage: z1 = UCF.zeta(14,4)
sage: z2 = UCF.zeta(14,6)
sage: z3 = UCF.zeta(14,8)
sage: z4 = UCF.zeta(14,10)
sage: z5 = UCF.zeta(14,2)
sage: z6 = UCF.zeta(14,12)
sage: num(30)
11115734242769381168827592198
Which is indeed an exact number.
Vincent
On 01/08/16 21:17, saad khalid wrote:
Hello!
So, I run the following code to compute some numbers. They should all
simplify to whole numbers(the imaginary part is 0), and originally I was
using the simplify_full() function to make this happen, however this become
more and more time intensive until, when using it in this case, the
computation for 10 different values of num was taking over a day(and I
don't have that kind of time).
z1 = (e^(2*pi*i/14))^4
z2 = (e^(2*pi*i/14))^6
z3 = (e^(2*pi*i/14))^8
z4 = (e^(2*pi*i/14))^10
z5 = (e^(2*pi*i/14))^2
z6 = (e^(2*pi*i/14))^12
num = lambda k: -z1^k*(z2-1)^(k+1)*(z3-1)^(k+1)*(z4-1)^(k+1)*(z5-1)^(k+1)*(
z6-1)^(k+1) + -z2^k*(z1-1)^(k+1)*(z4-1)^(k+1)*(z3-1)^(k+1)*(z5-1)^(k+1)*(z6-
1)^(k+1) + -z3^k*(z4-1)^(k+1)*(z2-1)^(k+1)*(z1-1)^(k+1)*(z5-1)^(k+1)*(z6-1
)^(k+1) + -z4^k*(z3-1)^(k+1)*(z2-1)^(k+1)*(z1-1)^(k+1)*(z5-1)^(k+1)*(z6-1)^(
k+1) + -z5^k*(z4-1)^(k+1)*(z2-1)^(k+1)*(z1-1)^(k+1)*(z3-1)^(k+1)*(z6-1)^(k+1
) + -z6^k*(z4-1)^(k+1)*(z2-1)^(k+1)*(z1-1)^(k+1)*(z3-1)^(k+1)*(z5-1)^(k+1)
show([(real(CC(num(k)))) for k in [0..40]]
However, I could get the decimal approximations by doing CC(num(i)) for
whatever value of i I want. However, the problem is that this shows that,
by like i >= 10 or so, the imaginary part stops being a small decimal,
which makes me think that there would be even more error in the real part.
I was hoping that I could take the output of the real part and just treat
it as a whole number(by multiplying by 10 to the correct exponent). But,
I'm not sure this gives me the right numbers. I was hoping there was some
way to increase the precision in the decimals. FOr example, in Mathematica,
you can do something like
Re[N[num[40], 100]]
and that gives me 100 decimal points of accuracy. My end goal is to more
quickly approximate these numbers (they're whole numbers, so they should
only take a finite amount of precision). How can I go about getting more
precision here? Thanks!
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.