1

Can anyone figure out how to fix this error? I want to define z beginning as 1 and update z to 2z everytime. Basically I was z = 1, 2, 4, 8, 16, ....

z := 1;

Successive := procedure(x1,y1,d);

procedure> F := Integers(9986899671513153299302129148204573775860428310315984346586760515456471532627966903385948703);

procedure> for i := 1 to d do

procedure|for> m := F!((3*x1^2)/(2*y1));

procedure|for> x2 := F!((m^2-2*x1));

procedure|for> y2 := F!((m*(x1-x2)-y1));

procedure|for> x1 := x2;

procedure|for> y1 := y2;

procedure|for> z := 2*z;

procedure|for> if z ge d then

procedure|for|if> break;

procedure|for|if> end if;

procedure|for> end for;

procedure> end procedure;

z := 2*z; ^ User error: Imported environment value 'z' cannot be used as a local

  • I changed it to z := 2^(i-1);

    This didn't get an error but z ended up being 1 when I went to print it after it ran.

    – Adam Staples May 07 '14 at 23:35
  • in the procedure, you can add ~z as an argument that is modified. Magma dislikes undeclared side effects. http://magma.maths.usyd.edu.au/magma/handbook/text/23 – Jack Schmidt May 08 '14 at 02:44

1 Answers1

1

Magma does not allow undeclared side effects. No modifying global variables. Procedures explicitly declare which variables they change. See http://magma.maths.usyd.edu.au/magma/handbook/text/23

Here is the fix for the side effects:

Successive := procedure(~x1,~y1,d,~z); 
F := Integers(9986899671513153299302129148204573775860428310315984346586760515456471532627966903385948703);
for i := 1 to d do
m := F!((3*x1^2)/(2*y1));
x2 := F!((m^2-2*x1));
y2 := F!((m*(x1-x2)-y1));
x1 := x2;
y1 := y2;
z := 2*z;
if z ge d then
break;
end if;
end for;
end procedure;
x1:=1;y1:=2;z:=1;
Successive(~x1,~y1,1,~z);z;
Successive(~x1,~y1,1,~z);z;

Results in:

> Successive := procedure(~x1,~y1,d,~z); 
procedure> F := Integers(9986899671513153299302129148204573775860428310315984346586760515456471532627966903385948703);
procedure> for i := 1 to d do
procedure|for> m := F!((3*x1^2)/(2*y1));
procedure|for> x2 := F!((m^2-2*x1));
procedure|for> y2 := F!((m*(x1-x2)-y1));
procedure|for> x1 := x2;
procedure|for> y1 := y2;
procedure|for> z := 2*z;
procedure|for> if z ge d then
procedure|for|if> break;
procedure|for|if> end if;
procedure|for> end for;
procedure> end procedure;
> x1:=1;y1:=2;z:=1;
> Successive(~x1,~y1,1,~z);z;
2
> Successive(~x1,~y1,1,~z);z;
4
Jack Schmidt
  • 55,589