This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / The Mathematica Book / Practical Introduction / Building Up Calculations  /

1.2.1 Using Previous Results

In doing calculations, you will often need to use previous results that you have got. In Mathematica, % always stands for your last result.

Ways to refer to your previous results.

  • Here is the first result.
  • In[1]:= 77 ^ 2


  • This adds 1 to the last result.
  • In[2]:= % + 1


  • This uses both the last result, and the result before that.
  • In[3]:= 3 % + % ^ 2 + %%


    You will have noticed that all the input and output lines in Mathematica are numbered. You can use these numbers to refer to previous results.

  • This adds the results on lines 2 and 3 above.
  • In[4]:= %2 + %3


    If you use a text-based interface to Mathematica, then successive input and output lines will always appear in order, as they do in the dialogs in this book. However, if you use a notebook interface to Mathematica, as discussed in Section 1.0.1, then successive input and output lines need not appear in order. You can for example "scroll back" and insert your next calculation wherever you want in the notebook. You should realize that % is always defined to be the last result that Mathematica generated. This may or may not be the result that appears immediately above your present position in the notebook. With a notebook interface, the only way to tell when a particular result was generated is to look at the Out[n] label that it has. Because you can insert and delete anywhere in a notebook, the textual ordering of results in a notebook need have no relation to the order in which the results were generated.