Ask Your Question

klx's profile - activity

2021-02-16 14:53:44 +0200 answered a question evaluating inverse erf
def probit(p):
    return (sqrt(2)*erfinv(2*p-1)).n()

print(probit(0.025)) #Wikipedia Verification
print(probit(0.975))

P1 = [] 
for n in xsrange(1,100):
    P1.append( ( n , probit(n/100.0)) )

G1 = point2d(P1,color='blue',pointsize=10)
G1.show()
2021-02-16 13:50:52 +0200 commented answer evaluating inverse erf
2021-02-16 13:47:44 +0200 asked a question probit, erfinv, and inconsistency with Wikipedia

I've used the erfinv

def probit(p):
    return e^(sqrt(2)*erfinv(2*p-1)).n()

print(probit(0.025))
print(probit(0.975))

and outputs

0.140863494093217
7.09907138423134

Wikipedia states that

$\operatorname{probit}(0.025) = -1.96 = -\operatorname{probit}(0.975)$

Interestingly

print(e^(sqrt(2)*erfinv(1/2)).n())

outputs

1.96303108415826

Am I missing a point here?

2021-02-06 13:18:41 +0200 received badge  Enthusiast
2021-01-19 20:28:01 +0200 commented answer Solving symbolic equations to IntegerModRing(26)

[k_1 + 11x2, k_2 + 11x2, k_3, k_4 + 1, x1 + 23*x2, 2]. I've got this as an experiment, what is the value of k_3 and the last 2?

2021-01-19 20:24:05 +0200 commented answer Solving symbolic equations to IntegerModRing(26)

No automatic way form basis to eq.sub?

2021-01-19 20:10:04 +0200 received badge  Commentator
2021-01-19 20:10:04 +0200 commented answer Solving symbolic equations to IntegerModRing(26)

Sorry, $i$ was a typo that takes your time. Is this the only way? I was expecting that the symbolic package can try solve by Gaussian Elimination.

2021-01-19 17:21:56 +0200 asked a question Solving symbolic equations to IntegerModRing(26)

To solve the Hill Cipher a have setup symbolic equations;

R = IntegerModRing(26)
a,b,c,d,x1,x2 = var('k_1,k_2,k_3,k_4,x1,x2')
K = Matrix(SR,[[a,b],[c,d]]); K
print(K)

pl = vector(SR,[1,29])
ci = vector(SR,[8,21])
eq1,eq2 = (K*pl-ci)

pl = vector(SR,[25,22])
ci = vector(SR,[x1,i])
eq3,eq4 = (K*pl-ci)


pl = vector(SR,[7,16])
ci = vector(SR,[x2,19])
eq5,eq6 = (K*pl-ci)

solve((eq1,eq2,eq3,eq4,eq5,eq6), [a,b,c,d,x1,x2])

There is a problem that The symbolic equations are not working modulo 26. For example, the first equation is

k_1 + 29*k_2 - 8

So how can I properly turn them into modulo 26 and solve the equations in modulo 26?

2021-01-16 15:50:02 +0200 commented answer Drawing a line not segment

Sorry, cells mixed! I have put it into a curve defined over GF. Yes, it is working. Thanks.

2021-01-16 10:56:45 +0200 received badge  Notable Question (source)
2021-01-15 23:58:51 +0200 commented answer Drawing a line not segment

PR = (lift(vR - vP)).normalized() is needed and after that TypeError: unsupported operand parent(s) for -: 'Vector space of dimension 2 over Finite Field of size 29' and 'Vector space of dimension 2 over Symbolic Ring' on the last line

2021-01-15 14:37:59 +0200 commented question Drawing a line not segment

@slelievre Thought that was not necessary, here it is.

2021-01-15 13:10:24 +0200 asked a question Drawing a line not segment

I want to draw a line passing through a point P and Q on an elliptic curve.

E = EllipticCurve([0,0,0,4,20])
print(E)
E.plot(xmin=-20, xmax=20, ymin=-20, ymax=20)
plotE = E.plot()
P=E(1,5)
R = - (P + P)
plotE += line([P.xy(),R.xy()],color='red')

