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 \mathbf{H}_\alpha(x) - Y_\alpha(x) = \frac{\left(\frac{x}{2}\right)^{\alpha-1}}{\sqrt{\pi} \Gamma \left (\alpha+\frac{1}{2} \right )} + O\left(\left (\tfrac{x}{2}\right)^{\alpha-3}\right),}

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

Semantic latex: \StruveH{\alpha}@{x} - \BesselY{\alpha}@{x} = \frac{(\frac{x}{2})^{\alpha-1}}{\sqrt{\cpi} \EulerGamma@{\alpha + \frac{1}{2}}} + O((\tfrac{x}{2})^{\alpha-3})

Confidence: 0.67074419509453

Mathematica

Translation: StruveH[\[Alpha], x]- BesselY[\[Alpha], x] == Divide[(Divide[x,2])^(\[Alpha]- 1),Sqrt[Pi]*Gamma[\[Alpha]+Divide[1,2]]]+ O[(Divide[x,2])^(\[Alpha]- 3)]

Information

Sub Equations

  • StruveH[\[Alpha], x]- BesselY[\[Alpha], x] = Divide[(Divide[x,2])^(\[Alpha]- 1),Sqrt[Pi]*Gamma[\[Alpha]+Divide[1,2]]]+ O[(Divide[x,2])^(\[Alpha]- 3)]

Free variables

  • \[Alpha]
  • x

Symbol info

  • Bessel function second kind; Example: \BesselY{v}@{z}

