6

Many times when I am using a symbolic computation tool (like Maple), I want to take the calculation/ and or the results and have them formatted into LaTex.

Is there a specific piece of software that does symbolic computing (Maple, MatLab, Mathematica...) and also allows you to quickly copy your work and paste it as math mode Latex or export a clean LaTex file?

For example I have used the export as latex option in the past for Maple, but it includes a lot of code just to display other elements of the worksheet that I am not interested in. Ideally I would like to avoid reformatting the equations I have written as much as possible.

(Note I have tried MathSage\SageTex and everything it offers but the combination of bugs and limited support outside of Linux makes it a problem to use).

AzJ
  • 261
  • Only slightly related to this: in case you did not know, you can also export Matlab figures to TikZ, where the figures can contain LaTeX formulae. – Karlo Nov 09 '16 at 19:30
  • 1
    sympy perhaps, see e.g. http://docs.sympy.org/dev/modules/printing.html#sympy.printing.latex.latex It is a Python package, and part of the SciPy stack. – Torbjørn T. Nov 09 '16 at 20:18
  • 2
    you don't have to convert the whole maple worksheet you can convert individual expressions eg http://www.math.tamu.edu/~boas/courses/math696/converting-Maple-code-into-LaTeX.html – David Carlisle Nov 09 '16 at 20:20
  • 1
    Even though you say you don't like it, I recommend sagemath. Support via https://groups.google.com/forum/#!forum/sage-support is pretty rapid - there's also https://ask.sagemath.org/questions/, but I haven't used this. For what I do I am not aware of any major bugs. (Disclaimer: I have contributed to sage, but I also moved to sage because I didn't like the alternatives.) Another option is Gap. –  Nov 09 '16 at 20:20
  • Maybe my answer here helps: https://tex.stackexchange.com/questions/337746/ – Dr. Manuel Kuehner Nov 09 '16 at 22:36
  • 1
    Take a look at the programm sagemath! – hans Nov 09 '16 at 22:13
  • We need more detail here. Can you show how this is done in Sagemath? – Werner Nov 09 '16 at 22:47

2 Answers2

4

In Mathematica, you can use TeXForm:

In[1]:= TrigExpand[Sin[5 x]] // TeXForm

Out[1]//TeXForm=
\sin ^5(x)+5 \sin (x) \cos ^4(x)-10 \sin ^3(x) \cos ^2(x)

You can also right click and select Copy As -> LaTeX

enter image description here

Szabolcs
  • 2,685
2

As mentioned in a comment, sympy might be an option, see e.g. the docs: http://docs.sympy.org/dev/modules/printing.html#sympy.printing.latex.latex.

It is a Python package, and part of the SciPy stack. Hence it is also available in Sage MathCloud, and probably the desktop version of Sage Math.

An example from a terminal session:

In [1]: import sympy as sp
   ...: from sympy.printing import latex as spl

In [2]: x = sp.symbols('x')

In [3]: f = (1/sp.cos(x))

In [4]: print(spl(f.series(x,0,6)))
1 + \frac{x^{2}}{2} + \frac{5 x^{4}}{24} + \mathcal{O}\left(x^{6}\right)
Torbjørn T.
  • 206,688