[Tex/LaTex] Does a tool exist which can take a LaTeX equation and convert it to a format suitable for evaluation in Wolfram’s Mathematica

equationswolfram-mathematica

I use LaTeX to type up my homework, but as I work I often need to pop things into Mathematica (or manually type them in, or manually use my TI-89, etc.).

Currently, I've been manually translating things like \frac{a}{b} into (a/b) for Mathematica's consumption… is there a tool out there which does this automagically?

Best Answer

Mathematica can do this itself: ToExpression["\\frac{a}{b}", TeXForm].

The mathematica frontend will automatically perform the necessary doubling of the backslashes so long as you are pasting into a string (ie, put the cursor between quotes "" before pasting)

You didn't ask, but you can also go the other way mathematica->Tex: TeXForm[a/b] gives \frac{a}{b}.

You can also use a mixture of TeX and mathematica in a file document.mtex and use the mathematica Splice["document.mtex"] command to replace <*, *> delimited mathematica input by TeXForm mathematica output. Eg:

The derivative of $x^x$ is $<*D[x^x,x]*>$.

Splices to:

The derivative of $x^x$ is $x^x (\log (x)+1)$.