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 \frac{d^2y}{dz^2} + (\lambda - 2h^2\cos 2z)y = 0. }

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

Semantic latex: \deriv [2]{y}{z} +(\lambda - 2 h^2 \cos 2 z) y = 0

Confidence: 0

Mathematica

Translation: D[y, {z, 2}]+(\[Lambda]- 2*(h)^(2)* Cos[2]*z)*y == 0

Information

Sub Equations

  • D[y, {z, 2}]+(\[Lambda]- 2*(h)^(2)* Cos[2]*z)*y = 0

Free variables

  • \[Lambda]
  • h
  • y
  • z

Symbol info

  • Cosine; Example: \cos@@{z}

Will be translated to: Cos[$0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.14#E2 Mathematica: https://reference.wolfram.com/language/ref/Cos.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

Tests

Symbolic

Test expression: (D[y, {z, 2}]+(\[Lambda]- 2*(h)^(2)* Cos[2]*z)*y)-(0)

ERROR:

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

SymPy

Translation: diff(y, z, 2)+(Symbol('lambda')- 2*(h)**(2)* cos(2)*z)*y == 0

Information

Sub Equations

  • diff(y, z, 2)+(Symbol('lambda')- 2*(h)**(2)* cos(2)*z)*y = 0

Free variables

  • Symbol('lambda')
  • h
  • y
  • z

Symbol info

  • Cosine; Example: \cos@@{z}

Will be translated to: cos($0) Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.14#E2 SymPy: https://docs.sympy.org/latest/modules/functions/elementary.html#cos

  • 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: diff(y, [z$(2)])+(lambda - 2*(h)^(2)* cos(2)*z)*y = 0

Information

Sub Equations

  • diff(y, [z$(2)])+(lambda - 2*(h)^(2)* cos(2)*z)*y = 0

Free variables

  • h
  • lambda
  • y
  • z

Symbol info

  • Cosine; Example: \cos@@{z}

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

  • 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

Description

  • Mathieu equation
  • equation

Complete translation information:

{
  "id" : "FORMULA_f61c342fb49ca917eb79ec57a8a34d98",
  "formula" : "\\frac{d^2y}{dz^2} + (\\lambda - 2h^2\\cos 2z)y = 0",
  "semanticFormula" : "\\deriv [2]{y}{z} +(\\lambda - 2 h^2 \\cos 2 z) y = 0",
  "confidence" : 0.0,
  "translations" : {
    "Mathematica" : {
      "translation" : "D[y, {z, 2}]+(\\[Lambda]- 2*(h)^(2)* Cos[2]*z)*y == 0",
      "translationInformation" : {
        "subEquations" : [ "D[y, {z, 2}]+(\\[Lambda]- 2*(h)^(2)* Cos[2]*z)*y = 0" ],
        "freeVariables" : [ "\\[Lambda]", "h", "y", "z" ],
        "tokenTranslations" : {
          "\\cos" : "Cosine; Example: \\cos@@{z}\nWill be translated to: Cos[$0]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/4.14#E2\nMathematica:  https://reference.wolfram.com/language/ref/Cos.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"
        }
      },
      "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" : "D[y, {z, 2}]+(\\[Lambda]- 2*(h)^(2)* Cos[2]*z)*y",
          "rhs" : "0",
          "testExpression" : "(D[y, {z, 2}]+(\\[Lambda]- 2*(h)^(2)* Cos[2]*z)*y)-(0)",
          "testCalculations" : [ {
            "result" : "ERROR",
            "testTitle" : "Simple",
            "testExpression" : null,
            "resultExpression" : null,
            "wasAborted" : false,
            "conditionallySuccessful" : false
          } ]
        } ]
      }
    },
    "SymPy" : {
      "translation" : "diff(y, z, 2)+(Symbol('lambda')- 2*(h)**(2)* cos(2)*z)*y == 0",
      "translationInformation" : {
        "subEquations" : [ "diff(y, z, 2)+(Symbol('lambda')- 2*(h)**(2)* cos(2)*z)*y = 0" ],
        "freeVariables" : [ "Symbol('lambda')", "h", "y", "z" ],
        "tokenTranslations" : {
          "\\cos" : "Cosine; Example: \\cos@@{z}\nWill be translated to: cos($0)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/4.14#E2\nSymPy: https://docs.sympy.org/latest/modules/functions/elementary.html#cos",
          "\\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" : "diff(y, [z$(2)])+(lambda - 2*(h)^(2)* cos(2)*z)*y = 0",
      "translationInformation" : {
        "subEquations" : [ "diff(y, [z$(2)])+(lambda - 2*(h)^(2)* cos(2)*z)*y = 0" ],
        "freeVariables" : [ "h", "lambda", "y", "z" ],
        "tokenTranslations" : {
          "\\cos" : "Cosine; Example: \\cos@@{z}\nWill be translated to: cos($0)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/4.14#E2\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=cos",
          "\\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" : 1,
    "sentence" : 6,
    "word" : 9
  } ],
  "includes" : [ ],
  "isPartOf" : [ ],
  "definiens" : [ {
    "definition" : "Mathieu equation",
    "score" : 0.722
  }, {
    "definition" : "equation",
    "score" : 0.6859086196238077
  } ]
}

Specify your own input