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


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

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
it had major issues.

> Does someone know how to do these kinds of
> substitutions without having to use the Pari reorder
> command, or how to use the reorder command in this
> instance to make it return a correct answer?

You should create your variables in the correct order from the start:
do u;v;U;V;W;w and not u;v;w,U;V;W. We are working on a way to allow
users to declare variables with fixed priority.

Cheers,
Bill.