LaTeX to CAS translator

Jump to navigation Jump to search

This mockup demonstrates the concept of TeX to Computer Algebra System (CAS) conversion.

The demo-application converts LaTeX functions which directly translate to CAS counterparts.

Functions without explicit CAS support are available for translation via a DRMF package (under development).

The following LaTeX input ...

{\displaystyle P_n^{(\alpha,\beta)}(x)= \sum_{s=0}^n {n+\alpha\choose n-s}{n+\beta \choose s} \left(\frac{x-1}{2}\right)^{s} \left(\frac{x+1}{2}\right)^{n-s}}

... is translated to the CAS output ...

Semantic latex: \JacobipolyP{\alpha}{\beta}{n}@{x} = \sum_{s=0}^n{n+\alpha\choose n-s}{n+\beta \choose s}(\frac{x-1}{2})^{s}(\frac{x+1}{2})^{n-s}

Confidence: 0.89530287320794

Mathematica

Translation: JacobiP[n, \[Alpha], \[Beta], x] == Sum[Binomial[n + \[Alpha],n - s]*Binomial[n + \[Beta],s]*(Divide[x - 1,2])^(s)*(Divide[x + 1,2])^(n - s), {s, 0, n}, GenerateConditions->None]

Information

Sub Equations

  • JacobiP[n, \[Alpha], \[Beta], x] = Sum[Binomial[n + \[Alpha],n - s]*Binomial[n + \[Beta],s]*(Divide[x - 1,2])^(s)*(Divide[x + 1,2])^(n - s), {s, 0, n}, GenerateConditions->None]

Free variables

  • \[Alpha]
  • \[Beta]
  • n
  • x

Symbol info

  • Jacobi polynomial; Example: \JacobipolyP{\alpha}{\beta}{n}@{x}

Will be translated to: JacobiP[$2, $0, $1, $3] Relevant links to definitions: DLMF: http://dlmf.nist.gov/18.3#T1.t1.r2 Mathematica: https://reference.wolfram.com/language/ref/JacobiP.html?q=JacobiP

  • Could be the second Feigenbaum constant.

But this system doesn't know how to translate it as a constant. It was translated as a general letter.

Tests

Symbolic

Test expression: (JacobiP[n, \[Alpha], \[Beta], x])-(Sum[Binomial[n + \[Alpha],n - s]*Binomial[n + \[Beta],s]*(Divide[x - 1,2])^(s)*(Divide[x + 1,2])^(n - s), {s, 0, n}, GenerateConditions->None])

ERROR:

{
    "result": "ERROR",
    "testTitle": "Simple",
    "testExpression": null,
    "resultExpression": null,
    "wasAborted": false,
    "conditionallySuccessful": false
}
Numeric

SymPy

Translation: jacobi(n, Symbol('alpha'), Symbol('beta'), x) == Sum(binomial(n + Symbol('alpha'),n - s)*binomial(n + Symbol('beta'),s)*((x - 1)/(2))**(s)*((x + 1)/(2))**(n - s), (s, 0, n))

Information

Sub Equations

  • jacobi(n, Symbol('alpha'), Symbol('beta'), x) = Sum(binomial(n + Symbol('alpha'),n - s)*binomial(n + Symbol('beta'),s)*((x - 1)/(2))**(s)*((x + 1)/(2))**(n - s), (s, 0, n))

Free variables

  • Symbol('alpha')
  • Symbol('beta')
  • n
  • x

Symbol info

  • Jacobi polynomial; Example: \JacobipolyP{\alpha}{\beta}{n}@{x}

Will be translated to: jacobi($2, $0, $1, $3) Relevant links to definitions: DLMF: http://dlmf.nist.gov/18.3#T1.t1.r2 SymPy: https://docs.sympy.org/latest/modules/functions/special.html#jacobi-polynomials

  • Could be the second Feigenbaum constant.

But this system doesn't know how to translate it as a constant. It was translated as a general letter.

Tests

Symbolic
Numeric

Maple

