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{(-1)^n}{2^n n!} (1-z)^{-\alpha} (1+z)^{-\beta} \frac{d^n}{dz^n} \left\{ (1-z)^\alpha (1+z)^\beta \left (1 - z^2 \right )^n \right\}.}

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

Semantic latex: \JacobipolyP{\alpha}{\beta}{n}@{z} = \frac{(-1)^n}{2^n n!}(1 - z)^{-\alpha}(1 + z)^{-\beta} \deriv [n]{ }{z} \{(1 - z)^\alpha(1 + z)^\beta(1 - z^2)^n \}

Confidence: 0.70338171203013

Mathematica

Translation: JacobiP[n, \[Alpha], \[Beta], z] == Divide[(- 1)^(n),(2)^(n)* (n)!]*(1 - z)^(- \[Alpha])*(1 + z)^(- \[Beta])* D[(1 - z)^\[Alpha]*(1 + z)^\[Beta]*(1 - (z)^(2))^(n), {z, n}]

Information

Sub Equations

  • JacobiP[n, \[Alpha], \[Beta], z] = Divide[(- 1)^(n),(2)^(n)* (n)!]*(1 - z)^(- \[Alpha])*(1 + z)^(- \[Beta])* D[(1 - z)^\[Alpha]*(1 + z)^\[Beta]*(1 - (z)^(2))^(n), {z, 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 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.

  • 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

Tests

Symbolic

Test expression: (JacobiP[n, \[Alpha], \[Beta], z])-(Divide[(- 1)^(n),(2)^(n)* (n)!]*(1 - z)^(- \[Alpha])*(1 + z)^(- \[Beta])* D[(1 - z)^\[Alpha]*(1 + z)^\[Beta]*(1 - (z)^(2))^(n), {z, n}])

ERROR:

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

SymPy

Translation: jacobi(n, Symbol('alpha'), Symbol('beta'), z) == ((- 1)**(n))/((2)**(n)* factorial(n))*(1 - z)**(- Symbol('alpha'))*(1 + z)**(- Symbol('beta'))* diff((1 - z)**(Symbol('alpha'))*(1 + z)**(Symbol('beta'))*(1 - (z)**(2))**(n), z, n)

Information

Sub Equations

  • jacobi(n, Symbol('alpha'), Symbol('beta'), z) = ((- 1)**(n))/((2)**(n)* factorial(n))*(1 - z)**(- Symbol('alpha'))*(1 + z)**(- Symbol('beta'))* diff((1 - z)**(Symbol('alpha'))*(1 + z)**(Symbol('beta'))*(1 - (z)**(2))**(n), z, n)

Free variables

  • Symbol('alpha')
  • Symbol('beta')
  • n
  • z

Symbol info

  • Jacobi polynomial; Example: \JacobipolyP{\alpha}{\beta}{n}@{x}

Will be translated to: jacobi($2, $0, $1, $3) Relevant links to definitions: DLMF: http://dlmf.nist.gov/18.3#T1.t1.r2 SymPy: https://docs.sympy.org/latest/modules/functions/special.html#jacobi-polynomials

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

  • 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 SymPy: https://docs.sympy.org/latest/tutorial/calculus.html#derivatives

Tests

Symbolic
Numeric

Maple

Translation: JacobiP(n, alpha, beta, z) = ((- 1)^(n))/((2)^(n)* factorial(n))*(1 - z)^(- alpha)*(1 + z)^(- beta)* diff((1 - z)^(alpha)*(1 + z)^(beta)*(1 - (z)^(2))^(n), [z$(n)])

Information

Sub Equations

  • JacobiP(n, alpha, beta, z) = ((- 1)^(n))/((2)^(n)* factorial(n))*(1 - z)^(- alpha)*(1 + z)^(- beta)* diff((1 - z)^(alpha)*(1 + z)^(beta)*(1 - (z)^(2))^(n), [z$(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.

  • 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

Tests

Symbolic
Numeric

Dependency Graph Information

Includes

Description

  • Rodrigues ' formula
  • equivalent definition

Complete translation information:

{
  "id" : "FORMULA_b98cc2a3c71764be8bc7fe354e54ebf7",
  "formula" : "P_n^{(\\alpha,\\beta)}(z) = \\frac{(-1)^n}{2^n n!} (1-z)^{-\\alpha} (1+z)^{-\\beta} \\frac{d^n}{dz^n} \\left\\{ (1-z)^\\alpha (1+z)^\\beta \\left (1 - z^2 \\right )^n \\right\\}",
  "semanticFormula" : "\\JacobipolyP{\\alpha}{\\beta}{n}@{z} = \\frac{(-1)^n}{2^n n!}(1 - z)^{-\\alpha}(1 + z)^{-\\beta} \\deriv [n]{ }{z} \\{(1 - z)^\\alpha(1 + z)^\\beta(1 - z^2)^n \\}",
  "confidence" : 0.7033817120301267,
  "translations" : {
    "Mathematica" : {
      "translation" : "JacobiP[n, \\[Alpha], \\[Beta], z] == Divide[(- 1)^(n),(2)^(n)* (n)!]*(1 - z)^(- \\[Alpha])*(1 + z)^(- \\[Beta])* D[(1 - z)^\\[Alpha]*(1 + z)^\\[Beta]*(1 - (z)^(2))^(n), {z, n}]",
      "translationInformation" : {
        "subEquations" : [ "JacobiP[n, \\[Alpha], \\[Beta], z] = Divide[(- 1)^(n),(2)^(n)* (n)!]*(1 - z)^(- \\[Alpha])*(1 + z)^(- \\[Beta])* D[(1 - z)^\\[Alpha]*(1 + z)^\\[Beta]*(1 - (z)^(2))^(n), {z, 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\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",
          "\\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"
        }
      },
      "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[(- 1)^(n),(2)^(n)* (n)!]*(1 - z)^(- \\[Alpha])*(1 + z)^(- \\[Beta])* D[(1 - z)^\\[Alpha]*(1 + z)^\\[Beta]*(1 - (z)^(2))^(n), {z, n}]",
          "testExpression" : "(JacobiP[n, \\[Alpha], \\[Beta], z])-(Divide[(- 1)^(n),(2)^(n)* (n)!]*(1 - z)^(- \\[Alpha])*(1 + z)^(- \\[Beta])* D[(1 - z)^\\[Alpha]*(1 + z)^\\[Beta]*(1 - (z)^(2))^(n), {z, n}])",
          "testCalculations" : [ {
            "result" : "ERROR",
            "testTitle" : "Simple",
            "testExpression" : null,
            "resultExpression" : null,
            "wasAborted" : false,
            "conditionallySuccessful" : false
          } ]
        } ]
      }
    },
    "SymPy" : {
      "translation" : "jacobi(n, Symbol('alpha'), Symbol('beta'), z) == ((- 1)**(n))/((2)**(n)* factorial(n))*(1 - z)**(- Symbol('alpha'))*(1 + z)**(- Symbol('beta'))* diff((1 - z)**(Symbol('alpha'))*(1 + z)**(Symbol('beta'))*(1 - (z)**(2))**(n), z, n)",
      "translationInformation" : {
        "subEquations" : [ "jacobi(n, Symbol('alpha'), Symbol('beta'), z) = ((- 1)**(n))/((2)**(n)* factorial(n))*(1 - z)**(- Symbol('alpha'))*(1 + z)**(- Symbol('beta'))* diff((1 - z)**(Symbol('alpha'))*(1 + z)**(Symbol('beta'))*(1 - (z)**(2))**(n), z, n)" ],
        "freeVariables" : [ "Symbol('alpha')", "Symbol('beta')", "n", "z" ],
        "tokenTranslations" : {
          "\\JacobipolyP" : "Jacobi polynomial; Example: \\JacobipolyP{\\alpha}{\\beta}{n}@{x}\nWill be translated to: jacobi($2, $0, $1, $3)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/18.3#T1.t1.r2\nSymPy: https://docs.sympy.org/latest/modules/functions/special.html#jacobi-polynomials",
          "\\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",
          "\\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\nSymPy: https://docs.sympy.org/latest/tutorial/calculus.html#derivatives"
        }
      }
    },
    "Maple" : {
      "translation" : "JacobiP(n, alpha, beta, z) = ((- 1)^(n))/((2)^(n)* factorial(n))*(1 - z)^(- alpha)*(1 + z)^(- beta)* diff((1 - z)^(alpha)*(1 + z)^(beta)*(1 - (z)^(2))^(n), [z$(n)])",
      "translationInformation" : {
        "subEquations" : [ "JacobiP(n, alpha, beta, z) = ((- 1)^(n))/((2)^(n)* factorial(n))*(1 - z)^(- alpha)*(1 + z)^(- beta)* diff((1 - z)^(alpha)*(1 + z)^(beta)*(1 - (z)^(2))^(n), [z$(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",
          "\\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"
        }
      }
    }
  },
  "positions" : [ {
    "section" : 2,
    "sentence" : 0,
    "word" : 10
  } ],
  "includes" : [ "(1 - x)^{\\alpha}(1 + x)^{\\beta}", "P_{n}^{(\\alpha, \\beta)}(x)", "n", "P_{n}^{(\\alpha, \\beta)}", "\\alpha,\\beta", "z" ],
  "isPartOf" : [ ],
  "definiens" : [ {
    "definition" : "Rodrigues ' formula",
    "score" : 0.6859086196238077
  }, {
    "definition" : "equivalent definition",
    "score" : 0.6460746792928004
  } ]
}

Specify your own input