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)}(z)=\sum_{k=0}^{\lfloor n/2\rfloor} (-1)^k\frac{\Gamma(n-k+\alpha)}{\Gamma(\alpha)k!(n-2k)!}(2z)^{n-2k}. }

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

Semantic latex: \ultrasphpoly{\alpha}{n}@{z} = \sum_{k=0}^{\floor{n / 2}}(- 1)^k \frac{\Gamma(n-k+\alpha)}{\Gamma(\alpha)k!(n-2k)!}(2 z)^{n-2k}

Confidence: 0.67541445472108

Mathematica

Translation: GegenbauerC[n, \[Alpha], z] == Sum[(- 1)^(k)*Divide[\[CapitalGamma][n - k + \[Alpha]],\[CapitalGamma][\[Alpha]]* (k)!*(n - 2*k)!]*(2*z)^(n - 2*k), {k, 0, Floor[n/2]}, GenerateConditions->None]

Information

Sub Equations

  • GegenbauerC[n, \[Alpha], z] = Sum[(- 1)^(k)*Divide[\[CapitalGamma][n - k + \[Alpha]],\[CapitalGamma][\[Alpha]]* (k)!*(n - 2*k)!]*(2*z)^(n - 2*k), {k, 0, Floor[n/2]}, GenerateConditions->None]

Free variables

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

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

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

  • Floor; Example: \floor{x}

Will be translated to: Floor[$0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/front/introduction#Sx4.p1.t1.r16 Mathematica: https://reference.wolfram.com/language/ref/Floor.html

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

Tests

Symbolic

Test expression: (GegenbauerC[n, \[Alpha], z])-(Sum[(- 1)^(k)*Divide[\[CapitalGamma]*(n - k + \[Alpha]),\[CapitalGamma]*(\[Alpha])*(k)!*(n - 2*k)!]*(2*z)^(n - 2*k), {k, 0, Floor[n/2]}, 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: \ultrasphpoly [\ultrasphpoly]

Tests

Symbolic
Numeric

Maple

Translation: GegenbauerC(n, alpha, z) = sum((- 1)^(k)*(Gamma(n - k + alpha))/(Gamma(alpha)* factorial(k)*factorial(n - 2*k))*(2*z)^(n - 2*k), k = 0..floor(n/2))

Information

Sub Equations

  • GegenbauerC(n, alpha, z) = sum((- 1)^(k)*(Gamma(n - k + alpha))/(Gamma(alpha)* factorial(k)*factorial(n - 2*k))*(2*z)^(n - 2*k), k = 0..floor(n/2))

Free variables

  • Gamma
  • alpha
  • n
  • z

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

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

  • Floor; Example: \floor{x}

Will be translated to: floor($0) Relevant links to definitions: DLMF: http://dlmf.nist.gov/front/introduction#Sx4.p1.t1.r16 Maple: https://www.maplesoft.com/support/help/maple/view.aspx?path=floor

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

Tests

Symbolic
Numeric

Dependency Graph Information

Includes

Complete translation information:

{
  "id" : "FORMULA_820b3cc4c65eb72900257f18225d1e91",
  "formula" : "C_n^{(\\alpha)}(z)=\\sum_{k=0}^{\\lfloor n/2\\rfloor} (-1)^k\\frac{\\Gamma(n-k+\\alpha)}{\\Gamma(\\alpha)k!(n-2k)!}(2z)^{n-2k}",
  "semanticFormula" : "\\ultrasphpoly{\\alpha}{n}@{z} = \\sum_{k=0}^{\\floor{n / 2}}(- 1)^k \\frac{\\Gamma(n-k+\\alpha)}{\\Gamma(\\alpha)k!(n-2k)!}(2 z)^{n-2k}",
  "confidence" : 0.675414454721077,
  "translations" : {
    "Mathematica" : {
      "translation" : "GegenbauerC[n, \\[Alpha], z] == Sum[(- 1)^(k)*Divide[\\[CapitalGamma][n - k + \\[Alpha]],\\[CapitalGamma][\\[Alpha]]* (k)!*(n - 2*k)!]*(2*z)^(n - 2*k), {k, 0, Floor[n/2]}, GenerateConditions->None]",
      "translationInformation" : {
        "subEquations" : [ "GegenbauerC[n, \\[Alpha], z] = Sum[(- 1)^(k)*Divide[\\[CapitalGamma][n - k + \\[Alpha]],\\[CapitalGamma][\\[Alpha]]* (k)!*(n - 2*k)!]*(2*z)^(n - 2*k), {k, 0, Floor[n/2]}, GenerateConditions->None]" ],
        "freeVariables" : [ "\\[Alpha]", "\\[CapitalGamma]", "n", "z" ],
        "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",
          "\\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",
          "\\floor" : "Floor; Example: \\floor{x}\nWill be translated to: Floor[$0]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/front/introduction#Sx4.p1.t1.r16\nMathematica:  https://reference.wolfram.com/language/ref/Floor.html",
          "\\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], z]",
          "rhs" : "Sum[(- 1)^(k)*Divide[\\[CapitalGamma]*(n - k + \\[Alpha]),\\[CapitalGamma]*(\\[Alpha])*(k)!*(n - 2*k)!]*(2*z)^(n - 2*k), {k, 0, Floor[n/2]}, GenerateConditions->None]",
          "testExpression" : "(GegenbauerC[n, \\[Alpha], z])-(Sum[(- 1)^(k)*Divide[\\[CapitalGamma]*(n - k + \\[Alpha]),\\[CapitalGamma]*(\\[Alpha])*(k)!*(n - 2*k)!]*(2*z)^(n - 2*k), {k, 0, Floor[n/2]}, 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: \\ultrasphpoly [\\ultrasphpoly]"
        }
      }
    },
    "Maple" : {
      "translation" : "GegenbauerC(n, alpha, z) = sum((- 1)^(k)*(Gamma(n - k + alpha))/(Gamma(alpha)* factorial(k)*factorial(n - 2*k))*(2*z)^(n - 2*k), k = 0..floor(n/2))",
      "translationInformation" : {
        "subEquations" : [ "GegenbauerC(n, alpha, z) = sum((- 1)^(k)*(Gamma(n - k + alpha))/(Gamma(alpha)* factorial(k)*factorial(n - 2*k))*(2*z)^(n - 2*k), k = 0..floor(n/2))" ],
        "freeVariables" : [ "Gamma", "alpha", "n", "z" ],
        "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",
          "\\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",
          "\\floor" : "Floor; Example: \\floor{x}\nWill be translated to: floor($0)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/front/introduction#Sx4.p1.t1.r16\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=floor",
          "\\Gamma" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary)."
        }
      }
    }
  },
  "positions" : [ {
    "section" : 1,
    "sentence" : 8,
    "word" : 2
  } ],
  "includes" : [ "C_{n}^{(\\alpha)}(x)", "\\alpha", "n" ],
  "isPartOf" : [ ],
  "definiens" : [ ]
}

Specify your own input