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 C_n^{(\alpha)}(x) = \frac{(-1)^n}{2^n n!}\frac{\Gamma(\alpha+\frac{1}{2})\Gamma(n+2\alpha)}{\Gamma(2\alpha)\Gamma(\alpha+n+\frac{1}{2})}(1-x^2)^{-\alpha+1/2}\frac{d^n}{dx^n}\left[(1-x^2)^{n+\alpha-1/2}\right].}

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

Semantic latex: \ultrasphpoly{\alpha}{n}@{x} = \frac{(-1)^n}{2^n n!} \frac{\Gamma(\alpha+\frac{1}{2})\Gamma(n+2\alpha)}{\Gamma(2\alpha)\Gamma(\alpha+n+\frac{1}{2})}(1 - x^2)^{-\alpha+1/2} \deriv [n]{ }{x} [(1 - x^2)^{n+\alpha-1/2}]

Confidence: 0.6805

Mathematica

Translation: GegenbauerC[n, \[Alpha], x] == Divide[(- 1)^(n),(2)^(n)* (n)!]*Divide[\[CapitalGamma][\[Alpha]+Divide[1,2]]* \[CapitalGamma][n + 2*\[Alpha]],\[CapitalGamma][2*\[Alpha]]* \[CapitalGamma][\[Alpha]+ n +Divide[1,2]]]*(1 - (x)^(2))^(- \[Alpha]+ 1/2)* D[(1 - (x)^(2))^(n + \[Alpha]- 1/2), {x, n}]

Information

Sub Equations

  • GegenbauerC[n, \[Alpha], x] = Divide[(- 1)^(n),(2)^(n)* (n)!]*Divide[\[CapitalGamma][\[Alpha]+Divide[1,2]]* \[CapitalGamma][n + 2*\[Alpha]],\[CapitalGamma][2*\[Alpha]]* \[CapitalGamma][\[Alpha]+ n +Divide[1,2]]]*(1 - (x)^(2))^(- \[Alpha]+ 1/2)* D[(1 - (x)^(2))^(n + \[Alpha]- 1/2), {x, n}]

Free variables

  • \[Alpha]
  • \[CapitalGamma]
  • n
  • x

Symbol info

  • Ultraspherical Gegenbauer polynomial; Example: \ultrasphpoly{\lambda}{n}@{x}

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

  • Derivative; Example: \deriv[n]{f}{x}

Will be translated to: D[$1, {$2, $0}] Relevant links to definitions: DLMF: http://dlmf.nist.gov/1.4#E4 Mathematica: https://reference.wolfram.com/language/ref/D.html

  • 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.

  • Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).

Tests

Symbolic

Test expression: (GegenbauerC[n, \[Alpha], x])-(Divide[(- 1)^(n),(2)^(n)* (n)!]*Divide[\[CapitalGamma]*(\[Alpha]+Divide[1,2])*\[CapitalGamma]*(n + 2*\[Alpha]),\[CapitalGamma]*(2*\[Alpha])*\[CapitalGamma]*(\[Alpha]+ n +Divide[1,2])]*(1 - (x)^(2))^(- \[Alpha]+ 1/2)* D[(1 - (x)^(2))^(n + \[Alpha]- 1/2), {x, n}])

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: \ultrasphpoly [\ultrasphpoly]

Tests

Symbolic
Numeric

Maple

Translation: GegenbauerC(n, alpha, x) = ((- 1)^(n))/((2)^(n)* factorial(n))*(Gamma(alpha +(1)/(2))* Gamma(n + 2*alpha))/(Gamma(2*alpha)* Gamma(alpha + n +(1)/(2)))*(1 - (x)^(2))^(- alpha + 1/2)* diff((1 - (x)^(2))^(n + alpha - 1/2), [x$(n)])

Information

Sub Equations

  • GegenbauerC(n, alpha, x) = ((- 1)^(n))/((2)^(n)* factorial(n))*(Gamma(alpha +(1)/(2))* Gamma(n + 2*alpha))/(Gamma(2*alpha)* Gamma(alpha + n +(1)/(2)))*(1 - (x)^(2))^(- alpha + 1/2)* diff((1 - (x)^(2))^(n + alpha - 1/2), [x$(n)])

Free variables

  • Gamma
  • alpha
  • n
  • x

Symbol info

  • Ultraspherical Gegenbauer polynomial; Example: \ultrasphpoly{\lambda}{n}@{x}

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

  • Derivative; Example: \deriv[n]{f}{x}

Will be translated to: diff($1, [$2$($0)]) Relevant links to definitions: DLMF: http://dlmf.nist.gov/1.4#E4 Maple: https://www.maplesoft.com/support/help/Maple/view.aspx?path=diff

  • 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.

  • Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).

Tests

Symbolic
Numeric

Dependency Graph Information

Includes

Description

  • Rodrigues formula

Complete translation information:

