LaTeX to CAS translator
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 E[h(y)] = \int_{-\infty}^{+\infty} \frac{1}{\sigma \sqrt{2\pi}} \exp \left( -\frac{(y-\mu)^2}{2\sigma^2} \right) h(y) dy}
... is translated to the CAS output ...
Semantic latex: E [h(y)] = \int_{-\infty}^{+\infty} \frac{1}{\sigma \sqrt{2 \cpi}} \exp(- \frac{(y-\mu)^2}{2\sigma^2}) h(y) \diff{y}
Confidence: 0
Mathematica
Translation: E[h[y]] == Integrate[Divide[1,\[Sigma]*Sqrt[2*Pi]]*Exp[-Divide[(y - \[Mu])^(2),2*\[Sigma]^(2)]]*h[y], {y, - Infinity, + Infinity}, GenerateConditions->None]
Information
Sub Equations
- E[h[y]] = Integrate[Divide[1,\[Sigma]*Sqrt[2*Pi]]*Exp[-Divide[(y - \[Mu])^(2),2*\[Sigma]^(2)]]*h[y], {y, - Infinity, + Infinity}, GenerateConditions->None]
Free variables
- \[Mu]
- \[Sigma]
- y
Symbol info
- Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).
- Exponential function; Example: \exp@@{z}
Will be translated to: Exp[$0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.2#E19 Mathematica: https://reference.wolfram.com/language/ref/Exp.html
- Pi was translated to: Pi
- Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).
Tests
Symbolic
Test expression: (E*(h*(y)))-(Integrate[Divide[1,\[Sigma]*Sqrt[2*Pi]]*Exp[-Divide[(y - \[Mu])^(2),2*\[Sigma]^(2)]]*h*(y), {y, - Infinity, + Infinity}, GenerateConditions->None])
ERROR:
{
"result": "ERROR",
"testTitle": "Simple",
"testExpression": null,
"resultExpression": null,
"wasAborted": false,
"conditionallySuccessful": false
}
Numeric
SymPy
Translation: E(h(y)) == integrate((1)/(Symbol('sigma')*sqrt(2*pi))*exp(-((y - Symbol('mu'))**(2))/(2*(Symbol('sigma'))**(2)))*h(y), (y, - oo, + oo))
Information
Sub Equations
- E(h(y)) = integrate((1)/(Symbol('sigma')*sqrt(2*pi))*exp(-((y - Symbol('mu'))**(2))/(2*(Symbol('sigma'))**(2)))*h(y), (y, - oo, + oo))
Free variables
- Symbol('mu')
- Symbol('sigma')
- y
Symbol info
- Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).
- Exponential function; Example: \exp@@{z}
Will be translated to: exp($0) Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.2#E19 SymPy: https://docs.sympy.org/latest/modules/functions/elementary.html#exp
- Pi was translated to: pi
- Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).
Tests
Symbolic
Numeric
Maple
Translation: E(h(y)) = int((1)/(sigma*sqrt(2*Pi))*exp(-((y - mu)^(2))/(2*(sigma)^(2)))*h(y), y = - infinity..+ infinity)
Information
Sub Equations
- E(h(y)) = int((1)/(sigma*sqrt(2*Pi))*exp(-((y - mu)^(2))/(2*(sigma)^(2)))*h(y), y = - infinity..+ infinity)
Free variables
- mu
- sigma
- y
Symbol info
- Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).
- Exponential function; Example: \exp@@{z}
Will be translated to: exp($0) Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.2#E19 Maple: https://www.maplesoft.com/support/help/Maple/view.aspx?path=LinearAlgebra/Trace
- Pi was translated to: Pi
- Function without DLMF-Definition. We keep it like it is (but delete prefix \ if necessary).
Tests
Symbolic
Numeric
Dependency Graph Information
Includes
Description
- integral
- integration by substitution
- expectation
- variable
- Hermite polynomial
Complete translation information:
{
"id" : "FORMULA_1423fe2a603a0984f3b824f4dd88eeaa",
"formula" : "E[h(y)] = \\int_{-\\infty}^{+\\infty} \\frac{1}{\\sigma \\sqrt{2\\pi}} \\exp \\left( -\\frac{(y-\\mu)^2}{2\\sigma^2} \\right) h(y) dy",
"semanticFormula" : "E [h(y)] = \\int_{-\\infty}^{+\\infty} \\frac{1}{\\sigma \\sqrt{2 \\cpi}} \\exp(- \\frac{(y-\\mu)^2}{2\\sigma^2}) h(y) \\diff{y}",
"confidence" : 0.0,
"translations" : {
"Mathematica" : {
"translation" : "E[h[y]] == Integrate[Divide[1,\\[Sigma]*Sqrt[2*Pi]]*Exp[-Divide[(y - \\[Mu])^(2),2*\\[Sigma]^(2)]]*h[y], {y, - Infinity, + Infinity}, GenerateConditions->None]",
"translationInformation" : {
"subEquations" : [ "E[h[y]] = Integrate[Divide[1,\\[Sigma]*Sqrt[2*Pi]]*Exp[-Divide[(y - \\[Mu])^(2),2*\\[Sigma]^(2)]]*h[y], {y, - Infinity, + Infinity}, GenerateConditions->None]" ],
"freeVariables" : [ "\\[Mu]", "\\[Sigma]", "y" ],
"tokenTranslations" : {
"h" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary).",
"\\exp" : "Exponential function; Example: \\exp@@{z}\nWill be translated to: Exp[$0]\nRelevant links to definitions:\nDLMF: http://dlmf.nist.gov/4.2#E19\nMathematica: https://reference.wolfram.com/language/ref/Exp.html",
"\\cpi" : "Pi was translated to: Pi",
"E" : "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" : "E*(h*(y))",
"rhs" : "Integrate[Divide[1,\\[Sigma]*Sqrt[2*Pi]]*Exp[-Divide[(y - \\[Mu])^(2),2*\\[Sigma]^(2)]]*h*(y), {y, - Infinity, + Infinity}, GenerateConditions->None]",
"testExpression" : "(E*(h*(y)))-(Integrate[Divide[1,\\[Sigma]*Sqrt[2*Pi]]*Exp[-Divide[(y - \\[Mu])^(2),2*\\[Sigma]^(2)]]*h*(y), {y, - Infinity, + Infinity}, GenerateConditions->None])",
"testCalculations" : [ {
"result" : "ERROR",
"testTitle" : "Simple",
"testExpression" : null,
"resultExpression" : null,
"wasAborted" : false,
"conditionallySuccessful" : false
} ]
} ]
}
},
"SymPy" : {
"translation" : "E(h(y)) == integrate((1)/(Symbol('sigma')*sqrt(2*pi))*exp(-((y - Symbol('mu'))**(2))/(2*(Symbol('sigma'))**(2)))*h(y), (y, - oo, + oo))",
"translationInformation" : {
"subEquations" : [ "E(h(y)) = integrate((1)/(Symbol('sigma')*sqrt(2*pi))*exp(-((y - Symbol('mu'))**(2))/(2*(Symbol('sigma'))**(2)))*h(y), (y, - oo, + oo))" ],
"freeVariables" : [ "Symbol('mu')", "Symbol('sigma')", "y" ],
"tokenTranslations" : {
"h" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary).",
"\\exp" : "Exponential function; Example: \\exp@@{z}\nWill be translated to: exp($0)\nRelevant links to definitions:\nDLMF: http://dlmf.nist.gov/4.2#E19\nSymPy: https://docs.sympy.org/latest/modules/functions/elementary.html#exp",
"\\cpi" : "Pi was translated to: pi",
"E" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary)."
}
}
},
"Maple" : {
"translation" : "E(h(y)) = int((1)/(sigma*sqrt(2*Pi))*exp(-((y - mu)^(2))/(2*(sigma)^(2)))*h(y), y = - infinity..+ infinity)",
"translationInformation" : {
"subEquations" : [ "E(h(y)) = int((1)/(sigma*sqrt(2*Pi))*exp(-((y - mu)^(2))/(2*(sigma)^(2)))*h(y), y = - infinity..+ infinity)" ],
"freeVariables" : [ "mu", "sigma", "y" ],
"tokenTranslations" : {
"h" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary).",
"\\exp" : "Exponential function; Example: \\exp@@{z}\nWill be translated to: exp($0)\nRelevant links to definitions:\nDLMF: http://dlmf.nist.gov/4.2#E19\nMaple: https://www.maplesoft.com/support/help/Maple/view.aspx?path=LinearAlgebra/Trace",
"\\cpi" : "Pi was translated to: Pi",
"E" : "Function without DLMF-Definition. We keep it like it is (but delete prefix \\ if necessary)."
}
}
}
},
"positions" : [ {
"section" : 1,
"sentence" : 1,
"word" : 10
} ],
"includes" : [ "y", "h" ],
"isPartOf" : [ ],
"definiens" : [ {
"definition" : "integral",
"score" : 0.7125985104912714
}, {
"definition" : "integration by substitution",
"score" : 0.6859086196238077
}, {
"definition" : "expectation",
"score" : 0.6460746792928004
}, {
"definition" : "variable",
"score" : 0.6460746792928004
}, {
"definition" : "Hermite polynomial",
"score" : 0.5988174995334326
} ]
}