Translation: JacobiP(n, alpha, beta, x) = sum(binomial(n + alpha,n - s)*binomial(n + beta,s)*((x - 1)/(2))^(s)*((x + 1)/(2))^(n - s), s = 0..n)

Information

Sub Equations

  • JacobiP(n, alpha, beta, x) = sum(binomial(n + alpha,n - s)*binomial(n + beta,s)*((x - 1)/(2))^(s)*((x + 1)/(2))^(n - s), s = 0..n)

Free variables

  • alpha
  • beta
  • n
  • x

Symbol info

  • Jacobi polynomial; Example: \JacobipolyP{\alpha}{\beta}{n}@{x}

Will be translated to: JacobiP($2, $0, $1, $3) Relevant links to definitions: DLMF: http://dlmf.nist.gov/18.3#T1.t1.r2 Maple: https://www.maplesoft.com/support/help/maple/view.aspx?path=JacobiP

  • Could be the second Feigenbaum constant.

But this system doesn't know how to translate it as a constant. It was translated as a general letter.

Tests

Symbolic
Numeric

Dependency Graph Information

Includes

Description

  • integer
  • Gamma function
  • Jacobi polynomial

Complete translation information:

{
  "id" : "FORMULA_928ae1a1423003c84cfa0f8765957889",
  "formula" : "P_n^{(\\alpha,\\beta)}(x)= \\sum_{s=0}^n {n+\\alpha\\choose n-s}{n+\\beta \\choose s} \\left(\\frac{x-1}{2}\\right)^{s} \\left(\\frac{x+1}{2}\\right)^{n-s}",
  "semanticFormula" : "\\JacobipolyP{\\alpha}{\\beta}{n}@{x} = \\sum_{s=0}^n{n+\\alpha\\choose n-s}{n+\\beta \\choose s}(\\frac{x-1}{2})^{s}(\\frac{x+1}{2})^{n-s}",
  "confidence" : 0.8953028732079359,
  "translations" : {
    "Mathematica" : {
      "translation" : "JacobiP[n, \\[Alpha], \\[Beta], x] == Sum[Binomial[n + \\[Alpha],n - s]*Binomial[n + \\[Beta],s]*(Divide[x - 1,2])^(s)*(Divide[x + 1,2])^(n - s), {s, 0, n}, GenerateConditions->None]",
      "translationInformation" : {
        "subEquations" : [ "JacobiP[n, \\[Alpha], \\[Beta], x] = Sum[Binomial[n + \\[Alpha],n - s]*Binomial[n + \\[Beta],s]*(Divide[x - 1,2])^(s)*(Divide[x + 1,2])^(n - s), {s, 0, n}, GenerateConditions->None]" ],
        "freeVariables" : [ "\\[Alpha]", "\\[Beta]", "n", "x" ],
        "tokenTranslations" : {
          "\\JacobipolyP" : "Jacobi polynomial; Example: \\JacobipolyP{\\alpha}{\\beta}{n}@{x}\nWill be translated to: JacobiP[$2, $0, $1, $3]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/18.3#T1.t1.r2\nMathematica:  https://reference.wolfram.com/language/ref/JacobiP.html?q=JacobiP",
          "\\alpha" : "Could be the second Feigenbaum constant.\nBut this system doesn't know how to translate it as a constant. It was translated as a general letter.\n"
        }
      },
      "numericResults" : {
        "overallResult" : "SKIPPED",
        "numberOfTests" : 0,
        "numberOfFailedTests" : 0,
        "numberOfSuccessfulTests" : 0,
        "numberOfSkippedTests" : 0,
        "numberOfErrorTests" : 0,
        "wasAborted" : false,
        "crashed" : false,
        "testCalculationsGroups" : [ ]
      },
      "symbolicResults" : {
        "overallResult" : "ERROR",
        "numberOfTests" : 1,
        "numberOfFailedTests" : 0,
        "numberOfSuccessfulTests" : 0,
        "numberOfSkippedTests" : 0,
        "numberOfErrorTests" : 1,
        "crashed" : false,
        "testCalculationsGroup" : [ {
          "lhs" : "JacobiP[n, \\[Alpha], \\[Beta], x]",
          "rhs" : "Sum[Binomial[n + \\[Alpha],n - s]*Binomial[n + \\[Beta],s]*(Divide[x - 1,2])^(s)*(Divide[x + 1,2])^(n - s), {s, 0, n}, GenerateConditions->None]",
          "testExpression" : "(JacobiP[n, \\[Alpha], \\[Beta], x])-(Sum[Binomial[n + \\[Alpha],n - s]*Binomial[n + \\[Beta],s]*(Divide[x - 1,2])^(s)*(Divide[x + 1,2])^(n - s), {s, 0, n}, GenerateConditions->None])",
          "testCalculations" : [ {
            "result" : "ERROR",
            "testTitle" : "Simple",
            "testExpression" : null,
            "resultExpression" : null,
            "wasAborted" : false,
            "conditionallySuccessful" : false
          } ]
        } ]
      }
    },
    "SymPy" : {
      "translation" : "jacobi(n, Symbol('alpha'), Symbol('beta'), x) == Sum(binomial(n + Symbol('alpha'),n - s)*binomial(n + Symbol('beta'),s)*((x - 1)/(2))**(s)*((x + 1)/(2))**(n - s), (s, 0, n))",
      "translationInformation" : {
        "subEquations" : [ "jacobi(n, Symbol('alpha'), Symbol('beta'), x) = Sum(binomial(n + Symbol('alpha'),n - s)*binomial(n + Symbol('beta'),s)*((x - 1)/(2))**(s)*((x + 1)/(2))**(n - s), (s, 0, n))" ],
        "freeVariables" : [ "Symbol('alpha')", "Symbol('beta')", "n", "x" ],
        "tokenTranslations" : {
          "\\JacobipolyP" : "Jacobi polynomial; Example: \\JacobipolyP{\\alpha}{\\beta}{n}@{x}\nWill be translated to: jacobi($2, $0, $1, $3)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/18.3#T1.t1.r2\nSymPy: https://docs.sympy.org/latest/modules/functions/special.html#jacobi-polynomials",
          "\\alpha" : "Could be the second Feigenbaum constant.\nBut this system doesn't know how to translate it as a constant. It was translated as a general letter.\n"
        }
      }
    },
    "Maple" : {
      "translation" : "JacobiP(n, alpha, beta, x) = sum(binomial(n + alpha,n - s)*binomial(n + beta,s)*((x - 1)/(2))^(s)*((x + 1)/(2))^(n - s), s = 0..n)",
      "translationInformation" : {
        "subEquations" : [ "JacobiP(n, alpha, beta, x) = sum(binomial(n + alpha,n - s)*binomial(n + beta,s)*((x - 1)/(2))^(s)*((x + 1)/(2))^(n - s), s = 0..n)" ],
        "freeVariables" : [ "alpha", "beta", "n", "x" ],
        "tokenTranslations" : {
          "\\JacobipolyP" : "Jacobi polynomial; Example: \\JacobipolyP{\\alpha}{\\beta}{n}@{x}\nWill be translated to: JacobiP($2, $0, $1, $3)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/18.3#T1.t1.r2\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=JacobiP",
          "\\alpha" : "Could be the second Feigenbaum constant.\nBut this system doesn't know how to translate it as a constant. It was translated as a general letter.\n"
        }
      }
    }
  },
  "positions" : [ {
    "section" : 3,
    "sentence" : 0,
    "word" : 11
  } ],
  "includes" : [ "x", "P_{n}^{(\\alpha, \\beta)}(x)", "n", "s", "P_{n}^{(\\alpha, \\beta)}", "\\alpha,\\beta" ],
  "isPartOf" : [ ],
  "definiens" : [ {
    "definition" : "integer",
    "score" : 0.7125985104912714
  }, {
    "definition" : "Gamma function",
    "score" : 0.6859086196238077
  }, {
    "definition" : "Jacobi polynomial",
    "score" : 0.6859086196238077
  } ]
}

Specify your own input