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

Documentation / Mathematica / The Mathematica Book / A Practical Introduction to Mathematica / Input and Output in Notebooks /

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


Here is a version of the input appropriate for StandardForm.



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])


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.



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



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.



Here are a few transformations made by TraditionalForm.

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


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


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


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


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.



Simple editing often does not disturb the hidden tags.



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.



This is interpreted as an arc tangent.



This is interpreted as the square of a tangent.



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



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.



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