The invmod command computes the inverse of A modulo B where A and B are integers or polynomials. If the inverse does not exist then null is returned. In the case of polynomials, the variable X must be specified as the third argument. An optional fourth argument P specifies a modulus for polynomial computations.
# integers invmod(2,5); 3 (2*3) % 5; 1 # polynomials invmod(x+1,x^2+x+1,x); -x # polynomials mod p invmod(x-1,x^2+x+1,x,11); 7*x+3 remainder((x-1)*(7*x+3),x^2+x+1,x,11); 1