Skip to content

Compute Engine 0.55.6: toLatex() omits multiplication sign for Multiply(number, Power(number, n)) after substitution #302

@lhotejc

Description

@lhotejc

Contexte
Après substitution numérique, le MathJSON est correct, mais la sérialisation LaTeX peut produire 32^2 au lieu de 3\times2^2.

Version

@cortex-js/compute-engine: 0.55.6
Node: 23.6.0
OS: macOS
Reproduction minimale

import { ComputeEngine } from '@cortex-js/compute-engine'

const ce = new ComputeEngine()

const parsedExpressionX = ce.box(
  ['Add', ['Multiply', 3, ['Power', 'x', 2]], ['Multiply', 5, 'x'], 3],
  { form: 'raw' }
)

const parsedExpression = parsedExpressionX.subs({ x: 2 }, { canonical: false })

console.log('MathJSON before:', JSON.stringify(parsedExpressionX.json))
console.log('MathJSON after :', JSON.stringify(parsedExpression.json))

console.log(
  'LaTeX default:',
  parsedExpression.toLatex()
)

console.log(
  'LaTeX forced :',
  parsedExpression.toLatex({
    form: 'raw',
    implicitMultiplication: false,
    multiplicationSign: '\\times'
  })
)

sortie observée

MathJSON after : ["Add",["Multiply",3,["Power",2,2]],["Multiply",5,2],3]
LaTeX default: 32^2+5\times2+3
LaTeX forced : 32^2+5\times2+3

sortie attendue

3\times2^2+5\times2+3

Notes

Le MathJSON est correct (Multiply(3, Power(2,2))), donc le problème semble venir de la sérialisation LaTeX.
Le bug persiste même avec
[implicitMultiplication: false] et [multiplicationSign: '\\times']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions