cortex-js / compute-engine

An engine for symbolic manipulation and numeric evaluation of math formulas expressed with MathJSON
https://cortexjs.io
MIT License
375 stars 47 forks source link

"Integrate" doesn't work #46

Closed smaxx73 closed 1 year ago

smaxx73 commented 2 years ago

This code :

const expr = ce.parse('x^2').json
ce.box(['Integrate', expr, ['Element', 'x', ['Interval', 0, 1]]]).latex
console.log(calculintegrale)

returns \mathrm{Integrate}(x^{2}, x\in )

rs-mobitech commented 1 year ago

+1 - Also hoping this feature could be added.

I would love to be able to work on this myself, but it's way beyond my skill level .

arnog commented 1 year ago
const expr = ce.parse('x^2').json;
const calculintegrale = ce.box([
    'Integrate',
    expr,
    ['Tuple', 'x', 0, 1],
  ]).latex;
console.log(calculintegrale);
// -> \int^{1}_{0}\!x^2\,\mathrm{d}x

Works now. Note that the second argument of "Integrate" is a Tuple of the index variable, the lower bound and the upper bound.