FACTOR

This function factors symbolic expressions, typically polynomials, into products of irreducible factors over supported domains.

Factoring finds an equivalent multiplicative form:

f(x) = \prod_i p_i(x)

where each factor p_i(x) is simpler than the original expanded form.

Excel Usage

=FACTOR(expression)
  • expression (str, required): Expression to factor.

Returns (str): String representation of the factored expression.

Example 1: Factor difference of squares

Inputs:

expression
x**2 - 1

Excel formula:

=FACTOR("x**2 - 1")

Expected output:

"(x - 1)*(x + 1)"

Example 2: Factor quadratic polynomial

Inputs:

expression
x**2 + 5*x + 6

Excel formula:

=FACTOR("x**2 + 5*x + 6")

Expected output:

"(x + 2)*(x + 3)"

Example 3: Factor difference of cubes

Inputs:

expression
x**3 - 8

Excel formula:

=FACTOR("x**3 - 8")

Expected output:

"(x - 2)*(x**2 + 2*x + 4)"

Example 4: Factor multivariable expression

Inputs:

expression
x2 - y2

Excel formula:

=FACTOR("x**2 - y**2")

Expected output:

"(x - y)*(x + y)"

Python Code

from sympy import sympify
from sympy import factor as sympy_factor

def factor(expression):
    """
    Factor a symbolic expression into simpler multiplicative terms.

    See: https://docs.sympy.org/latest/modules/polys/reference.html#sympy.polys.polytools.factor

    This example function is provided as-is without any representation of accuracy.

    Args:
        expression (str): Expression to factor.

    Returns:
        str: String representation of the factored expression.
    """
    try:
        normalized_expression = expression.replace("^", "**")
        expr = sympify(normalized_expression)
        result = sympy_factor(expr)
        return str(result)
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Expression to factor.