polynomial_gcd

Function polynomial_gcd 

Source
pub fn polynomial_gcd(
    a: &Expression,
    b: &Expression,
    var: &Symbol,
) -> Expression
Expand description

Unified polynomial GCD with automatic type routing

Analyzes coefficient types and routes to optimal implementation:

  • All integers → IntPoly GCD (fastest)
  • Any rationals → RationalPoly GCD (field operations)
  • Symbolic → fallback to Euclidean algorithm

§Arguments

  • a - First polynomial
  • b - Second polynomial
  • var - Variable to treat as polynomial variable

§Example

use mathhook_core::{expr, symbol};
use mathhook_core::core::polynomial::dispatch::polynomial_gcd;

let x = symbol!(x);
let p1 = expr!((x^2) - 1);
let p2 = expr!(x - 1);
let gcd = polynomial_gcd(&p1, &p2, &x);