gcd
Returns the greatest common divisor of two symbolic expressions when their polynomial structure can be resolved.
Nerdamer preserves common numeric, monomial, univariate, and multivariable polynomial factors. Rational polynomial structure is normalized before the common divisor is computed.
If the supported polynomial methods cannot resolve the inputs, the operation can remain symbolic as gcd(a,b).
Examples
These examples use Nerdamer Notation.
Keep the common numeric and polynomial factor.
gcd(6*(x-1)*(x+2),15*(x-1)*(x^3+1)) // → -3+3*x
Extract a common multivariable monomial.
gcd(x*y*(x+y+1),x*y*(x^2-y+3)) // → x*y
Preserve a common factor containing symbolic parameters.
gcd((x^2+a)*(x^3+1),(x^2+a)*(x^4+b*x+1)) // → x^2+a
Interfaces
The same operation is available through the interfaces below.
Nerdamer Notation
Use this form inside input passed to nerdamer(...).
gcd(arg1, arg2)
nerdamer.gcd
Call the operation through the default nerdamer import.
nerdamer.gcd(x: ExpressionInput, y: ExpressionInput): Expression
Parameters
| Name | Type | Description |
|---|---|---|
x | ExpressionInput | First expression-compatible operand. |
y | ExpressionInput | Second expression-compatible operand. |
Returns
Expression — The exact symbolic GCD or an unevaluated `gcd` expression.
Direct JavaScript / TypeScript API
Import the operation directly from its package entry point.
import { gcd } from 'nerdamer/algebra';
gcd(x: ExpressionInput, y: ExpressionInput): Expression
Parameters
| Name | Type | Description |
|---|---|---|
x | ExpressionInput | First expression-compatible operand. |
y | ExpressionInput | Second expression-compatible operand. |
Returns
Expression — The exact symbolic GCD or an unevaluated `gcd` expression.
