AngouriMath

Navigation

← Back to list of members

Factor​(AngouriMath.​Entity,​AngouriMath.​Entity.​Variable)

 Method (no overloads)

Summary

expr written as a product of powers of polynomials
irreducible over the rationals, or null where that could not
be settled.

Parameter "expr"

The polynomial to factorise.

Parameter "variable"

The variable it is a polynomial in.

Returns

The factorisation; the input itself where it is irreducible over the
rationals, which is an answer and not a refusal; or null where expr is not a polynomial in
variable with rational or polynomial coefficients, or where
the question is past what the factoriser will do.

Remarks

In one variable, Zassenhaus: square-free decomposition, Berlekamp's
factorisation modulo a prime, Hensel lifting to a power of it above Mignotte's
bound, and recombination — and the factors are multiplied back and compared with
the input before they are returned. The degree bound is 32.
In more than one, two things are tried in order. First the content in
variable — the common divisor of the coefficients, which is a
polynomial in the other variables — is taken out. Then whatever remains is
factored by Kronecker's substitution, which writes the exponent vector as a
numeral in mixed radix and reads a one-variable factorisation back. Its ceiling is
a degree budget rather than a variable count: the image has degree the product of
the radices less one, so three variables of degree 2 fit and four do not.
A refusal is possible and a wrong answer is not. Every candidate factor is
checked by exact division before it is kept, and the assembled factors are divided
back into the input.

Example

Console.WriteLine(MathS.Polynomials.Factor("x ^ 4 - 5 * x ^ 2 + 4", "x"));
// (x + 1) * (x + 2) * (x - 2) * (x - 1)
            
Console.WriteLine(MathS.Polynomials.Factor("x ^ 3 - 3 * x ^ 2 + 3 * x - 1", "x"));
// (x - 1) ^ 3
            
Console.WriteLine(MathS.Polynomials.Factor("x ^ 2 + 1", "x"));
// x ^ 2 + 1        -- irreducible over Q, which is an answer
            
Console.WriteLine(MathS.Polynomials.Factor("x * y + y", "x"));
// y * (x + 1)      -- the content in x is taken out first
            
Console.WriteLine(MathS.Polynomials.Factor("x ^ 2 - y ^ 2", "x"));
// (x + y) * (x - y)
            
Console.WriteLine(MathS.Polynomials.Factor("x ^ 12 - y ^ 12", "x") is null);
// True             -- past the substitution's degree budget

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online