12
$\begingroup$

I am not sure how to explain it, but whenever I compute something in Mathematica, the output always spits back the result in a Mathematica language as opposed to easy-to-read equations.

It's troublesome if my answer contains multiplies of parentheses and if my matrix is large.

Is there a way to make Mathematica display answers in "$\LaTeX$" form? So for instance, if i compute

RowReduce[{{1, 0}, {0, 1}}]

How do I make it spit out a square matrix instead of giving me back {{1, 0}, {0, 1}}?

$\endgroup$
  • $\begingroup$ Try: {{1,0},{0,1}}//MatrixForm $\endgroup$ – kale Sep 22 '12 at 23:05
  • 2
    $\begingroup$ There is also TeXForm. TeXForm[{{1, 0}, {0, 1}}] gives: $\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \\ \end{array} \right)$ $\endgroup$ – Oleksandr R. Sep 22 '12 at 23:08
  • $\begingroup$ By the way, welcome to the site. Your question displays a bit more nicely now, too. ;) For future reference, here's the guide to formatting your posts. $\endgroup$ – Oleksandr R. Sep 22 '12 at 23:20
18
$\begingroup$

Two possible answers.

  1. TexForm converts a Mathematica expression into something you can use to paste it in TeX:

    TeXForm[x/Sqrt[5]]
    ==> \frac{x}{\sqrt{5}}
    

    A usually more convenient way of achieving this is right-clicking output, and selecting Copy as | LaTeX.

  2. If all you're looking for is a neater display form inside Mathematica, then have a look at MatrixForm and TraditionalForm.

    m = {{1, 2}, {3, 4}};
    TraditionalForm[m]
    MatrixForm[m]
    

    enter image description here

    Be careful only to use these commands to display already existing values. For example, when you're writing something like

    m = TraditionalForm[{{1, 2}, {3, 4}}];
    Eigenvalues[m]
    

    then m is not assigned the matrix, but its TraditionalForm representation, which does not behave like a matrix anymore. The output of the above is simply a silly line:

    enter image description here

$\endgroup$
  • $\begingroup$ Thanks, but I am not solely interested in just displaying matrices, but also simplifying integrals, expressions, etc... $\endgroup$ – Hawk Sep 23 '12 at 0:37
  • 6
    $\begingroup$ @jak Then use a more illustrative example... You can't make matrices the focus of your question and expect us to divine that you actually wanted to simplify integrals $\endgroup$ – rm -rf Sep 23 '12 at 0:59
  • 2
    $\begingroup$ Actually I just found the solution. Under "preference" and "evaluation" in Mathematica, we can switch the output cells to TraditionalForm $\endgroup$ – Hawk Sep 23 '12 at 2:05
  • $\begingroup$ Good to see you posting again, David. $\endgroup$ – Mr.Wizard Sep 23 '12 at 2:44
  • 1
    $\begingroup$ @Mr.Wizard My activity on SE highly depends on what I'm currently using. Blame Haskell for my inactivity :-) $\endgroup$ – David Sep 23 '12 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.