Skip to main content
Glama

factor_expression

Factorize algebraic expressions to find roots, simplify rational functions, and analyze stability. Returns factored form with LaTeX for direct use.

Instructions

    Factorize algebraic expression.

    ═══════════════════════════════════════════════════════════════════════
    🆕 PHASE 1 - NOT IN SYMPY-MCP OR NSFORGE v0.2.3!
    ═══════════════════════════════════════════════════════════════════════

    DETERMINISTIC: Always attempts factorization (unlike `simplify()`).

    Use cases:
    - Find roots: x²-1 → (x-1)(x+1) ⇒ roots at x=±1
    - Simplify rational functions
    - Characteristic equations (eigenvalues)
    - Stability analysis (find poles)

    Args:
        expression: Expression to factorize
        deep: Factor recursively into subexpressions (default: False)
        modulus: Modular arithmetic (for finite fields)

    Returns:
        Factored expression with LaTeX

    Examples:
        # Quadratic factorization
        factor_expression("x**2 - 1")
        → {"result": "(x - 1)*(x + 1)", ...}

        # Find roots
        factor_expression("x**2 + 5*x + 6")
        → {"result": "(x + 2)*(x + 3)", ...}

        # Compartment model characteristic equation
        factor_expression("s**2 + (k12 + k21 + k10)*s + k21*k10")
        → {"result": "(s + λ1)*(s + λ2)", ...}  # eigenvalues

        # Rational function numerator
        factor_expression("C**2 - K_m**2")
        → {"result": "(C - K_m)*(C + K_m)", ...}

        # Difference of cubes
        factor_expression("x**3 - 8")
        → {"result": "(x - 2)*(x**2 + 2*x + 4)", ...}
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deepNo
modulusNo
expressionYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the deterministic behavior, the return format ('Factored expression with LaTeX'), and demonstrates output shape through examples. It does not mention error handling, performance, or assumptions about variable domains, but for a pure factorization tool, these are minor gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is somewhat verbose with a banner and multiple examples, but the core purpose is front-loaded. Every example adds value by illustrating different use cases. The structure is logical (purpose, use cases, args, returns, examples), though it could be trimmed slightly without losing substance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity and presence of 60+ siblings, the description adequately covers when and how to use the tool, parameter semantics, and return format. The examples and use cases are sufficient for an agent to select this tool over alternatives. The lack of explicit output schema details is mitigated by the examples.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It explicitly defines all three parameters: expression ('Expression to factorize'), deep ('Factor recursively into subexpressions, default: False'), and modulus ('Modular arithmetic for finite fields'). This adds meaningful semantics beyond the bare schema types and defaults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a clear, specific statement: 'Factorize algebraic expression.' It further distinguishes itself from siblings by noting 'DETERMINISTIC: Always attempts factorization (unlike `simplify()`)' and provides concrete use cases that set it apart from tools like expand_expression or simplify.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description lists specific use cases (find roots, simplify rational functions, characteristic equations, stability analysis) and explicitly contrasts with simplify(). While it does not say 'do not use when...', the context implies when factorization is appropriate, and the comparison to simplify() gives a clear alternative. This is slightly above basic guidance but not exhaustive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/u9401066/nsforge-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server