Bill Allombert on Tue, 27 Feb 2007 14:10:12 +0100

 Re: Variable ordering

On Mon, Feb 26, 2007 at 06:32:20AM -0800, William Hart wrote:
>
> So here's the problem. In the function
> toEllipticCurve, the first print statement prints
> something like the following:
>
> u^3 + 6*u^2 + (-17*v + Mod(-17*w + 12, 2*w^3 - 34*w +
> 99))*u + (2*v^3 + Mod(6*w, 2*w^3 - 34*w + 99)*v^2 +
> Mod(6*w^2 - 34, 2*w^3 - 34*w + 99)*v)
>
> As you can see, it is a polynomial in u and v with
> coefficients in Z[w]/(3*w^3+2*w^2+w-1).
>
> Now all I want to do is replace u with U/W and v with
> V/W in this polynomial. I've tried using the Pari
> subst function (with appropriate modifications to the
> code). And I've tried exactly what I've written in the
> program  trace above. But it doesn't work. Here is the
> result:
>
> Mod(6*W^2*V*w^2 + (-17*W^2*U + 6*W*V^2)*w + (U^3 +
> 6*W*U^2 + (-17*W*V + 12*W^2)*U + (2*V^3 - 34*W^2*V)),
> 2*w^3 - 34*w + 99)

You need to create U,V,W before w.  Add at the start of your script
u;v;U;V;W;w;
to ensure that.

Beside you can use substvec(...,[u,v],[U/W,V/W]) which is a bit
more robust than subst(subst(...,u,U/W),v,V/W).

> Now I realise this is a Pari variable order issue, and
> indeed, if I change the order of the Pari variables
> using the reorder command, it works just fine. If I

Do not use reorder() it has been removed in the 2.4 series because