Using this only draw a line segment from P to Q. How can I draw a line? I've looked on the doc but did not see an option for this. Any solution?

2020-10-20 21:31:55 +0200 commented answer Multiplicative order of elements in a finite field defined by QuotientRing

Oh, great, thanks.

2020-10-20 20:06:16 +0200 received badge  Popular Question (source)
2020-10-20 20:05:43 +0200 asked a question Multiplicative order of elements in a finite field defined by QuotientRing

I've defined the AES's $\operatorname{GF}(2^8)$ field as follows;

R.<x> = PolynomialRing(GF(2), 'x')
S.<y> = QuotientRing(R, R.ideal(x^8+x^4+x^3+x+1))
S.is_field()

When I added the below and run it

print("y+1 = ",(y+1).multiplicative_order())

I've got this error;

   2671         if not self.is_unit():
-> 2672             raise ArithmeticError("self (=%s) must be a unit to have a multiplicative order.")
  • How one can easily find the multiplicative order?

I've seen this question How to find the multiplicative order of an element in a quotient ring over finite field ? but that is too complex to build. Is there an easy method?

2020-08-27 19:47:03 +0200 commented answer Prevent sage from calculating a function?
2020-08-25 22:44:40 +0200 asked a question finding inverse of en element wiht Ext-GCD fails due to defining polynomial converts zero in function

I'm trying to implement a fast Ext-GCD to find the inverse of an element in the finite field $GF(2^8)$ of AES.

def egcd(a, b):
    print(a)
    print(b)
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b/a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
    gcd = b
    return gcd, x, y


#Base field
R.<y> = PolynomialRing(GF(2), 'y')

#Defining polynomial
G = y^8+y^4+y^3+y+1

#The field extension
S.<x> = QuotientRing(R, R.ideal(G))
S.is_field()

print(egcd(x^8+x^4+x^3+x+1,x^7+x+1))

When the $x^8+x^4+x^3+x+1$ is sent to this function it is converted to zero, so the print(a) prints zero.

Is there a way to protect the variable from converting to zero so that this function can work as intended?

2020-08-19 21:09:43 +0200 commented answer elliptic curve scalar multiplication

Without the $[n \bmod order]G$ check this code will fail as see on Stackoverflow : order of a point is not regular in Hessian Curve implementation

2020-08-18 21:50:50 +0200 commented answer Defining Hessian Curve

OK, This defines a general curve. Now it is hard to use the Elliptic curves over finite fields tools. Is there a way?

2020-08-17 13:05:26 +0200 asked a question Defining Hessian Curve

How do we define a Hessian Curve on SageMath. I've failed to find a source about this. The curve equation is this

$$X^3 + Y^3 + cZ^3 = dXYZ$$ and paremetrazied with $c$ and $d$ over the field $GF(p)$

2019-12-22 18:49:21 +0200 received badge  Supporter (source)
2019-12-18 16:57:13 +0200 received badge  Student (source)
2019-12-12 21:25:27 +0200 received badge  Scholar (source)
2019-12-12 14:43:12 +0200 commented answer Sagemath refuses to load singular curve

The shape of the singular point. Cusp or node. Of course, when drawing over the finite field, we got only point. Should I look at the curve over Q?

2019-12-11 20:41:15 +0200 commented answer Sagemath refuses to load singular curve

When I try to plot, I've the following error NotImplementedError: plotting of curves over Finite Field of size 23981 is not implemented yet

2019-12-10 08:29:34 +0200 edited question Sagemath refuses to load singular curve

I know that this below Elliptic curve is singular at $(23796,0)$

F = GF(23981)
E = EllipticCurve(F,[0, 0, 0, 17230, 22699])

Since

$\frac{\partial f}{\partial x} = 3x^2 + 17230 =0 \pmod p$ and vanishes at $x={185,23796}$ and $(185,0)$ not on the curve.

$\frac{\partial f}{\partial y} = -2y = 0 \pmod p$ and vanishes at $y=0$

I'm trying to define this curve to plot but SageMath gives the error;

ArithmeticError: invariants (0, 0, 0, 17230, 22699) define a singular curve

How can I plot this curve?