Skip to content

"\ln(constant) × variable" simplifies to "NaN" #259

@AlexEdgcomb

Description

@AlexEdgcomb

Description

The .simplify() method incorrectly returns NaN when simplifying expressions containing \ln(constant) × variable or \log(constant) × variable.

Impacts symbolic computation involving logarithms multiplied with variables, preventing equivalence checking and mathematical operations.

Steps to Reproduce

  1. Go to https://codepen.io/alexedgcomb/pen/jEWvByB?editors=1001 (Compute Engine version: 0.30.2)

Actual Result

Console has:

"Parsed:" "x\ln(8)"
"Simplified:" "\operatorname{NaN}"
"Simplified JSON:" "NaN"
"Simplified:" "\operatorname{NaN}"
"Simplified:" "(2x+9)\times8^{x^2+9x}"

All expressions containing \ln(constant) × variable become NaN during simplification. The pattern fails for any constant: \ln(2), \ln(8), \ln(10), etc. Notably, expressions WITHOUT \ln simplify correctly (Example 3).

Expected Result

Console have:

"Parsed": "x\ln(8)"
"Simplified": "x\ln(8)"  OR  "3x\ln(2)"
"Simplified JSON": ["Multiply", "x", ["Ln", 8]]  OR equivalent
"Simplified": "(2x+9)\ln(8)\times8^{x^2+9x}"  OR simplified form
"Simplified": "(2x+9)\times8^{x^2+9x}"

The expression \ln(constant) × variable is mathematically valid and should either:

  1. Remain as-is during simplification
  2. Be simplified using logarithm laws (e.g., ln(8) = 3ln(2))

Mathematical Context:

  • \ln(8) alone evaluates correctly to 2.0794...
  • \ln(8) × x is a valid symbolic expression
  • Other symbolic math systems (SymPy, Mathematica, Maple) preserve this form or simplify using logarithm properties, never returning NaN

Environment

Regression:

  • Worked: 0.20.2 - 0.25.0
  • Broken: 0.26.0 - 0.30.2

Perhaps related issue: #227 (Canonicalization over-simplifies division) also involves the canonicalization/simplification process producing incorrect results for mathematically valid expressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions