This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / Textual Input and Output  /

2.8.5 Short and Shallow Output

When you generate a very large output expression in Mathematica, you often do not want to see the whole expression at once. Rather, you would first like to get an idea of the general structure of the expression, and then, perhaps, go in and look at particular parts in more detail.
The functions Short and Shallow allow you to see "outlines" of large Mathematica expressions.

Showing outlines of expressions.

  • This generates a long expression. If the whole expression were printed out here, it would go on for 23 lines.
  • In[1]:= t = Expand[(1 + x + y)^12] ;

  • This gives a one-line "outline" of t. The <<87>> indicates that 87 terms are omitted.
  • In[2]:= Short[t]


    When Mathematica generates output, it first effectively writes the output in one long row. Then it looks at the width of text you have asked for, and it chops the row of output into a sequence of separate "lines". Each of the "lines" may of course contain superscripts and built-up fractions, and so may take up more than one actual line on your output device. When you specify a particular number of lines in Short, Mathematica takes this to be the number of "logical lines" that you want, not the number of actual physical lines on your particular output device.

  • Here is a four-line version of t. More terms are shown in this case.
  • In[3]:= Short[t, 4]


  • You can use Short with other output forms, such as InputForm.
  • In[4]:= Short[InputForm[t]]


    Short works by removing a sequence of parts from an expression until the output form of the result fits on the number of lines you specify. Sometimes, however, you may find it better to specify not how many final output lines you want, but which parts of the expression to drop. Shallow[expr,


    ] includes only length arguments to any function, and drops all subexpressions that are below the specified depth.

  • Shallow shows a different outline of t.
  • In[5]:= Shallow[t]


  • This includes only 10 arguments to each function, but allows any depth.
  • In[6]:= Shallow[t, {Infinity, 10}]


    Shallow is particularly useful when you want to drop parts in a uniform way throughout a highly nested expression, such as a large list structure returned by Trace.

  • Here is the recursive definition of the Fibonacci function.
  • In[7]:= fib[n_] := fib[n-1] + fib[n-2] ; fib[0] = fib[1] = 1


  • This generates a large list structure.
  • In[8]:= tr = Trace[fib[8]] ;

  • You can use Shallow to see an outline of the structure.
  • In[9]:= Shallow[tr]


  • Short gives you a less uniform outline, which can be more difficult to understand.
  • In[10]:= Short[tr, 4]