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 \begin{align} &\mathrm{kei}_n(x) = - \ln\left(\frac{x}{2}\right) \mathrm{bei}_n(x) - \frac{\pi}{4}\mathrm{ber}_n(x) \\ &-\frac{1}{2} \left(\frac{x}{2}\right)^{-n} \sum_{k=0}^{n-1} \sin\left[\left(\frac{3n}{4} + \frac{k}{2}\right)\pi\right] \frac{(n-k-1)!}{k!} \left(\frac{x^2}{4}\right)^k \\ &+ \frac{1}{2} \left(\frac{x}{2}\right)^n \sum_{k \geq 0} \sin\left[\left(\frac{3n}{4} + \frac{k}{2}\right)\pi\right] \frac{\psi(k+1) + \psi(n + k + 1)}{k! (n+k)!} \left(\frac{x^2}{4}\right)^k . \end{align}}

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

Semantic latex: \begin{align}&\Kelvinkei{n}@@{(x)} = - \ln(\frac{x}{2}) \Kelvinbei{n}@@{(x)} - \frac{\cpi}{4} \Kelvinber{n}@@{(x)} \\ &- \frac{1}{2}(\frac{x}{2})^{-n} \sum_{k=0}^{n-1} \sin [(\frac{3n}{4} + \frac{k}{2}) \cpi] \frac{(n-k-1)!}{k!}(\frac{x^2}{4})^k \\ &+ \frac{1}{2}(\frac{x}{2})^n \sum_{k \geq 0} \sin [(\frac{3n}{4} + \frac{k}{2}) \cpi] \frac{\digamma@{k + 1} + \digamma@{n + k + 1}}{k! (n+k)!}(\frac{x^2}{4})^k .\end{align}

Confidence: 0.66951655463217

Mathematica

Translation: KelvinKei[n, x] == - Log[Divide[x,2]]*KelvinBei[n, x]-Divide[Pi,4]*KelvinBer[n, x] -Divide[1,2]*(Divide[x,2])^(- n)* Sum[Sin[(Divide[3*n,4]+Divide[k,2])*Pi]*Divide[(n - k - 1)!,(k)!]*(Divide[(x)^(2),4])^(k), {k, 0, n - 1}, GenerateConditions->None] +Divide[1,2]*(Divide[x,2])^(n)* Sum[Sin[(Divide[3*n,4]+Divide[k,2])*Pi]*Divide[PolyGamma[k + 1]+ PolyGamma[n + k + 1],(k)!*(n + k)!]*(Divide[(x)^(2),4])^(k), {k, 0, Infinity}, GenerateConditions->None]

Information

Sub Equations

  • KelvinKei[n, x] = - Log[Divide[x,2]]*KelvinBei[n, x]-Divide[Pi,4]*KelvinBer[n, x]

Free variables

  • n
  • x

Symbol info

  • Kelvin Function KEI; Example: \Kelvinkei{\nu}@@{x}

Will be translated to: KelvinKei[$0, $1] Relevant links to definitions: DLMF: http://dlmf.nist.gov/10.61#E2 Mathematica: https://reference.wolfram.com/language/ref/KelvinKei.html

  • Kelvin Function BER; Example: \Kelvinber{\nu}@@{x}

Will be translated to: KelvinBer[$0, $1] Relevant links to definitions: DLMF: http://dlmf.nist.gov/10.61#E1 Mathematica: https://reference.wolfram.com/language/ref/KelvinBer.html

  • Sine; Example: \sin@@{z}