{
  "id" : "FORMULA_e99ad97ac29599b3a2d06d92cd1f0d85",
  "formula" : "C_n^{(\\alpha)}(x) = \\frac{(-1)^n}{2^n n!}\\frac{\\Gamma(\\alpha+\\frac{1}{2})\\Gamma(n+2\\alpha)}{\\Gamma(2\\alpha)\\Gamma(\\alpha+n+\\frac{1}{2})}(1-x^2)^{-\\alpha+1/2}\\frac{d^n}{dx^n}\\left[(1-x^2)^{n+\\alpha-1/2}\\right]",
  "semanticFormula" : "\\ultrasphpoly{\\alpha}{n}@{x} = \\frac{(-1)^n}{2^n n!} \\frac{\\Gamma(\\alpha+\\frac{1}{2})\\Gamma(n+2\\alpha)}{\\Gamma(2\\alpha)\\Gamma(\\alpha+n+\\frac{1}{2})}(1 - x^2)^{-\\alpha+1/2} \\deriv [n]{ }{x} [(1 - x^2)^{n+\\alpha-1/2}]",
  "confidence" : 0.6805,
  "translations" : {
    "Mathematica" : {
      "translation" : "GegenbauerC[n, \\[Alpha], x] == Divide[(- 1)^(n),(2)^(n)* (n)!]*Divide[\\[CapitalGamma][\\[Alpha]+Divide[1,2]]* \\[CapitalGamma][n + 2*\\[Alpha]],\\[CapitalGamma][2*\\[Alpha]]* \\[CapitalGamma][\\[Alpha]+ n +Divide[1,2]]]*(1 - (x)^(2))^(- \\[Alpha]+ 1/2)* D[(1 - (x)^(2))^(n + \\[Alpha]- 1/2), {x, n}]",
      "translationInformation" : {
        "subEquations" : [ "GegenbauerC[n, \\[Alpha], x] = Divide[(- 1)^(n),(2)^(n)* (n)!]*Divide[\\[CapitalGamma][\\[Alpha]+Divide[1,2]]* \\[CapitalGamma][n + 2*\\[Alpha]],\\[CapitalGamma][2*\\[Alpha]]* \\[CapitalGamma][\\[Alpha]+ n +Divide[1,2]]]*(1 - (x)^(2))^(- \\[Alpha]+ 1/2)* D[(1 - (x)^(2))^(n + \\[Alpha]- 1/2), {x, n}]" ],
        "freeVariables" : [ "\\[Alpha]", "\\[CapitalGamma]", "n", "x" ],
        "tokenTranslations" : {
          "\\ultrasphpoly" : "Ultraspherical Gegenbauer polynomial; Example: \\ultrasphpoly{\\lambda}{n}@{x}\nWill be translated to: GegenbauerC[$1, $0, $2]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/18.3#T1.t1.r3\nMathematica:  https://reference.wolfram.com/language/ref/GegenbauerC.html",
          "\\deriv1" : "Derivative; Example: \\deriv[n]{f}{x}\nWill be translated to: D[$1, {$2, $0}]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/1.4#E4\nMathematica:  https://reference.wolfram.com/language/ref/D.html",
          "\\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",
          "\\Gamma" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary)."
        }
      },
      "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" : "GegenbauerC[n, \\[Alpha], x]",
          "rhs" : "Divide[(- 1)^(n),(2)^(n)* (n)!]*Divide[\\[CapitalGamma]*(\\[Alpha]+Divide[1,2])*\\[CapitalGamma]*(n + 2*\\[Alpha]),\\[CapitalGamma]*(2*\\[Alpha])*\\[CapitalGamma]*(\\[Alpha]+ n +Divide[1,2])]*(1 - (x)^(2))^(- \\[Alpha]+ 1/2)* D[(1 - (x)^(2))^(n + \\[Alpha]- 1/2), {x, n}]",
          "testExpression" : "(GegenbauerC[n, \\[Alpha], x])-(Divide[(- 1)^(n),(2)^(n)* (n)!]*Divide[\\[CapitalGamma]*(\\[Alpha]+Divide[1,2])*\\[CapitalGamma]*(n + 2*\\[Alpha]),\\[CapitalGamma]*(2*\\[Alpha])*\\[CapitalGamma]*(\\[Alpha]+ n +Divide[1,2])]*(1 - (x)^(2))^(- \\[Alpha]+ 1/2)* D[(1 - (x)^(2))^(n + \\[Alpha]- 1/2), {x, n}])",
          "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: \\ultrasphpoly [\\ultrasphpoly]"
        }
      }
    },
    "Maple" : {
      "translation" : "GegenbauerC(n, alpha, x) = ((- 1)^(n))/((2)^(n)* factorial(n))*(Gamma(alpha +(1)/(2))* Gamma(n + 2*alpha))/(Gamma(2*alpha)* Gamma(alpha + n +(1)/(2)))*(1 - (x)^(2))^(- alpha + 1/2)* diff((1 - (x)^(2))^(n + alpha - 1/2), [x$(n)])",
      "translationInformation" : {
        "subEquations" : [ "GegenbauerC(n, alpha, x) = ((- 1)^(n))/((2)^(n)* factorial(n))*(Gamma(alpha +(1)/(2))* Gamma(n + 2*alpha))/(Gamma(2*alpha)* Gamma(alpha + n +(1)/(2)))*(1 - (x)^(2))^(- alpha + 1/2)* diff((1 - (x)^(2))^(n + alpha - 1/2), [x$(n)])" ],
        "freeVariables" : [ "Gamma", "alpha", "n", "x" ],
        "tokenTranslations" : {
          "\\ultrasphpoly" : "Ultraspherical Gegenbauer polynomial; Example: \\ultrasphpoly{\\lambda}{n}@{x}\nWill be translated to: GegenbauerC($1, $0, $2)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/18.3#T1.t1.r3\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=GegenbauerC",
          "\\deriv1" : "Derivative; Example: \\deriv[n]{f}{x}\nWill be translated to: diff($1, [$2$($0)])\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/1.4#E4\nMaple: https://www.maplesoft.com/support/help/Maple/view.aspx?path=diff",
          "\\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",
          "\\Gamma" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary)."
        }
      }
    }
  },
  "positions" : [ {
    "section" : 1,
    "sentence" : 11,
    "word" : 7
  } ],
  "includes" : [ "C_{n}^{(\\alpha)}(x)", "(1 -x^{2})^{\\alpha-1/2}", "\\alpha", "n", "\\mathbf{R}^{n}" ],
  "isPartOf" : [ ],
  "definiens" : [ {
    "definition" : "Rodrigues formula",
    "score" : 0.722
  } ]
}

Specify your own input