Wolfram Research, Inc.

1.10.9 Forms of Input and Output

Mathematica notebooks allow you to give input and get output in a variety of different forms. Typically the front end provides menu commands for converting cells from one form to another.

Forms of input and output.

The input here works in both InputForm and StandardForm.

In[1]:= x^2 + y^2/z

Out[1]=

Here is a version of the input appropriate for StandardForm.

In[2]:=

Out[2]=

InputForm is the most general form of input for Mathematica: it works whether you are using a notebook interface or a text-based interface.

With a notebook interface, output is by default produced in StandardForm.

In[3]:= Sqrt[x] + 1/(2 + Sqrt[y])

Out[3]=

With a text-based interface, OutputForm is used instead.

In[4]:= Sqrt[x] + 1/(2 + Sqrt[y]) // OutputForm

Out[4]//OutputForm= Sqrt[x] + (2 + Sqrt[y])^(-1)

Out[4]//OutputForm= " 1

Sqrt[x] + -----------

2 + Sqrt[y]"

With a notebook interface, the default form for both input and output is StandardForm.

The basic idea of StandardForm is to provide a precise but elegant representation of Mathematica expressions, making use of special characters, two-dimensional positioning, and so on.

Both input and output are given here in StandardForm.

In[5]:=

Out[5]=

An important feature of StandardForm is that any output you get in this form you can also directly use as input.

In[6]:=

Out[6]=

The precise nature of StandardForm prevents it from following all of the somewhat haphazard conventions of traditional mathematical notation. Mathematica however also supports TraditionalForm, which uses a large collection of rules to give a rather complete rendition of traditional mathematical notation.

TraditionalForm uses lower-case names for functions, and puts their arguments in parentheses rather than square brackets.

In[7]:=

Out[7]//TraditionalForm=

Here are a few transformations made by TraditionalForm.

In[8]:= {Abs[x], ArcTan[x], BesselJ[0, x], Binomial[i, j]} //

TraditionalForm

Out[8]//TraditionalForm=

TraditionalForm is often useful for generating output that can be inserted directly into documents which use traditional mathematical notation. But you should understand that TraditionalForm is intended primarily for output: it does not have the kind of precision that is needed to provide reliable input to Mathematica.

Thus, for example, in TraditionalForm, Ci(x) is the representation for both Ci[x] and CosIntegral[x], so if this form appears on its own as input, Mathematica will have no idea which of the two interpretations is the correct one.

In StandardForm, these three expressions are all displayed in a unique and unambiguous way.

In[9]:= { Ci[1+x], CosIntegral[1+x], Ci(1+x) } // StandardForm

Out[9]//StandardForm=

In TraditionalForm, however, the first two are impossible to distinguish, and the third differs only in the presence of an extra space.

In[10]:= { Ci[1+x], CosIntegral[1+x], Ci(1+x) } // TraditionalForm

Out[10]//TraditionalForm=

The ambiguities of TraditionalForm make it in general unsuitable for specifying input to the Mathematica kernel. But at least for sufficiently simple cases, Mathematica does include various heuristic rules for trying to interpret TraditionalForm expressions as Mathematica input.

Cells intended for input to the kernel are assumed by default to contain StandardForm expressions.

Here the front end was specifically told that input would be given in TraditionalForm. The cell bracket has a jagged line to indicate the difficulties involved.

Some situations in which TraditionalForm input can be expected to work.

Whenever Mathematica generates an expression in TraditionalForm, it automatically inserts various hidden tags so that the expression can later be interpreted unambiguously if it is given as input. And even if you edit the expression, the tags will often be left sufficiently undisturbed that unambiguous interpretation will still be possible.

This generates output in TraditionalForm.

In[11]:= Exp[I Pi x] // TraditionalForm

Out[11]//TraditionalForm=

Mathematica was told to expect TraditionalForm input here. The input was copied from the previous output line, and thus contains hidden tags that ensure the correct interpretation.

In[12]:=

Out[12]//StandardForm=

Simple editing often does not disturb the hidden tags.

In[13]:=

Out[13]//StandardForm=

If you enter a TraditionalForm expression from scratch, or import it from outside Mathematica, then Mathematica will still do its best to guess what the expression means. When there are ambiguities, what it typically does is to assume that you are using notation in whatever way is more common in elementary mathematical applications.

In TraditionalForm input, this is interpreted as a derivative.

In[14]:=

Out[14]//StandardForm=

This is interpreted as an arc tangent.

In[15]:=

Out[15]//StandardForm=

This is interpreted as the square of a tangent.

In[16]:=

Out[16]//StandardForm=

There is no particularly standard traditional interpretation for this; Mathematica assumes that it is 1/Tan[x]^2.

In[17]:=

Out[17]//StandardForm=

You should realize that TraditionalForm does not provide any kind of precise or complete way of specifying Mathematica expressions. Nevertheless, for some elementary purposes it may be sufficient, particularly if you use a few additional tricks.

A few tricks for TraditionalForm input.

With a space f (1 + x) is interpreted as multiplication. Without a space, g(1 + x) is interpreted as a function.

In[18]:=

Out[18]//StandardForm=

The ordinary e is interpreted as a symbol e. The special "exponential e", entered as ee, is interpreted as the exponential constant.

In[19]:=

Out[19]//StandardForm=