# castor's profile - activity

 2021-03-13 14:06:23 +0200 received badge ● Popular Question (source) 2020-04-15 18:06:37 +0200 commented answer Interact selector containing card suits Thank you, it is great. Also thanks for the second part. 2020-04-15 15:27:34 +0200 commented question Interact selector containing card suits That is what I looked for. It seems that the code works online using SageMath Cell, but not in Jupyter Notebook. 2020-04-07 11:33:07 +0200 asked a question Interact selector containing card suits I have the following code that used to work in the Python 2 era: @interact def _(S=selector([r"$\diamondsuit$",r"$\heartsuit$",r"$\spadesuit$",r"$\clubsuit$"],default=r"$\diamondsuit$",nrows=1,buttons=True,label="suits")): pretty_print(html(S))  Now it provides. Is there a way to have the expected symbols in the selector? Thank you for your suggestions in advance. OK, it seems to work online using SageMath Cell, in case of Jupyter Notebook I still do not know an answer. 2020-02-01 14:48:21 +0200 received badge ● Commentator 2020-02-01 14:48:21 +0200 commented question SageTeX: sagecommandline problem You are completely right, thank you. In memoire documentclass it works fine, it is the elegantbook documentclass that makes the problem. 2020-01-31 11:51:09 +0200 asked a question SageTeX: sagecommandline problem As a simple example of the problem I have encountered \begin{sagecommandline} sage: M=matrix.identity(6) sage: M sage: v=vector([k for k in [0..5]]) sage: v \end{sagecommandline}  the output looks fine except that the printed matrix $M$ overlaps with the definition of the vector $v.$ Is there a way to add some vertical space below the displayed matrix? 2019-11-08 23:16:28 +0200 received badge ● Necromancer (source) 2019-11-08 22:21:39 +0200 answered a question Solving 3rd degree Diophantine equation in Sage The elliptic curve $E_1: y^2=x^3-x/25+9/125$ is isomorphic to the one $E_2: Y^2=X^3-25X+9\cdot 5^3,$ here we have $X=25x.$ Integral points on $E_1$ are integral points on $E_2.$ The latter can be computed via Sage. E=EllipticCurve([-25,9*5^3]) E.integral_points() [(4 : 33 : 1)]  Hence the only candidates are $(4/25 : \pm 33/125 : 1)$ on your curve. Therefore there are no integral points. 2019-10-22 11:42:14 +0200 commented answer Elliptic curves - morphism Thank you very much, it work well. 2019-10-22 10:04:13 +0200 asked a question Elliptic curves - morphism Consider the example from the documentation: sage: R. = QQ[] sage: Jacobian(u^3+v^3+t, variables=[u,v]) Elliptic Curve defined by y^2 = x^3 + (-27/4*t^2) over Multivariate Polynomial Ring in u, v, t over Rational Field  how to obtain the morphism in this case? 2018-12-25 12:23:45 +0200 received badge ● Nice Answer (source) 2018-01-04 21:51:09 +0200 commented question Changes of variable from quartic to Weierstrass Just a tiny modification of the above code: u,v=polygens(QQ,'u,v') E=Curve(-v^2 + u^4-2*u^3+5*u^2+8*u+4) Jacobian(E, morphism=True)  it yields: Scheme morphism: From: Affine Plane Curve over Rational Field defined by u^4 - 2*u^3 + 5*u^2 - v^2 + 8*u + 4 To: Elliptic Curve defined by y^2 = x^3 - 121/3*x + 1690/27 over Rational Field Defn: Defined on coordinates by sending (u, v) to (7/3*u^4*v + 58/3*u^3*v - 1/3*u^2*v - 88/3*u*v - 8/3*v : -12*u^6 + 12*u^5 + 120*u^4 + 120*u^3 + 180*u^2 + 12*u - 48 : -v^3)  2017-01-25 15:33:28 +0200 commented answer points on elliptic curve Thanks @nbruin for the correction, now using the second suggested test we may go as E=EllipticCurve([0,0,0,-3267,45630]) P=E([51,-108]) F=EllipticCurve([0,27,0,-4077,51705]) Q=F([-57,432]) [(m,n) for m in [1..100] for n in [1..100] if (m*P).xy()[0] == (n*Q).xy()[0]]  the result is simply []. 2017-01-24 22:05:56 +0200 answered a question points on elliptic curve I guess the second point Q is given by [-57,216]. I use it in what follows.  E=EllipticCurve([0,0,0,-3267,45630]) P=E([51,-108]) Q=E([-57,216]) [(m,n) for m in [1..10] for n in [1..10] if (m*P)[0]==(n*Q)[0]]  The result is: [(2, 2), (4, 4), (6, 6), (8, 8), (10, 10)]  e.g. 2P=(339 : 6156 : 1) and 2Q=(339 : -6156 : 1). 2017-01-04 19:30:45 +0200 answered a question FunctionField with more than 1 variable Thank you for the workaround, it helps to compute what I need. There is a small gap at the end, I need to define a polynomial ring over the function field and factor certain polynomials over it. The error message is that it is not implemeted, but I know some factors and I could reduce the problem to a quadratic polynomial. 2017-01-04 15:41:55 +0200 asked a question FunctionField with more than 1 variable I have tried the following to construct an appropriate function field: F.=FunctionField(QQ,2)  as a result I got TypeError: create_key() got multiple values for keyword argument 'names'  after that I looked for the documentation but only find one variable examples. I also tried a few more versions like F.=FunctionField(QQ,names=('a','b'))  but did not work. Thank for any advice in this direction in advance. 2016-11-28 15:13:01 +0200 received badge ● Nice Answer (source) 2016-11-27 19:05:54 +0200 answered a question How to get latex expression in exponential notation? The following may help: P.=LaurentPolynomialRing(QQ,2) u1=J/K latex(u1)  it gives what you need J K^{-1}. 2016-11-27 12:30:33 +0200 marked best answer Strange output using qsub I wrote a Sage code and it works fine on my notebook: nohup < QE.sage > QE.txt & the output file QE.txt looks OK. When I try to use the same code on a cluster using qsub -q test.q QE.sh then the output is ---------------------------------------------------------------------- | Sage Version 5.9, Release Date: 2013-04-30 | | Type "notebook()" for the browser-based notebook interface. | | Type "help()" for help. | ---------------------------------------------------------------------- .[?1034hsage: ....: ....: ....: sage: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ... .: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: .. ..: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: . ...: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: .... : sage: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ... .: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: ....: sage: sage: ....: ....: ....: ....: ....: ....: ....: Exiting Sage (CPU time 0m1.86s, Wall time 0m1.88s).  here QE.sh is as follows #!/bin/sh #$-N QE.sage module load sage sage < QE.sage  Also if I use @parallel() on my notebook, then it works as expected: @parallel(ncpus=2) def szamol(a,b): w=QEllCur([a,b,1]) if w==-1: return "bad input" else: return w W=list(szamol([(a,b) for a in range(-2,3) for b in range(-2,3)])) for X, Y in sorted(W): print X, Y  The CPU time is about 2 sec on my notebook using 2 cores on the cluster using less than 12 cores it prints the first pair and that is it after running (not waiting in the que) more than 2 hours. My questions are: how to get the same output using my code on a (linux) cluster as using it on my (linux) notebook? how to use @parallel() on a cluster? 2016-11-27 12:30:33 +0200 received badge ● Scholar (source) 2016-11-27 12:23:33 +0200 answered a question Constant coefficient of Laurent Polynomials You may try the following: a = var(",".join( "a%i" %i for i in range(0, 7))) R. = LaurentPolynomialRing(SR,2) f = x*y + a6*x + a4*y + x*y^-1 + x^-1*y + a3*y^-1 + a1*x^-1 + x^-1*y^-1 (f/(x^1*y^0)).constant_coefficient()  It gives a6 as you expect and e.g.  (f/(x^0*y^1)).constant_coefficient()  is equal to a4. Also you can determine the coefficient of any monomial: (f/(x^0*y^1)).coefficient(x^-1*y^-2)  is 1. 2016-11-20 22:39:14 +0200 received badge ● Good Answer (source) 2016-11-20 00:07:50 +0200 received badge ● Nice Answer (source) 2016-11-19 23:15:54 +0200 answered a question General power of a matrix? In many cases the following works: A=matrix(SR,[[1,2],[2,1]]) D,P=A.eigenmatrix_right() n=var('n') An=P*matrix(SR,[[D[0,0]^n,0],[0,D[1,1]^n]])*P.inverse() An  Here one obtains An as follows: [1/2*3^n + 1/2*(-1)^n 1/2*3^n - 1/2*(-1)^n] [1/2*3^n - 1/2*(-1)^n 1/2*3^n + 1/2*(-1)^n].  It does not work if the given matrix is not similar to a diagonal matrix. 2016-11-03 17:59:49 +0200 commented answer point addition on elliptic curve In fact I just picked up some points to demonstrate point addition over this domain. As I see now your point Q is given, it is not a general point (X,Y) so I am not sure if you really need this FunctionField stuff. Anyway, you can combine @slelievre code with mine: k. = NumberField(x^4 - 5*x^2 - 32) K. = k.extension(x^2+2) kX.=FunctionField(K) R. = kX[] kY. = kX.extension(Y^2-X^3+3267*X-45630) E=EllipticCurve(kY,[0,0,0,-3267,45630]) P=E(15+36*B, 27*a*(a^2-4*B-5)) Q=E(51,108) P+Q  that provides ((-a^3 + 3*a - 38)*B + 1/2*a^3 - 21/2*a + 7 : (-20*a^3 + 78*a - 58)*B + 11/2*a^3 - 375/2*a - 304 : 1)  and 2*P+Q is a nice point (-57 : 216 ... 2016-11-02 20:58:08 +0200 answered a question point addition on elliptic curve Something that may help: k.=NumberField([x^2 - 30*x + 2817,x^4 + 30*x^3 - 18252*x^2 + 280530*x +6465339]) kX.=FunctionField(k) R. = kX[] kY. = kX.extension(Y^2-X^3+3267*X-45630) E=EllipticCurve(kY,[-3267,45630]) Q=E([X,Y]) P1=E([15,0]) P2=E([1/5184*(-b^3 - 45*b^2 + 14985*b - 133515),0]) print(P1+Q) print(P2+Q)  Here the answer is as follows: ((15*X - 2817)/(X - 15) : ((-2592)/(-X^2 + 30*X - 225))*Y : 1)  and (((-1/5184*b^3 - 5/576*b^2 + 185/64*b - 4945/192)*X + 5/864*b^3 + 25/96*b^2 - 2775/32*b + 114869/32)/(X + 1/5184*b^3 + 5/576*b^2 - 185/64*b + 4945/192) : ((5/576*b^3 + 25/64*b^2 - 8325/64*b + 449151/64)/(-X^2 + (-1/2592*b^3 - 5/288*b^2 + 185/32*b - 4945/96)*X - 5/1728*b^3 - 25/192*b^2 + 2775/64*b - 219413/64))*Y : 1).  2016-10-29 00:15:35 +0200 answered a question Elliptic curve defined with parameter You may try the following K. = FunctionField(GF(5,'a')) E=EllipticCurve([0,u,0,16*u,0])  there are many functions to be applied for your curve E: SageMath Doc. Define a point e.g. and compute the double point: P=E([0,0]) 2*P  To determine some more "small" points on your curve: [E.lift_x(s+t*u, all=True) for s in [0..4] for t in [0..4] if E.is_x_coord(s+t*u)]  which provides: [[(0 : 0 : 1)], [(4*u : 2*u : 1), (4*u : 3*u : 1)], [(4 : 2 : 1), (4 : 3 : 1)]].  2016-10-27 18:53:47 +0200 commented answer programming of looping to print selected value of m Is not x=(121043P-2*P)[0]? 2016-10-27 14:23:50 +0200 answered a question Polynomial ring modulus integer to univariate polynomial ring over the Integers Your code is almost there, probably you need the following: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler f=DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)() R. = PolynomialRing(GF(13)) Y. = R.quotient(X^1024 + 1) Y(f)  Here you obtain 10*t^7 + 5*t^6 + 3*t^4 + 7*t^3 + 12*t^2 + 2*t + 1  2016-10-27 14:14:36 +0200 answered a question programming of looping to print selected value of m You may try something like Qp=pAdicField(13) E=EllipticCurve(Qp,[0,0,0,-3267,45630]) P=E([-21,324]) p=13 #because I am working 13-adically for m in [1..10]: R=12104*m*P S=-2*P Q=R+S x=Q[0] y=Q[1] W=(81*x^16 + 40662*x^15 + 14353281*x^14 - 460241028*x^13 - 644722959186*x^12 + 39379675354740*x^11 + 5212980804862026*x^10 - 415546630058854656*x^9 - 8202010485984353739*x^8 + 1396767997483732402758*x^7 - 27550698906220673513787*x^6 - 1044392234943529703379852*x^5 + 60770398462922893831446348*x^4 - 1284453663719469166478575296*x^3 + 14183844641879715988450074288*x^2 - 81800517874945025246941522368*x + 196162341839727571433321441856)- (3240*x^14 + 456840*x^13 + 188268624*x^12 - 45834271200*x^11 - 2435651997264*x^10 + 682353767281968*x^9 - 7053953405575680*x^8 - 2553415737499629216*x^7 + 98906717445152189544*x^6 + 1348117411901578667784*x^5 - 162666175355778441465360*x^4 + 4276857451171442758058304*x^3 - 54456600108308451946891776*x^2 + 350065581968511893813480064*x - 918312303919436410092339456)*y D=W[0] T=kronecker(D,p) if T == 1: print(m)  but when m=3 you have W=13^-32 + 12*13^-31 + 5*13^-30 + 4*13^-29 + 10*13^-28 + 13^-27 + 10*13^-26 + 8*13^-25 + 3*13^-24 + 11*13^-23 + 11*13^-22 + 9*13^-21 + 12*13^-20 + 4*13^-19 + 6*13^-18 + 13^-17 + O(13^-16)  and D=W[0] will not be defined. The same happens for m=5 also and for many other values I would guess. 2016-10-27 13:45:57 +0200 answered a question change p-adic precision in elliptic curve Your code is pretty close to what you want: Qp=pAdicField(13,4) E=EllipticCurve(Qp,[0,0,0,-3267,45630]); E P=E([-21,324]);P  the answer is (5 + 11*13 + 12*13^2 + 12*13^3 + O(13^4) : 12 + 11*13 + 13^2 + O(13^4) : 1 + O(13^4)).  2016-10-16 22:39:14 +0200 answered a question n-th power of matrices You can find an interactive Sage application here: http://shrek.unideb.hu/~tengely/Magya... the last part is "Mátrixok n-edik hatványának zárt alakja", it is in Hungarian, but the mathematics and Sage command will help I think. In case of your example this code will not work, the eigenvalue 1 has multiplicity larger than 1. To make it work the computation related to the eigenvectors should be modified. At the above page the matrix is given by matrix([[1,2,1],[6,-1,0],[-1,-2,-1]]) and after pushing the "Számolás" button you see the general form of the$n$th power of this matrix. If you have a diagonalizable matrix the above code should do the job. 2016-10-12 18:26:41 +0200 received badge ● Student (source) 2016-10-12 17:40:53 +0200 asked a question Groupring element in pretty_print I have the following code: G37=GroupAlgebra(SymmetricGroup(3),GF(7)) M37=MatrixSpace(G37,2,2) S3=SymmetricGroup(3).list() @interact def _(a11=input_grid(1,6, default = [1,2,0,0,0,0], label='$a_{11}$'),a12=input_grid(1,6, default = [0,1,2,2,3,3], label='$a_{12}$'),a21=input_grid(1,6, default = [0,3,4,2,3,4], label='$a_{21}$'),a22=input_grid(1,6, default = [0,1,1,0,0,0], label='$a_{22}$')): A11=sum([G37(a11[0][k])*G37(S3[k]) for k in [0..5]]) A12=sum([G37(a12[0][k])*G37(S3[k]) for k in [0..5]]) A21=sum([G37(a21[0][k])*G37(S3[k]) for k in [0..5]]) A22=sum([G37(a22[0][k])*G37(S3[k]) for k in [0..5]]) pretty_print(html('$A=%s$'%latex(M37([A11,A12,A21,A22]))))  The first element$A_{11}$appears as$+2(1,2)$instead of$()+2(1,2).$Is it possible to protect the groupring element$()\$ somehow? Thanks for the answers in advance. 2016-10-12 17:23:19 +0200 commented answer solve linear system in GF(7) Completely right, thank you for the comment. 2016-05-30 12:09:20 +0200 commented answer solve linear system in GF(7) It works in the same way: solve_mod(eqns,49)  The result is: [(20, 5, 26, 14, 10, 45)].