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

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

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

Confidence: 0.6805

Mathematica

Translation: Integrate[(GegenbauerC[n, \[Alpha], x])^(2)*(1 - (x)^(2))^(\[Alpha]-Divide[1,2]), {x, - 1, 1}, GenerateConditions->None] == Divide[Pi*(2)^(1 - 2*\[Alpha])* \[CapitalGamma][n + 2*\[Alpha]],(n)!*(n + \[Alpha])*(\[CapitalGamma][\[Alpha]])^(2)]

Information

Sub Equations

  • Integrate[(GegenbauerC[n, \[Alpha], x])^(2)*(1 - (x)^(2))^(\[Alpha]-Divide[1,2]), {x, - 1, 1}, GenerateConditions->None] = Divide[Pi*(2)^(1 - 2*\[Alpha])* \[CapitalGamma][n + 2*\[Alpha]],(n)!*(n + \[Alpha])*(\[CapitalGamma][\[Alpha]])^(2)]

Free variables

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

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

  • Pi was translated to: Pi
  • 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: (Integrate[(GegenbauerC[n, \[Alpha], x])^(2)*(1 - (x)^(2))^(\[Alpha]-Divide[1,2]), {x, - 1, 1}, GenerateConditions->None])-(Divide[Pi*(2)^(1 - 2*\[Alpha])* \[CapitalGamma]*(n + 2*\[Alpha]),(n)!*(n + \[Alpha])*(\[CapitalGamma]*(\[Alpha]))^(2)])

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: int((GegenbauerC(n, alpha, x))^(2)*(1 - (x)^(2))^(alpha -(1)/(2)), x = - 1..1) = (Pi*(2)^(1 - 2*alpha)* Gamma(n + 2*alpha))/(factorial(n)*(n + alpha)*(Gamma(alpha))^(2))

Information

Sub Equations

  • int((GegenbauerC(n, alpha, x))^(2)*(1 - (x)^(2))^(alpha -(1)/(2)), x = - 1..1) = (Pi*(2)^(1 - 2*alpha)* Gamma(n + 2*alpha))/(factorial(n)*(n + alpha)*(Gamma(alpha))^(2))

Free variables

  • Gamma
  • alpha
  • n

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

  • Pi was translated to: Pi
  • 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

Is part of

Complete translation information:

{
  "id" : "FORMULA_d807cf75321a8ce2d34f89336594fd7c",
  "formula" : "\\int_{-1}^1 \\left[C_n^{(\\alpha)}(x)\\right]^2(1-x^2)^{\\alpha-\\frac{1}{2}}dx = \\frac{\\pi 2^{1-2\\alpha}\\Gamma(n+2\\alpha)}{n!(n+\\alpha)[\\Gamma(\\alpha)]^2}",
  "semanticFormula" : "\\int_{-1}^1 [\\ultrasphpoly{\\alpha}{n}@{x}]^2(1 - x^2)^{\\alpha-\\frac{1}{2}} \\diff{x} = \\frac{\\cpi 2^{1-2\\alpha} \\Gamma(n + 2 \\alpha)}{n!(n+\\alpha)[\\Gamma(\\alpha)]^2}",
  "confidence" : 0.6805,
  "translations" : {
    "Mathematica" : {
      "translation" : "Integrate[(GegenbauerC[n, \\[Alpha], x])^(2)*(1 - (x)^(2))^(\\[Alpha]-Divide[1,2]), {x, - 1, 1}, GenerateConditions->None] == Divide[Pi*(2)^(1 - 2*\\[Alpha])* \\[CapitalGamma][n + 2*\\[Alpha]],(n)!*(n + \\[Alpha])*(\\[CapitalGamma][\\[Alpha]])^(2)]",
      "translationInformation" : {
        "subEquations" : [ "Integrate[(GegenbauerC[n, \\[Alpha], x])^(2)*(1 - (x)^(2))^(\\[Alpha]-Divide[1,2]), {x, - 1, 1}, GenerateConditions->None] = Divide[Pi*(2)^(1 - 2*\\[Alpha])* \\[CapitalGamma][n + 2*\\[Alpha]],(n)!*(n + \\[Alpha])*(\\[CapitalGamma][\\[Alpha]])^(2)]" ],
        "freeVariables" : [ "\\[Alpha]", "\\[CapitalGamma]", "n" ],
        "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",
          "\\cpi" : "Pi was translated to: Pi",
          "\\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" : "Integrate[(GegenbauerC[n, \\[Alpha], x])^(2)*(1 - (x)^(2))^(\\[Alpha]-Divide[1,2]), {x, - 1, 1}, GenerateConditions->None]",
          "rhs" : "Divide[Pi*(2)^(1 - 2*\\[Alpha])* \\[CapitalGamma]*(n + 2*\\[Alpha]),(n)!*(n + \\[Alpha])*(\\[CapitalGamma]*(\\[Alpha]))^(2)]",
          "testExpression" : "(Integrate[(GegenbauerC[n, \\[Alpha], x])^(2)*(1 - (x)^(2))^(\\[Alpha]-Divide[1,2]), {x, - 1, 1}, GenerateConditions->None])-(Divide[Pi*(2)^(1 - 2*\\[Alpha])* \\[CapitalGamma]*(n + 2*\\[Alpha]),(n)!*(n + \\[Alpha])*(\\[CapitalGamma]*(\\[Alpha]))^(2)])",
          "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" : "int((GegenbauerC(n, alpha, x))^(2)*(1 - (x)^(2))^(alpha -(1)/(2)), x = - 1..1) = (Pi*(2)^(1 - 2*alpha)* Gamma(n + 2*alpha))/(factorial(n)*(n + alpha)*(Gamma(alpha))^(2))",
      "translationInformation" : {
        "subEquations" : [ "int((GegenbauerC(n, alpha, x))^(2)*(1 - (x)^(2))^(alpha -(1)/(2)), x = - 1..1) = (Pi*(2)^(1 - 2*alpha)* Gamma(n + 2*alpha))/(factorial(n)*(n + alpha)*(Gamma(alpha))^(2))" ],
        "freeVariables" : [ "Gamma", "alpha", "n" ],
        "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",
          "\\cpi" : "Pi was translated to: Pi",
          "\\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" : [ ],
  "includes" : [ "C_{n}^{(\\alpha)}(x)", "\\alpha", "n", "\\int_{-1}^1 \\left[C_n^{(\\alpha)}(x)\\right]^2(1-x^2)^{\\alpha-\\frac{1}{2}}\\,dx = \\frac{\\pi 2^{1-2\\alpha}\\Gamma(n+2\\alpha)}{n!(n+\\alpha)[\\Gamma(\\alpha)]^2}" ],
  "isPartOf" : [ "\\int_{-1}^1 \\left[C_n^{(\\alpha)}(x)\\right]^2(1-x^2)^{\\alpha-\\frac{1}{2}}\\,dx = \\frac{\\pi 2^{1-2\\alpha}\\Gamma(n+2\\alpha)}{n!(n+\\alpha)[\\Gamma(\\alpha)]^2}" ],
  "definiens" : [ ]
}

Specify your own input