Dan Nichols on Tue, 09 Sep 2014 19:43:50 +0200

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

Specialize bivariate FpXY (C library)

Hello PARI users,

Given an FpXY f(x,y) with main variable x and secondary variable y, I want to get the specialization f(r,y) for some r in Fp. It seems like the function I should use is:

GEN FpXY_evaly(GEN Q, GEN y, GEN p, long vy) Q an FpXY, returns the FpX Q(X, y), where
X is the second variable of Q.

I assume vy is supposed to the the variable number for the secondary variable. When I try to call this function, the return value is always 1. For example, the following code
#include "stdio.h"
#include <pari/pari.h>

int main()
    pari_init( 400000000, 0 );
    int y = fetch_user_var( "y" );
    GEN p = utoi( 7 );
    GEN f = gp_read_str( "x^2 + y^2 + x*y + 1" );
    pari_printf( "f(x,y) = %Ps\n", f );
    printf( "gvar( f ) = %li\n", gvar( f ) );
    GEN fx0 = FpXY_evalx( f, gen_0, p );
    pari_printf( "f(x,0) = %Ps\n", fx0 );
    GEN f0y = FpXY_evaly( f, gen_0, p, y );
    pari_printf( "f(0,y) = %Ps\n", f0y );


Produces this output:

f(x,y) = x^2 + y*x + (y^2 + 1)
gvar( f ) = 0
f(x,0) = x^2 + 1
f(0,y) = 1

The last line should be y^2 + 1. Am I using the function correctly? Alternatively, I know I could use the functions gsubst or poleval and then reduce mod p, but wouldn't that be slower? p may be very large and f may have high degree.

Thanks very much,

Dan Nichols