# Is it possible to “pretty print” my input integral in Mathematica like Wolfram|Alpha does?

With Wolfram|Alpha, if I enter:

Integrate[r^3, {t, 0, 2Pi}, {r, 0, 2}, {z, r^2, 4}]


Wolfram|Alpha will pretty print my input like so:

Which is very readable, and I can easily check to make sure I entered in my bounds and integrand correctly. Were as if I entered that formula straight into Mathematica, it just spits out the answer and I have to manually inspect my raw input for typos.

So, my question is: Is it possible to nicely display formulas in Mathematica without using Wolfram|Alpha?

I want a way to convert my raw input "Integrate[r^3, {t, 0, 2Pi}, {r, 0, 2}, {z, r^2, 4}]" into a more human-friendly form.

(The problem with calling Wolfram|Alpha from Mathematica all the time is that it is slow, sometimes times out, requires internet, and is often much more noisy than I need.)

• Select cell -> Right click -> Convert to -> TraditionalForm – Sektor Nov 30 '14 at 21:55
• Also, typing Esc + int + Esc enters $\int$, which I've always found to be far more convenient than using the drop-down menus. – DumpsterDoofus Nov 30 '14 at 22:29
• @DumpsterDoofus Could use intt instead of int to get a complete template for the integral with placeholders for the bounds. – Sjoerd C. de Vries Dec 1 '14 at 7:13
• See reference.wolfram.com/language/guide/…, especially the Learning Resources part. – Sjoerd C. de Vries Dec 1 '14 at 7:16

Something like

heldint = HoldForm[Integrate[r^3, {t, 0, 2 Pi}, {r, 0, 2}, {z, r^2, 4}]];
int = ReleaseHold[heldint];

Row[{heldint, " \[LongEqual] ", int, " \[TildeTilde] ", N[int]}] // TraditionalForm


• Beautiful! I think I'll end up using // HoldForm // TraditionalForm as my preferred way to verify my input – Daryl Nov 30 '14 at 22:43
• Is there any way to convert those 3 lines of yours into a single function? So I could do something like Integrate[...] // Pretty and see exactly the output you showed – Daryl Nov 30 '14 at 22:46
• Got it: SetAttributes[Pretty, HoldAll]; Pretty[fn_] := (heldint = HoldForm[fn]; int = ReleaseHold[heldint]; Row[{heldint, " \[LongEqual] ", int, " \[TildeTilde] ", N[int]}] // TraditionalForm); – Daryl Nov 30 '14 at 22:54
• Yes. You could do int = fn; instead of int = ReleaseHold[heldint];. – Chip Hurst Dec 1 '14 at 5:22

TraditionalForm looks nice but it also incurs additional complexity in handling expressions. If you attempt to evaluate a TraditionalForm cell you will be asked if you wish to interpret it as input, and the equivalence is not always complete. Fortunately Mathematica is quite cabable of displaying formatted integrals in StandardForm.

If you merely wrap your expression in HoldForm and evaluate it you will get:

Integrate[r^3, {t, 0, 2 Pi}, {r, 0, 2}, {z, r^2, 4}] // HoldForm


You can convert the expression in place without evaluation by selecting it and using menu Cell > Convert To > StandardForm which under Windows has the keyboard shortcut Shift+Ctrl+N. Example:

Note the active syntax highlighting which is not present in TraditionalForm.

• IMO this is the answer OP was looking for. To be honest I didn't read the original question carefully and just provided a way to mimic Alpha's output. – Chip Hurst Dec 1 '14 at 5:15

Mathematica 10 introduced a new set of functions that can help with this:

    Inactive[Integrate][r^3, {t, 0, 2 Pi}, {r, 0, 2}, {z, r^2, 4}]


Or, obtaining same output:

    Inactivate[Integrate[r^3, {t, 0, 2 Pi}, {r, 0, 2}, {z, r^2, 4}]]


And then:

    Activate[%]
(* 32 Pi/3 *)


wiki answer. All the above solutions are fine, but I think Maple does this much simpler and I thought to show how Maple does it, may be future versions of M can adopt this. (in some way, can't use the same Upper/Lower trick ofcourse, since M commands already start with UpperCase)

In Maple, there is what is called the Inert form. Command that starts with upper case, do not evaluate. This way one can verify the command by typing Int instead of int then to actually evaluate, type value() on the form. Here is an example

You can see how simple it is.

update: Thanks Karsten comment, Mathematica in V10 seems to have adopted this using Inactive (I never used this command myself actually before...too many commands, too little time). But it seem to do what Inert in Maple does:

Very nice. I think I'll start using this more.

• Inactive seems to be the adoption made in v10. – Karsten 7. Dec 1 '14 at 4:28
• @Karsten7.: Yes, but will probably also work for v11, v12 and further on – Alexey Bobrick Dec 6 '14 at 14:49
• @Karsten7.: I would be happier if it had a "pretty" input like the output! :) Does it have such a thing? – H. R. Mar 17 '16 at 18:00
• @H.R. I'm not sure what you mean, but you can try 1) Using one of the Palettes 2) Marking the input, right click and choose Convert To StandardForm or TraditionalForm 3) Using InputAliases (for example Esc dintt Esc). – Karsten 7. Mar 17 '16 at 20:42
• @Karsten7.: Let me clarify myself. For example, active integration has a command form like Integrate[f[x],{x,a,b}]. Also, it has a pretty form which we can achieve by Esc+dintt+Esc. Does inactive integration has a pretty form like the latter case. – H. R. Mar 18 '16 at 11:22