# 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 Commented Nov 30, 2014 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. Commented Nov 30, 2014 at 22:29
• @DumpsterDoofus Could use intt instead of int to get a complete template for the integral with placeholders for the bounds. Commented Dec 1, 2014 at 7:13
• See reference.wolfram.com/language/guide/…, especially the Learning Resources part. Commented Dec 1, 2014 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 Commented Nov 30, 2014 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 Commented Nov 30, 2014 at 22:46
• Got it: SetAttributes[Pretty, HoldAll]; Pretty[fn_] := (heldint = HoldForm[fn]; int = ReleaseHold[heldint]; Row[{heldint, " \[LongEqual] ", int, " \[TildeTilde] ", N[int]}] // TraditionalForm); Commented Nov 30, 2014 at 22:54
• Yes. You could do int = fn; instead of int = ReleaseHold[heldint];. Commented Dec 1, 2014 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. Commented Dec 1, 2014 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. Commented Dec 1, 2014 at 4:28
• @Karsten7.: Yes, but will probably also work for v11, v12 and further on Commented Dec 6, 2014 at 14:49
• @Karsten7.: I would be happier if it had a "pretty" input like the output! :) Does it have such a thing? Commented Mar 17, 2016 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). Commented Mar 17, 2016 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. Commented Mar 18, 2016 at 11:22