Will be translated to: Sin[$0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.14#E1 Mathematica: https://reference.wolfram.com/language/ref/Sin.html

  • Digamma / Psi function; Example: \digamma@{z}

Will be translated to: PolyGamma[$0] Constraints: z not element of {0, -1, -2, ...} Relevant links to definitions: DLMF: http://dlmf.nist.gov/5.2#E2 Mathematica: https://reference.wolfram.com/language/ref/PolyGamma.html

  • Pi was translated to: Pi
  • Kelvin Function BEI; Example: \Kelvinbei{\nu}@@{x}

Will be translated to: KelvinBei[$0, $1] Relevant links to definitions: DLMF: http://dlmf.nist.gov/10.61#E1 Mathematica: https://reference.wolfram.com/language/ref/KelvinBei.html

  • Natural logarithm; Example: \ln@@{z}

Will be translated to: Log[$0] Constraints: z != 0 Branch Cuts: (-\infty, 0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.2#E2 Mathematica: https://reference.wolfram.com/language/ref/Log.html

Tests

Symbolic

Test expression: (KelvinKei[n, x])-(- Log[Divide[x,2]]*KelvinBei[n, x]-Divide[Pi,4]*KelvinBer[n, x])

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

Tests

Symbolic
Numeric

Maple

Translation: KelvinKei(n, x) = - ln((x)/(2))*KelvinBei(n, x)-(Pi)/(4)*KelvinBer(n, x) -(1)/(2)*((x)/(2))^(- n)* sum(sin(((3*n)/(4)+(k)/(2))*Pi)*(factorial(n - k - 1))/(factorial(k))*(((x)^(2))/(4))^(k), k = 0..n - 1) +(1)/(2)*((x)/(2))^(n)* sum(sin(((3*n)/(4)+(k)/(2))*Pi)*(Psi(k + 1)+ Psi(n + k + 1))/(factorial(k)*factorial(n + k))*(((x)^(2))/(4))^(k), k = 0..infinity)

Information

Sub Equations

  • KelvinKei(n, x) = - ln((x)/(2))*KelvinBei(n, x)-(Pi)/(4)*KelvinBer(n, x)

Free variables

  • n
  • x

Symbol info

  • Kelvin Function KEI; Example: \Kelvinkei{\nu}@@{x}

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

  • Kelvin Function BER; Example: \Kelvinber{\nu}@@{x}

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

  • Sine; Example: \sin@@{z}

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

  • Digamma / Psi function; Example: \digamma@{z}

Will be translated to: Psi($0) Constraints: z not element of {0, -1, -2, ...} Relevant links to definitions: DLMF: http://dlmf.nist.gov/5.2#E2 Maple: https://www.maplesoft.com/support/help/maple/view.aspx?path=Psi

  • Pi was translated to: Pi
  • Kelvin Function BEI; Example: \Kelvinbei{\nu}@@{x}

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

  • Natural logarithm; Example: \ln@@{z}

Will be translated to: ln($0) Constraints: z != 0 Branch Cuts: (-\infty, 0] Relevant links to definitions: DLMF: http://dlmf.nist.gov/4.2#E2 Maple: https://www.maplesoft.com/support/help/maple/view.aspx?path=ln

Tests

Symbolic
Numeric

Dependency Graph Information

Includes

Is part of

Complete translation information:

{
  "id" : "FORMULA_62dd8602607f0e5796a59a30eac17b51",
  "formula" : "\\begin{align}\n&\\mathrm{kei}_n(x) = - \\ln\\left(\\frac{x}{2}\\right) \\mathrm{bei}_n(x) - \\frac{\\pi}{4}\\mathrm{ber}_n(x) \\\\\n&-\\frac{1}{2} \\left(\\frac{x}{2}\\right)^{-n} \\sum_{k=0}^{n-1} \\sin\\left[\\left(\\frac{3n}{4} + \\frac{k}{2}\\right)\\pi\\right] \\frac{(n-k-1)!}{k!} \\left(\\frac{x^2}{4}\\right)^k  \\\\\n&+ \\frac{1}{2} \\left(\\frac{x}{2}\\right)^n \\sum_{k \\geq 0} \\sin\\left[\\left(\\frac{3n}{4} + \\frac{k}{2}\\right)\\pi\\right] \\frac{\\psi(k+1) + \\psi(n + k + 1)}{k! (n+k)!} \\left(\\frac{x^2}{4}\\right)^k .\n\\end{align}",
  "semanticFormula" : "\\begin{align}&\\Kelvinkei{n}@@{(x)} = - \\ln(\\frac{x}{2}) \\Kelvinbei{n}@@{(x)} - \\frac{\\cpi}{4} \\Kelvinber{n}@@{(x)} \\\\ &- \\frac{1}{2}(\\frac{x}{2})^{-n} \\sum_{k=0}^{n-1} \\sin [(\\frac{3n}{4} + \\frac{k}{2}) \\cpi] \\frac{(n-k-1)!}{k!}(\\frac{x^2}{4})^k \\\\ &+ \\frac{1}{2}(\\frac{x}{2})^n \\sum_{k \\geq 0} \\sin [(\\frac{3n}{4} + \\frac{k}{2}) \\cpi] \\frac{\\digamma@{k + 1} + \\digamma@{n + k + 1}}{k! (n+k)!}(\\frac{x^2}{4})^k .\\end{align}",
  "confidence" : 0.6695165546321705,
  "translations" : {
    "Mathematica" : {
      "translation" : "KelvinKei[n, x] == - Log[Divide[x,2]]*KelvinBei[n, x]-Divide[Pi,4]*KelvinBer[n, x] -Divide[1,2]*(Divide[x,2])^(- n)* Sum[Sin[(Divide[3*n,4]+Divide[k,2])*Pi]*Divide[(n - k - 1)!,(k)!]*(Divide[(x)^(2),4])^(k), {k, 0, n - 1}, GenerateConditions->None] +Divide[1,2]*(Divide[x,2])^(n)* Sum[Sin[(Divide[3*n,4]+Divide[k,2])*Pi]*Divide[PolyGamma[k + 1]+ PolyGamma[n + k + 1],(k)!*(n + k)!]*(Divide[(x)^(2),4])^(k), {k, 0, Infinity}, GenerateConditions->None]",
      "translationInformation" : {
        "subEquations" : [ "KelvinKei[n, x] = - Log[Divide[x,2]]*KelvinBei[n, x]-Divide[Pi,4]*KelvinBer[n, x]" ],
        "freeVariables" : [ "n", "x" ],
        "tokenTranslations" : {
          "\\Kelvinkei" : "Kelvin Function KEI; Example: \\Kelvinkei{\\nu}@@{x}\nWill be translated to: KelvinKei[$0, $1]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/10.61#E2\nMathematica:  https://reference.wolfram.com/language/ref/KelvinKei.html",
          "\\Kelvinber" : "Kelvin Function BER; Example: \\Kelvinber{\\nu}@@{x}\nWill be translated to: KelvinBer[$0, $1]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/10.61#E1\nMathematica:  https://reference.wolfram.com/language/ref/KelvinBer.html",
          "\\sin" : "Sine; Example: \\sin@@{z}\nWill be translated to: Sin[$0]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/4.14#E1\nMathematica:  https://reference.wolfram.com/language/ref/Sin.html",
          "\\digamma" : "Digamma / Psi function; Example: \\digamma@{z}\nWill be translated to: PolyGamma[$0]\nConstraints: z not element of {0, -1, -2, ...}\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/5.2#E2\nMathematica:  https://reference.wolfram.com/language/ref/PolyGamma.html",
          "\\cpi" : "Pi was translated to: Pi",
          "\\Kelvinbei" : "Kelvin Function BEI; Example: \\Kelvinbei{\\nu}@@{x}\nWill be translated to: KelvinBei[$0, $1]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/10.61#E1\nMathematica:  https://reference.wolfram.com/language/ref/KelvinBei.html",
          "\\ln" : "Natural logarithm; Example: \\ln@@{z}\nWill be translated to: Log[$0]\nConstraints: z != 0\nBranch Cuts: (-\\infty, 0]\nRelevant links to definitions:\nDLMF:         http://dlmf.nist.gov/4.2#E2\nMathematica:  https://reference.wolfram.com/language/ref/Log.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" : "KelvinKei[n, x]",
          "rhs" : "- Log[Divide[x,2]]*KelvinBei[n, x]-Divide[Pi,4]*KelvinBer[n, x]",
          "testExpression" : "(KelvinKei[n, x])-(- Log[Divide[x,2]]*KelvinBei[n, x]-Divide[Pi,4]*KelvinBer[n, x])",
          "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: \\Kelvinkei [\\Kelvinkei]"
        }
      }
    },
    "Maple" : {
      "translation" : "KelvinKei(n, x) = - ln((x)/(2))*KelvinBei(n, x)-(Pi)/(4)*KelvinBer(n, x) -(1)/(2)*((x)/(2))^(- n)* sum(sin(((3*n)/(4)+(k)/(2))*Pi)*(factorial(n - k - 1))/(factorial(k))*(((x)^(2))/(4))^(k), k = 0..n - 1) +(1)/(2)*((x)/(2))^(n)* sum(sin(((3*n)/(4)+(k)/(2))*Pi)*(Psi(k + 1)+ Psi(n + k + 1))/(factorial(k)*factorial(n + k))*(((x)^(2))/(4))^(k), k = 0..infinity)",
      "translationInformation" : {
        "subEquations" : [ "KelvinKei(n, x) = - ln((x)/(2))*KelvinBei(n, x)-(Pi)/(4)*KelvinBer(n, x)" ],
        "freeVariables" : [ "n", "x" ],
        "tokenTranslations" : {
          "\\Kelvinkei" : "Kelvin Function KEI; Example: \\Kelvinkei{\\nu}@@{x}\nWill be translated to: KelvinKei($0, $1)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/10.61#E2\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=KelvinKei",
          "\\Kelvinber" : "Kelvin Function BER; Example: \\Kelvinber{\\nu}@@{x}\nWill be translated to: KelvinBer($0, $1)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/10.61#E1\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=KelvinBer",
          "\\sin" : "Sine; Example: \\sin@@{z}\nWill be translated to: sin($0)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/4.14#E1\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=sin",
          "\\digamma" : "Digamma / Psi function; Example: \\digamma@{z}\nWill be translated to: Psi($0)\nConstraints: z not element of {0, -1, -2, ...}\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/5.2#E2\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=Psi",
          "\\cpi" : "Pi was translated to: Pi",
          "\\Kelvinbei" : "Kelvin Function BEI; Example: \\Kelvinbei{\\nu}@@{x}\nWill be translated to: KelvinBei($0, $1)\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/10.61#E1\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=KelvinBei",
          "\\ln" : "Natural logarithm; Example: \\ln@@{z}\nWill be translated to: ln($0)\nConstraints: z != 0\nBranch Cuts: (-\\infty, 0]\nRelevant links to definitions:\nDLMF:  http://dlmf.nist.gov/4.2#E2\nMaple: https://www.maplesoft.com/support/help/maple/view.aspx?path=ln"
        }
      }
    }
  },
  "positions" : [ ],
  "includes" : [ "\\psi(z)", "x)", "n", "_{n}(x)", "x", "\\begin{align}&\\mathrm{kei}_n(x) = - \\ln\\left(\\frac{x}{2}\\right) \\mathrm{bei}_n(x) - \\frac{\\pi}{4}\\mathrm{ber}_n(x) \\\\&-\\frac{1}{2} \\left(\\frac{x}{2}\\right)^{-n} \\sum_{k=0}^{n-1} \\sin\\left[\\left(\\frac{3n}{4} + \\frac{k}{2}\\right)\\pi\\right] \\frac{(n-k-1)!}{k!} \\left(\\frac{x^2}{4}\\right)^k  \\\\&+ \\frac{1}{2} \\left(\\frac{x}{2}\\right)^n \\sum_{k \\geq 0} \\sin\\left[\\left(\\frac{3n}{4} + \\frac{k}{2}\\right)\\pi\\right] \\frac{\\psi(k+1) + \\psi(n + k + 1)}{k! (n+k)!} \\left(\\frac{x^2}{4}\\right)^k .\\end{align}" ],
  "isPartOf" : [ "\\begin{align}&\\mathrm{kei}_n(x) = - \\ln\\left(\\frac{x}{2}\\right) \\mathrm{bei}_n(x) - \\frac{\\pi}{4}\\mathrm{ber}_n(x) \\\\&-\\frac{1}{2} \\left(\\frac{x}{2}\\right)^{-n} \\sum_{k=0}^{n-1} \\sin\\left[\\left(\\frac{3n}{4} + \\frac{k}{2}\\right)\\pi\\right] \\frac{(n-k-1)!}{k!} \\left(\\frac{x^2}{4}\\right)^k  \\\\&+ \\frac{1}{2} \\left(\\frac{x}{2}\\right)^n \\sum_{k \\geq 0} \\sin\\left[\\left(\\frac{3n}{4} + \\frac{k}{2}\\right)\\pi\\right] \\frac{\\psi(k+1) + \\psi(n + k + 1)}{k! (n+k)!} \\left(\\frac{x^2}{4}\\right)^k .\\end{align}" ],
  "definiens" : [ ]
}

Specify your own input