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

ContentsHow Input and Output Work

2.8.1 Forms of Input and Output

Here is one way to enter a particular expression.

In[1]:= x^2 + Sqrt[y]


Here is another way to enter the same expression.

In[2]:= Plus[Power[x, 2], Sqrt[y]]


With a notebook front end, you can also enter the expression directly in this way.



Mathematica allows you to output expressions in many different ways.

In Mathematica notebooks, expressions are by default output in StandardForm.

In[4]:= x^2 + Sqrt[y]


OutputForm uses only ordinary keyboard characters and is the default for text-based interfaces to Mathematica.

In[5]:= OutputForm[ x^2 + Sqrt[y] ]

Out[5]//OutputForm= x^2 + Sqrt[y]

Out[5]//OutputForm= " 2

x + Sqrt[y]"

InputForm yields a form that can be typed directly on a keyboard.

In[6]:= InputForm[ x^2 + Sqrt[y] ]

Out[6]//InputForm= x^2 + Sqrt[y]

FullForm shows the internal form of an expression in explicit functional notation.

In[7]:= FullForm[ x^2 + Sqrt[y] ]


Some output forms for expressions.

Output forms provide textual representations of Mathematica expressions. In some cases these textual representations are also suitable for input to Mathematica. But in other cases they are intended just to be looked at, or to be exported to other programs, rather than to be used as input to Mathematica.

TraditionalForm uses a large collection of ad hoc rules to produce an approximation to traditional mathematical notation.

In[8]:= TraditionalForm[ x^2 + Sqrt[y] + Gamma[z] EllipticK[z] ]


TeXForm yields output suitable for export to TeX.

In[9]:= TeXForm[ x^2 + Sqrt[y] ]

Out[9]//TeXForm= x^2 + {\sqrt{y}}

CForm yields output that can be included in a C program. Macros for objects like Power are included in the header file mdefs.h.

In[10]:= CForm[ x^2 + Sqrt[y] ]

Out[10]//CForm= Power(x,2) + Sqrt(y)

FortranForm yields output suitable for export to Fortran.

In[11]:= FortranForm[ x^2 + Sqrt[y] ]

Out[11]//FortranForm= x**2 + Sqrt(y)

Output forms not normally used for Mathematica input.

Section 2.8.17 will discuss how you can create your own output forms. You should realize however that in communicating with external programs it is often better to use MathLink to send expressions directly than to generate a textual representation for these expressions.

Two ways to communicate between Mathematica and other programs.

ContentsHow Input and Output Work