Ask Your Question

rburing's profile - activity

2021-04-18 15:32:19 +0200 received badge  Good Answer (source)
2021-04-18 10:04:22 +0200 received badge  Good Answer (source)
2021-04-17 18:36:18 +0200 received badge  Nice Answer (source)
2021-04-17 13:13:18 +0200 received badge  Nice Answer (source)
2021-04-16 19:29:20 +0200 answered a question matrix_plot not returning any outputs in subroutines

The reason is the following: the notebook and command line interface, when they are evaluating input, at the end they al

2021-04-16 19:17:37 +0200 edited answer Cannot evaluate symbolic expression to a numerical value

From the documentation of roots: Return roots of self that can be found exactly, possibly with multiplicities. Not a

2021-04-16 19:16:59 +0200 answered a question Cannot evaluate symbolic expression to a numerical value

From the documentation of roots: Return roots of self that can be found exactly, possibly with multiplicities. Not a

2021-04-13 13:41:02 +0200 received badge  Nice Answer (source)
2021-04-13 11:52:30 +0200 received badge  Necromancer (source)
2021-04-13 10:53:41 +0200 answered a question possible bug: kernel of ring homomorphism

This was a bug which has been fixed in the meantime.

2021-04-13 10:06:24 +0200 received badge  Nice Answer (source)
2021-04-11 13:23:52 +0200 answered a question inequalities in sagemath

I don't know what solve is doing (with inequalities/assumptions), but here your system of polynomial equations has finit

2021-04-08 08:32:15 +0200 commented question "Ratio" of two elements in a ring

You can use the normal basis associated to a Gröbner basis. Please add an example of R.

2021-04-03 08:23:29 +0200 received badge  Good Answer (source)
2021-04-01 11:11:00 +0200 received badge  Nice Answer (source)
2021-04-01 09:04:10 +0200 commented question Why am I getting a type error when I attempt to take the projective closure of this intersection?

The code seems to work as given over here. Have you tried it in the latest version of Sage?

2021-03-24 16:34:53 +0200 answered a question large finite fields with modulus='primitive' do not satisfy equality

You instruct SageMath twice to create a finite field with $2^{n}$ elements with a primitive modulus. Effectively, each t

2021-03-23 07:35:53 +0200 answered a question matrix over symbolic ring to matrix over finite field

In the code you added, the ideal ends up in a univariate polynomial ring over a multivariate polynomial ring, rather tha

2021-03-22 11:59:22 +0200 commented question matrix over symbolic ring to matrix over finite field

Yes, please add a complete block of code that ends in an error. So far, it is not clear how e.g. x_1_2_1 ends up in the

2021-03-21 00:20:50 +0200 received badge  Good Answer (source)
2021-03-13 20:40:39 +0200 edited answer Fraction must have unit denominator when studying Elliptic Curve over complex field?

