In [1]:
from kh_scrape import scrape_bat
Tknots14 = scrape_bat('khTknotsless14')
At this point, in Sage Math, one may need to declare the variables t
and q
(if one hasn't done so, already). One could try to declare them as generators of a polynomial ring or simply use var
(EY: 20160503 I'm not sure what's the best practice; please let me know. Also with the polynomial ring, I'm not sure which field to use; I'll use the rationals first, QQ
in Sage Math, and possibly one should try the complex numbers CC
(with limited precision, because computers calculate in floats) or real numbers RR
). I'll do the Polynomial Ring below:
In [4]:
PolyRing_QQ_qt = PolynomialRing(QQ,'q,t',2)
# one can also do the below; the problem with this syntax is when someone wants to
# write functions or classes on top of this
# PolyRing_QQ_qt.<q,t> = PolynomialRing(QQ,2)
In [6]:
PolyRing_QQ_qt.<q,t> = PolynomialRing(QQ,2)
In [7]:
Tknots14sage = [ sage_eval(line,locals={'x1':t, 'x2':q}) for line in Tknots14]
In [8]:
Tknots14sage[0]
Out[8]:
In [9]:
latex(Tknots14sage[1].factor())
Out[9]:
$q \cdot (q^{2} + 1) \cdot (q^{6} t^{3} + q^{4} t^{2} + 1)$
If you want to plug in values for q,t
you can't simply do substitute module .subs
: q,t
in the polynomial ring are not variables (i.e. you didn't declare them with var
; e.g. q = var('q')
. See this page, Evaluation of multivariate functions and so we "evaluate" the polynomials "by the arguments" in the parentheses:
In [10]:
Tknots14sage[1](t=1); latex(Tknots14sage[1](t=1))
Out[10]:
$q^{9} + 2 q^{7} + q^{5} + q^{3} + q$
In [11]:
Tknots14sage[1](t=1).factor()
Out[11]:
In [12]:
Tknots14sage[0](q=e**(2*pi*I/6)).simplify()
Out[12]:
In [13]:
for i in range(len(Tknots14sage)): print Tknots14sage[i]
In [26]:
for i in range(len(Tknots14sage)): print Tknots14sage[i], '\n', latex(Tknots14sage[i])
$\frac{q^{2} + 1}{q}$
$q^{9} t^{3} + q^{7} t^{3} + q^{7} t^{2} + q^{5} t^{2} + q^{3} + q$
$q^{15} t^{5} + q^{13} t^{5} + q^{13} t^{4} + q^{11} t^{4} + q^{11} t^{3} + q^{9} t^{3} + q^{9} t^{2} + q^{7} t^{2} + q^{5} + q^{3}$
$q^{21} t^{7} + q^{19} t^{7} + q^{19} t^{6} + q^{17} t^{6} + q^{17} t^{5} + q^{15} t^{5} + q^{15} t^{4} + q^{13} t^{4} + q^{13} t^{3} + q^{11} t^{3} + q^{11} t^{2} + q^{9} t^{2} + q^{7} + q^{5}$
$q^{27} t^{9} + q^{25} t^{9} + q^{25} t^{8} + q^{23} t^{8} + q^{23} t^{7} + q^{21} t^{7} + q^{21} t^{6} + q^{19} t^{6} + q^{19} t^{5} + q^{17} t^{5} + q^{17} t^{4} + q^{15} t^{4} + q^{15} t^{3} + q^{13} t^{3} + q^{13} t^{2} + q^{11} t^{2} + q^{9} + q^{7}$
$q^{33} t^{11} + q^{31} t^{11} + q^{31} t^{10} + q^{29} t^{10} + q^{29} t^{9} + q^{27} t^{9} + q^{27} t^{8} + q^{25} t^{8} + q^{25} t^{7} + q^{23} t^{7} + q^{23} t^{6} + q^{21} t^{6} + q^{21} t^{5} + q^{19} t^{5} + q^{19} t^{4} + q^{17} t^{4} + q^{17} t^{3} + q^{15} t^{3} + q^{15} t^{2} + q^{13} t^{2} + q^{11} + q^{9}$
$q^{39} t^{13} + q^{37} t^{13} + q^{37} t^{12} + q^{35} t^{12} + q^{35} t^{11} + q^{33} t^{11} + q^{33} t^{10} + q^{31} t^{10} + q^{31} t^{9} + q^{29} t^{9} + q^{29} t^{8} + q^{27} t^{8} + q^{27} t^{7} + q^{25} t^{7} + q^{25} t^{6} + q^{23} t^{6} + q^{23} t^{5} + q^{21} t^{5} + q^{21} t^{4} + q^{19} t^{4} + q^{19} t^{3} + q^{17} t^{3} + q^{17} t^{2} + q^{15} t^{2} + q^{13} + q^{11}$
$q^{17} t^{5} + q^{15} t^{5} + q^{13} t^{4} + q^{13} t^{3} + q^{11} t^{4} + q^{11} t^{3} + q^{11} t^{2} + q^{9} t^{2} + q^{7} + q^{5}$
$q^{21} t^{7} + q^{19} t^{7} + q^{19} t^{6} + q^{19} t^{5} + q^{17} t^{6} + q^{17} t^{5} + q^{15} t^{4} + q^{15} t^{3} + q^{13} t^{4} + q^{13} t^{3} + q^{13} t^{2} + q^{11} t^{2} + q^{9} + q^{7}$
In [28]:
theta = var('theta',domain='real')
g = var('g',domain='real')
N = var('N')
# N = var('N','integer')
In [18]:
k = theta*g**2/(2*pi)
In [30]:
q_to_subst = exp( 2*pi*I/(N +k ))
In [34]:
q_to_subst.subs(N==2)
q_to_subst.subs(N==3)
Out[34]:
In [51]:
latex(Tknots14sage[0](q=q_to_subst.subs(N==2)))
Out[51]:
In [49]:
latex(Tknots14sage[0](q=q_to_subst.subs(N==2)).real())
Out[49]:
In [50]:
latex(Tknots14sage[0](q=q_to_subst.subs(N==2)).imag())
Out[50]:
In [52]:
latex( Tknots14sage[1](q=q_to_subst.subs(N==2)) )
Out[52]:
In [53]:
latex( Tknots14sage[1](q=q_to_subst.subs(N==2)).real() )
Out[53]:
In [54]:
latex( Tknots14sage[1](q=q_to_subst.subs(N==2)).imag() )
Out[54]:
In [56]:
latex( Tknots14sage[1](q=q_to_subst.subs(N==2),t=1) )
Out[56]:
In [57]:
latex( Tknots14sage[1](q=q_to_subst.subs(N==2),t=1).real() )
Out[57]:
In [58]:
latex( Tknots14sage[1](q=q_to_subst.subs(N==2),t=1).imag() )
Out[58]:
In [ ]: