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)} (z) = \frac{\Gamma (\alpha+n+1)}{n!\,\Gamma (\alpha+\beta+n+1)} \sum_{m=0}^n {n\choose m} \frac{\Gamma (\alpha + \beta + n + m + 1)}{\Gamma (\alpha + m + 1)} \left(\frac{z-1}{2}\right)^m.}

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

Semantic latex: \JacobipolyP{\alpha}{\beta}{n}@{z} = \frac{\EulerGamma@{\alpha + n + 1}}{n! \EulerGamma@{\alpha + \beta + n + 1}} \sum_{m=0}^n{n\choose m} \frac{\EulerGamma@{\alpha + \beta + n + m + 1}}{\EulerGamma@{\alpha + m + 1}}(\frac{z-1}{2})^m

Confidence: 0.64259245941821

Mathematica

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

Information

Sub Equations

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

Free variables

  • \[Alpha]
  • \[Beta]
  • n
  • z

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.

  • Euler Gamma function; Example: \EulerGamma@{z}

Will be translated to: Gamma[$0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/5.2#E1 Mathematica: https://reference.wolfram.com/language/ref/Gamma.html

Tests

Symbolic

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

ERROR:

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

SymPy

Translation:

Information

Symbol info

  • (LaTeX -> SymPy) No translation possible for given token: Cannot extract information from feature set: \EulerGamma [\EulerGamma]

Tests

Symbolic
Numeric

Maple

Translation: JacobiP(n, alpha, beta, z) = (GAMMA(alpha + n + 1))/(factorial(n)*GAMMA(alpha + beta + n + 1))*sum(binomial(n,m)*(GAMMA(alpha + beta + n + m + 1))/(GAMMA(alpha + m + 1))*((z - 1)/(2))^(m), m = 0..n)

Information

Sub Equations

  • JacobiP(n, alpha, beta, z) = (GAMMA(alpha + n + 1))/(factorial(n)*GAMMA(alpha + beta + n + 1))*sum(binomial(n,m)*(GAMMA(alpha + beta + n + m + 1))/(GAMMA(alpha + m + 1))*((z - 1)/(2))^(m), m = 0..n)

Free variables

  • alpha
  • beta
  • n
  • z

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.

  • Euler Gamma function; Example: \EulerGamma@{z}

Will be translated to: GAMMA($0) Relevant links to definitions: DLMF: http://dlmf.nist.gov/5.2#E1 Maple: https://www.maplesoft.com/support/help/maple/view.aspx?path=GAMMA

Tests

Symbolic
Numeric

Dependency Graph Information

Includes

Is part of

Complete translation information:

{
  "id" : "FORMULA_d1b07572345f7ab922eac9f7afa8e29d",
  "formula" : "P_n^{(\\alpha,\\beta)} (z) = \\frac{\\Gamma (\\alpha+n+1)}{n!\\Gamma (\\alpha+\\beta+n+1)} \\sum_{m=0}^n {n\\choose m} \\frac{\\Gamma (\\alpha + \\beta + n + m + 1)}{\\Gamma (\\alpha + m + 1)} \\left(\\frac{z-1}{2}\\right)^m",
  "semanticFormula" : "\\JacobipolyP{\\alpha}{\\beta}{n}@{z} = \\frac{\\EulerGamma@{\\alpha + n + 1}}{n! \\EulerGamma@{\\alpha + \\beta + n + 1}} \\sum_{m=0}^n{n\\choose m} \\frac{\\EulerGamma@{\\alpha + \\beta + n + m + 1}}{\\EulerGamma@{\\alpha + m + 1}}(\\frac{z-1}{2})^m",
  "confidence" : 0.6425924594182052,
  "translations" : {
    "Mathematica" : {
      "translation" : "JacobiP[n, \\[Alpha], \\[Beta], z] == Divide[Gamma[\\[Alpha]+ n + 1],(n)!*Gamma[\\[Alpha]+ \\[Beta]+ n + 1]]*Sum[Binomial[n,m]*Divide[Gamma[\\[Alpha]+ \\[Beta]+ n + m + 1],Gamma[\\[Alpha]+ m + 1]]*(Divide[z - 1,2])^(m), {m, 0, n}, GenerateConditions->None]",
      "translationInformation" : {
        "subEquations" : [ "JacobiP[n, \\[Alpha], \\[Beta], z] = Divide[Gamma[\\[Alpha]+ n + 1],(n)!*Gamma[\\[Alpha]+ \\[Beta]+ n + 1]]*Sum[Binomial[n,m]*Divide[Gamma[\\[Alpha]+ \\[Beta]+ n + m + 1],Gamma[\\[Alpha]+ m + 1]]*(Divide[z - 1,2])^(m), {m, 0, n}, GenerateConditions->None]" ],
        "freeVariables" : [ "\\[Alpha]", "\\[Beta]", "n", "z" ],
        "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",
          "\\EulerGamma" : "Euler Gamma function; Example: \\EulerGamma@{z}\nWill be translated to: Gamma[$0]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/5.2#E1\nMathematica:  https://reference.wolfram.com/language/ref/Gamma.html"
        }
      },
      "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], z]",
          "rhs" : "Divide[Gamma[\\[Alpha]+ n + 1],(n)!*Gamma[\\[Alpha]+ \\[Beta]+ n + 1]]*Sum[Binomial[n,m]*Divide[Gamma[\\[Alpha]+ \\[Beta]+ n + m + 1],Gamma[\\[Alpha]+ m + 1]]*(Divide[z - 1,2])^(m), {m, 0, n}, GenerateConditions->None]",
          "testExpression" : "(JacobiP[n, \\[Alpha], \\[Beta], z])-(Divide[Gamma[\\[Alpha]+ n + 1],(n)!*Gamma[\\[Alpha]+ \\[Beta]+ n + 1]]*Sum[Binomial[n,m]*Divide[Gamma[\\[Alpha]+ \\[Beta]+ n + m + 1],Gamma[\\[Alpha]+ m + 1]]*(Divide[z - 1,2])^(m), {m, 0, n}, GenerateConditions->None])",
          "testCalculations" : [ {
            "result" : "ERROR",
            "testTitle" : "Simple",
            "testExpression" : null,
            "resultExpression" : null,
            "wasAborted" : false,
            "conditionallySuccessful" : false
          } ]
        } ]
      }
    },
    "SymPy" : {
      "translation" : "",
      "translationInformation" : {
        "tokenTranslations" : {
          "Error" : "(LaTeX -> SymPy) No translation possible for given token: Cannot extract information from feature set: \\EulerGamma [\\EulerGamma]"
        }
      }
    },
    "Maple" : {
      "translation" : "JacobiP(n, alpha, beta, z) = (GAMMA(alpha + n + 1))/(factorial(n)*GAMMA(alpha + beta + n + 1))*sum(binomial(n,m)*(GAMMA(alpha + beta + n + m + 1))/(GAMMA(alpha + m + 1))*((z - 1)/(2))^(m), m = 0..n)",
      "translationInformation" : {
        "subEquations" : [ "JacobiP(n, alpha, beta, z) = (GAMMA(alpha + n + 1))/(factorial(n)*GAMMA(alpha + beta + n + 1))*sum(binomial(n,m)*(GAMMA(alpha + beta + n + m + 1))/(GAMMA(alpha + m + 1))*((z - 1)/(2))^(m), m = 0..n)" ],
        "freeVariables" : [ "alpha", "beta", "n", "z" ],
        "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",
          "\\EulerGamma" : "Euler Gamma function; Example: \\EulerGamma@{z}\nWill be translated to: GAMMA($0)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/5.2#E1\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=GAMMA"
        }
      }
    }
  },
  "positions" : [ ],
  "includes" : [ "z", "n + \\alpha + \\beta", "\\alpha,\\beta", "\\Gamma(z)", "n", "P_{n}^{(\\alpha, \\beta)}", "P_n^{(\\alpha,\\beta)} (z) = \\frac{\\Gamma (\\alpha+n+1)}{n!\\,\\Gamma (\\alpha+\\beta+n+1)} \\sum_{m=0}^n {n\\choose m} \\frac{\\Gamma (\\alpha + \\beta + n + m + 1)}{\\Gamma (\\alpha + m + 1)} \\left(\\frac{z-1}{2}\\right)^m", "P_{n}^{(\\alpha, \\beta)}(x)" ],
  "isPartOf" : [ "P_n^{(\\alpha,\\beta)} (z) = \\frac{\\Gamma (\\alpha+n+1)}{n!\\,\\Gamma (\\alpha+\\beta+n+1)} \\sum_{m=0}^n {n\\choose m} \\frac{\\Gamma (\\alpha + \\beta + n + m + 1)}{\\Gamma (\\alpha + m + 1)} \\left(\\frac{z-1}{2}\\right)^m" ],
  "definiens" : [ ]
}

Specify your own input