When you write QQbar['a'] you get a polynomial ring over QQbar with variable named a, so an elliptic curve over QQbar['a

2021-03-13 20:36:57 +0200 answered a question Fraction must have unit denominator when studying Elliptic Curve over complex field?

When you write QQbar['a'] you get a polynomial ring over QQbar with variable named a, so an elliptic curve over QQbar['a

2021-03-08 22:42:55 +0200 commented question Customizing sage objects latex behaviour

For vectors: I don't see a non-hacky way to do it currently, but looking at the implementation of _latex_ with v._latex_

2021-03-03 17:13:21 +0200 commented question Fit model data

Up to a small numerical difference the results are the same, because for the second set of parameters $a^b \approx 2^{1/

2021-02-28 08:40:43 +0200 commented question Ask Sagemath has a new home !

Some dates (e.g. on the front page) display as 0 years ago, which is accurate but not very precise.

2021-02-25 20:32:59 +0200 commented question Evaluate constants in symbolic expression?

Using https://ask.sagemath.org/question/460... you can do SubstituteNumericalApprox()(x(a=1, b=3)).

2021-02-23 09:52:31 +0200 commented question alternative to jupyter notebook?

At least as a workaround you can save and load intermediate results (see the examples there).

2021-02-21 11:39:56 +0200 answered a question Turning a closed subscheme into a point

You can use the rational_points method:

sage: p1.rational_points()
[(1 : 0 : 1)]
sage: p2.rational_points()
[(-1 : 0 : 1)]

By the way, also for points defined over other fields:

sage: A.<x,y> = ProjectiveSpace(QQ,1)
sage: X = A.subscheme(x^2 - 2*y^2)
sage: X.rational_points(F=QQbar)
[(-1.414213562373095? : 1), (1.414213562373095? : 1)]
2021-02-09 15:28:59 +0200 commented question possible bug: kernel of ring homomorphism
2021-02-03 23:21:30 +0200 commented question What is the .sigma() function for an elliptic curve's formal group?

I don't know the answer, but you can view the implementation by entering the following:

sage: E = EllipticCurve('14a')
sage: F = E.formal_group()
sage: F.sigma??

Perhaps something will look familiar.

2021-02-03 19:06:08 +0200 commented question Sage crash when computing variety for an ideal with many variables

Please fix your code so that it works when pasted into https://sagecell.sagemath.org/. Then try I.groebner_basis() instead of I.variety(...) to get some idea about the solutions (the Groebner basis is in particular a system of generators of your ideal).

2021-02-03 19:01:30 +0200 answered a question How to print positive integers that divides a number without a remainder?
sage: divisors(54)
[1, 2, 3, 6, 9, 18, 27, 54]
2021-02-03 02:28:10 +0200 received badge  Nice Answer (source)
2021-02-02 14:15:17 +0200 commented question Sage crash when computing variety for an ideal with many variables

Please make your code self-contained so that it works in a fresh session (e.g. poly is currently not defined). The error you quote is due to the groebner function in Singular choosing a wrong strategy. You could try entering your ideal into Singular and using std (instead of groebner) there.

2021-02-01 09:45:51 +0200 commented answer subs in vector field

Just curious: Couldn't OP's code be made to work? The fact that subs exists while not doing the expected thing is likely to confuse/frustrate users. I've also run into this.

2021-01-22 12:35:43 +0200 commented question when I must declare f= or f(x,y)= ?

The problem is with sgn(SGN); this is an inconsistency / missing feature in Sage, because things like cos(SGN) and log(SGN) work fine. I reported this as trac ticket #31282.

2021-01-20 13:38:07 +0200 answered a question How to index all elements of a finite field?

Using the more standard indexing:

sage: F.<x> = GF(3^5, impl='givaro')
sage: F.fetch_int(4)
x + 1
sage: (x+1).integer_representation()
4
2021-01-20 13:32:46 +0200 commented question How to index all elements of a finite field?

What is the logic behind this indexing? The more usual way is to associate $f(x)$ to $f(p) \in \mathbb{N}$, so $x^2$ corresponds to $9$ and $x+1$ corresponds to $4$.

2021-01-19 19:36:29 +0200 answered a question Solving symbolic equations to IntegerModRing(26)

You can define a polynomial ring over $\mathbb{Z}/26\mathbb{Z}$ with an ideal in it generated by (the left-hand sides of) your equations, and calculate a Groebner basis of it with respect to a lexicographic monomial ordering. This will "triangularize" the system of equations, and if you are lucky you can solve it by successive substitutions. Here is the setup:

R = PolynomialRing(IntegerModRing(26), names='k_1,k_2,k_3,k_4,x1,x2', order='lex')
a,b,c,d,x1,x2 = R.gens()
K = Matrix(R,[[a,b],[c,d]]); K

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

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

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

I = R.ideal([eq1,eq2,eq3,eq4,eq5,eq6])

I replaced $i$ by $-5$ because it will lead to a solution; the other option, i.e. $5$, doesn't.

sage: I.groebner_basis()
[k_1 + 15*x2 + 10, k_2 + 21*x2 + 20, k_3 + 9, k_4 + 16, x1 + 5*x2 + 14]

This can be viewed as a list of equations (set equal to zero). Each of these equations can be solved by putting its first term to the other side (so only x2 remains as an indeterminate). Indeed:

sage: [eq.subs(x1=-5*x2-14,k_4=-16,k_3=-9,k_2=-21*x2-20,k_1=-15*x2-10) for eq in [eq1,eq2,eq3,eq4,eq5,eq6]]
[0, 0, 0, 0, 0, 0]

The system of equations with $i$ replaced by $5$ is unsolvable because the Groebner basis contains the constant $2$, or, if you prefer: because 12*eq2 + 5*eq4 - eq6 evaluates to $2$ in that case.

2021-01-17 16:15:47 +0200 answered a question Determine Two quadratic form is integer congruence (rational equivalent)?

The method is_globally_equivalent_to answers this and provides the matrix:

sage: QA = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: QB = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: X = QA.is_globally_equivalent_to(QB, return_matrix=True); X
[ 0  0  0  1]
[ 0  0  1  0]
[ 0  1  1 -1]
[ 1  1 -1 -1]
sage: X.transpose()*QA.matrix()*X == QB.matrix()
True

This calls the PARI function qfisom, which implements an algorithm of Plesken and Souvignier.

2021-01-04 16:13:59 +0200 answered a question inverse image under ring homomorphism

Thanks for reporting this bug; it is now tracked at trac ticket #31178.

Edit: It was fixed on the same day, and the bugfix has since been merged into SageMath. The first beta that includes this fix is 9.3.beta6, which will be released soon.

2020-12-23 13:47:24 +0200 answered a question How i can create s-box 4 by 4

There is a list of S-Boxes used in cryptographic schemes in the reference manual (including 4x4 ones).

The first one is called Elephant, and can be accessed and used like this:

sage: from sage.crypto.sboxes import sboxes
sage: S = sboxes['Elephant']; S
(14, 13, 11, 0, 2, 1, 4, 15, 7, 10, 8, 5, 9, 12, 3, 6)
sage: S([0,0,0,1])
[1, 1, 0, 1]

You can also create them yourself:

sage: from sage.crypto.sbox import SBox
sage: S = SBox(12,5,6,11,9,0,10,13,3,14,15,8,4,7,1,2)
sage: S.input_size(), S.output_size()
(4, 4)
sage: S([0,0,0,1])
[0, 1, 0, 1]

It is explained on the page S-Boxes and Their Algebraic Representations.

2020-12-22 22:14:10 +0200 answered a question Matrix-scalar and vector-scalar operations

This kind of coercion is documented:

On the other hand, Sage has the notion of a coercion, which is a canonical morphism (occasionally up to a conventional choice made by developers) between parents. A coercion from one parent to another must be defined on the whole domain, and always succeeds. As it may be invoked implicitly, it should be obvious and natural (in both the mathematically rigorous and colloquial sense of the word).

Symbolic expressions can be coerced to symbolic matrices of a fixed size:

sage: B.parent().has_coerce_map_from(SR)
True
sage: cm = sage.structure.element.get_coercion_model()
sage: cm.explain(B, x, operator.add)
Coercion on right operand via
    Coercion map:
      From: Symbolic Ring
      To:   Full MatrixSpace of 3 by 3 dense matrices over Symbolic Ring
Arithmetic performed after coercions.
Result lives in Full MatrixSpace of 3 by 3 dense matrices over Symbolic Ring
Full MatrixSpace of 3 by 3 dense matrices over Symbolic Ring

It is because there is a canonical map, mapping $1$ to the identity matrix, which is a morphism of algebras with basis.

Symbolic expressions cannot be coerced to vectors of a fixed size:

sage: b.parent().has_coerce_map_from(SR)
False

It is because there is no canonical map which is a morphism of modules with basis. Of course there exist morphisms, like the $1 \mapsto (1,1,1)$ you suggest, but that is no better than $1 \mapsto (1,0,0)$ or $1 \mapsto (0,0,1)$. There is no obvious natural choice, so there is no coercion.

2020-12-13 11:54:50 +0200 received badge  Good Answer (source)
2020-12-13 11:10:20 +0200 received badge  Nice Answer (source)