chinrem takes two lists as argument, each list being made of 2 polynomials (either expressions or as a list of coefficients in decreasing order). If the polynomials are expressions, an optional third argument may be provided to specify the main variable, by default x is used. chinrem([A,R],[B,Q]) returns the list of two polynomials P and S such that :
| S=R Q, P=A (mod R ), P=B (mod Q ) |
If R and Q are coprime, a solution P always exists and all the solutions are congruent modulo S=R*Q. For example, assume we want to solve :
|
Input :
Output :
or :
^2+1],[x-1,x^2-1])Output :
^2+x+1/-2,x^4-1]
hence P(x)=−x2−2.x+1/2 (mod x4−1)
Another example, input :
Output :
or :
^2+1],[y+1,y^2+y+1],y)Output :
^3-y^2+1,y^4+y^3+2*y^2+y+1]