Will be translated to: BesselY[$0, $1] Branch Cuts: (-\infty, 0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/10.2#E3 Mathematica: https://reference.wolfram.com/language/ref/BesselY.html

  • Struve function; Example: \StruveH{\nu}@{z}

Will be translated to: StruveH[$0, $1] Relevant links to definitions: DLMF: http://dlmf.nist.gov/11.2#E1 Mathematica: https://reference.wolfram.com/language/ref/StruveH.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).
  • 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: (StruveH[\[Alpha], x]- BesselY[\[Alpha], x])-(Divide[(Divide[x,2])^(\[Alpha]- 1),Sqrt[Pi]*Gamma[\[Alpha]+Divide[1,2]]]+ O*((Divide[x,2])^(\[Alpha]- 3)))

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

Tests

Symbolic
Numeric

Maple

Translation: StruveH(alpha, x)- BesselY(alpha, x) = (((x)/(2))^(alpha - 1))/(sqrt(Pi)*GAMMA(alpha +(1)/(2)))+ O(((x)/(2))^(alpha - 3))

Information

Sub Equations

  • StruveH(alpha, x)- BesselY(alpha, x) = (((x)/(2))^(alpha - 1))/(sqrt(Pi)*GAMMA(alpha +(1)/(2)))+ O(((x)/(2))^(alpha - 3))

Free variables

  • alpha
  • x

Symbol info

  • Bessel function second kind; Example: \BesselY{v}@{z}

Will be translated to: BesselY($0, $1) Branch Cuts: (-\infty, 0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/10.2#E3 Maple: https://www.maplesoft.com/support/help/maple/view.aspx?path=Bessel

  • Struve function; Example: \StruveH{\nu}@{z}

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

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

Description

  • Neumann function

Complete translation information:

{
  "id" : "FORMULA_f545056d7b45235ee294695b71a9b568",
  "formula" : "\\mathbf{H}_\\alpha(x) - Y_\\alpha(x) = \\frac{\\left(\\frac{x}{2}\\right)^{\\alpha-1}}{\\sqrt{\\pi} \\Gamma \\left (\\alpha+\\frac{1}{2} \\right )} + O\\left(\\left (\\tfrac{x}{2}\\right)^{\\alpha-3}\\right)",
  "semanticFormula" : "\\StruveH{\\alpha}@{x} - \\BesselY{\\alpha}@{x} = \\frac{(\\frac{x}{2})^{\\alpha-1}}{\\sqrt{\\cpi} \\EulerGamma@{\\alpha + \\frac{1}{2}}} + O((\\tfrac{x}{2})^{\\alpha-3})",
  "confidence" : 0.670744195094534,
  "translations" : {
    "Mathematica" : {
      "translation" : "StruveH[\\[Alpha], x]- BesselY[\\[Alpha], x] == Divide[(Divide[x,2])^(\\[Alpha]- 1),Sqrt[Pi]*Gamma[\\[Alpha]+Divide[1,2]]]+ O[(Divide[x,2])^(\\[Alpha]- 3)]",
      "translationInformation" : {
        "subEquations" : [ "StruveH[\\[Alpha], x]- BesselY[\\[Alpha], x] = Divide[(Divide[x,2])^(\\[Alpha]- 1),Sqrt[Pi]*Gamma[\\[Alpha]+Divide[1,2]]]+ O[(Divide[x,2])^(\\[Alpha]- 3)]" ],
        "freeVariables" : [ "\\[Alpha]", "x" ],
        "tokenTranslations" : {
          "\\BesselY" : "Bessel function second kind; Example: \\BesselY{v}@{z}\nWill be translated to: BesselY[$0, $1]\nBranch Cuts: (-\\infty, 0]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/10.2#E3\nMathematica:  https://reference.wolfram.com/language/ref/BesselY.html",
          "\\StruveH" : "Struve function; Example: \\StruveH{\\nu}@{z}\nWill be translated to: StruveH[$0, $1]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/11.2#E1\nMathematica:  https://reference.wolfram.com/language/ref/StruveH.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",
          "O" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary).",
          "\\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" : "StruveH[\\[Alpha], x]- BesselY[\\[Alpha], x]",
          "rhs" : "Divide[(Divide[x,2])^(\\[Alpha]- 1),Sqrt[Pi]*Gamma[\\[Alpha]+Divide[1,2]]]+ O*((Divide[x,2])^(\\[Alpha]- 3))",
          "testExpression" : "(StruveH[\\[Alpha], x]- BesselY[\\[Alpha], x])-(Divide[(Divide[x,2])^(\\[Alpha]- 1),Sqrt[Pi]*Gamma[\\[Alpha]+Divide[1,2]]]+ O*((Divide[x,2])^(\\[Alpha]- 3)))",
          "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: \\StruveH [\\StruveH]"
        }
      }
    },
    "Maple" : {
      "translation" : "StruveH(alpha, x)- BesselY(alpha, x) = (((x)/(2))^(alpha - 1))/(sqrt(Pi)*GAMMA(alpha +(1)/(2)))+ O(((x)/(2))^(alpha - 3))",
      "translationInformation" : {
        "subEquations" : [ "StruveH(alpha, x)- BesselY(alpha, x) = (((x)/(2))^(alpha - 1))/(sqrt(Pi)*GAMMA(alpha +(1)/(2)))+ O(((x)/(2))^(alpha - 3))" ],
        "freeVariables" : [ "alpha", "x" ],
        "tokenTranslations" : {
          "\\BesselY" : "Bessel function second kind; Example: \\BesselY{v}@{z}\nWill be translated to: BesselY($0, $1)\nBranch Cuts: (-\\infty, 0]\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/10.2#E3\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=Bessel",
          "\\StruveH" : "Struve function; Example: \\StruveH{\\nu}@{z}\nWill be translated to: StruveH($0, $1)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/11.2#E1\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=StruveH",
          "\\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",
          "O" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary).",
          "\\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" : [ {
    "section" : 4,
    "sentence" : 1,
    "word" : 7
  } ],
  "includes" : [ "\\mathbf{L}_{\\alpha}(x)", "x", "\\mathbf{K}_\\alpha(x)", "\\alpha", "\\Gamma(z)", "\\mathbf{H}_{\\alpha}(z)", "\\mathbf{H}_{\\alpha}(x)", "\\mathbf{M}_\\alpha(x)", "Y_{\\alpha}(x)" ],
  "isPartOf" : [ ],
  "definiens" : [ {
    "definition" : "Neumann function",
    "score" : 0.7125985104912714
  } ]
}

Specify your own input