List of equations in MAGMA

201 Views Asked by At

I have some integer $n$, some ambient affine space $\mathbb{A}^n$, and a list $L$ of equations $f_{ij}$ cutting out a variety $X$ in the ambient space. I have problems defining the list $L$ correctly. My code looks as follows:

  • define the ambient space
  • for i,j in [1..n] define the $f_{ij}$

this works as it should; I get the correct equations. Then (outside the for loop defining the $f_{ij}$) I define my list L by

  • L:=[$f_{ij}$ : i,j in [1..n]];

when I print L, it has the correct number of elements, but all elements are $f_{11}$ rather than the $f_{ij}$. I'm not sure what I'm doing wrong here, naively it looks correct, but maybe I don't properly understand how lists work in MAGMA. Thanks for your help!

Complete code:

Q:=Rationals();

n:=2;

A:=AffineSpace(Q, n^2);

for i,j in [1..n] do

fij := 0;

for k in [1..n] do

fij +:= A.(k+(i-1)*n)*A.(k+(j-1)*n);

end for;

end for;

L:=[fij : i,j in [1..n]];

1

There are 1 best solutions below

1
On BEST ANSWER

In the code you declare a variable called fij but this is only a name to magma, it doesn't know that you want different variables for different i,j so each loop you overwrite fij with the next one and at the end you make a list with this one variable $n^2$ times.

One way to do what you want is to add each f to L as you go along using Append like so:

Q:=Rationals();

n:=2;

L := [];

A:=AffineSpace(Q, n^2);

for i,j in [1..n] do
    f := 0;
    for k in [1..n] do
        f +:= A.(k+(i-1)*n)*A.(k+(j-1)*n);
    end for;
    Append(~L, f);
end for;
print L;