This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / Textual Input and Output /

2.9.2 How Input and Output Work

Steps in the operation of Mathematica.

When you type something like x^2 what Mathematica at first sees is just the string of characters x, ^, 2. But with the usual way that Mathematica is set up, it immediately knows to convert this string of characters into the expression Power[x, 2].

Then, after whatever processing is possible has been done, Mathematica takes the expression Power[x, 2] and converts it into some kind of textual representation for output.

Mathematica reads the string of characters x, ^, 2 and converts it to the expression Power[x, 2].

In[1]:= x ^ 2


This shows the expression in Fortran form.

In[2]:= FortranForm[%]

Out[2]//FortranForm= x**2

FortranForm is just a "wrapper": the value of Out[2] is still the expression Power[x, 2].

In[3]:= %


It is important to understand that in a typical Mathematica session In[n] and Out[n] record only the underlying expressions that are processed, not the textual representations that happen to be used for their input or output.

If you explicitly request a particular kind of output, say by using TraditionalForm[expr], then what you get will be labeled with Out[n]//TraditionalForm. This indicates that what you are seeing is expr//TraditionalForm, even though the value of Out[n] itself is just expr.

Mathematica also allows you to specify globally that you want output to be displayed in a particular form. And if you do this, then the form will no longer be indicated explicitly in the label for each line. But it is still the case that In[n] and Out[n] will record only underlying expressions, not the textual representations used for their input and output.

This sets t to be an expression with FortranForm explicitly wrapped around it.

In[4]:= t = FortranForm[x^2 + y^2]

Out[4]//FortranForm= x**2 + y**2

The result on the previous line is just the expression.

In[5]:= %


But t contains the FortranForm wrapper, and so is displayed in FortranForm.

In[6]:= t

Out[6]//FortranForm= x**2 + y**2

Wherever t appears, it is formatted in FortranForm.

In[7]:= {t^2, 1/t}