#cdf-show-file.cdf-text { top:105px; } .ObsBanner {color:black; width:430px; padding-left:7px; padding-right:7px; padding-top:6px; padding-bottom:6px; position:absolute; left:180px; top:125px; font-size:10px; font-weight:normal; font-family:Verdana, Arial, Helvetica, sans-serif; font-stretch:narrow; background:#fffdc8; border:solid 2px #ffbb33; line-height:16px; z-index:3;} .ObsBanner a:link {font-weight:bold; color:#cc6600;} .ObsBanner a:hover {font-weight:bold; color:#cc6600;} .ObsBanner a:visited {font-weight:bold; color:#cc6600;} THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
 MATHEMATICA TUTORIAL Related Tutorials »| Functions »

# The Interpretation of Textual Forms

 ToExpression[input] create an expression by interpreting strings or boxes

Converting from strings or boxes to expressions.

This takes a string and interprets it as an expression.
 Out[1]=
Here is the box structure corresponding to the textual form of an expression in StandardForm.
 Out[2]=
ToExpression interprets this box structure and yields the original expression again.
 Out[3]=
In any Mathematica session, Mathematica is always effectively using ToExpression to interpret the textual form of your input as an actual expression to evaluate.
If you use the notebook front end for Mathematica, then the interpretation only takes place when the contents of a cell are sent to the kernel, say for evaluation. This means that within a notebook there is no need for the textual forms you set up to correspond to meaningful Mathematica expressions; this is only necessary if you want to send these forms to the kernel.
 FullForm explicit functional notation InputForm one-dimensional notation StandardForm two-dimensional notation

The hierarchy of forms for standard Mathematica input.

Here is an expression entered in FullForm.
 Out[4]=
Here is the same expression entered in InputForm.
 Out[5]=
And here is the expression entered in StandardForm.
 Out[6]=
Built into Mathematica is a collection of standard rules for use by ToExpression in converting textual forms to expressions.
These rules define the grammar of Mathematica. They state, for example, that should be interpreted as Plus, and that should be interpreted as Power. If the input you give is in FullForm, then the rules for interpretation are very straightforward: every expression consists just of a head followed by a sequence of elements enclosed in brackets. The rules for InputForm are slightly more sophisticated: they allow operators such as , , and , and understand the meaning of expressions where these operators appear between operands. StandardForm involves still more sophisticated rules, which allow operators and operands to be arranged not just in a one-dimensional sequence, but in a full two-dimensional structure.
Mathematica is set up so that FullForm, InputForm, and StandardForm form a strict hierarchy: anything you can enter in FullForm will also work in InputForm, and anything you can enter in InputForm will also work in StandardForm.
If you use a notebook front end for Mathematica, then you will typically want to use all the features of StandardForm. If you use a text-based interface, however, then you will typically be able to use only features of InputForm.
When you use StandardForm in a Mathematica notebook, you can enter directly two-dimensional forms such as or annotated graphics. But InputForm allows only one-dimensional forms.
If you copy a StandardForm expression whose interpretation can be determined without evaluation, then the expression will be pasted into external applications as InputForm. Otherwise, the text is copied in a linear form that precisely represents the two-dimensional structure using . When you paste this linear form back into a Mathematica notebook, it will automatically "snap" into two-dimensional form.
 ToExpression[input,form] attempt to create an expression assuming that input is given in the specified textual form

Importing from other textual forms.

StandardForm and its subsets FullForm and InputForm provide precise ways to represent any Mathematica expression in textual form. And given such a textual form, it is always possible to convert it unambiguously to the expression it represents.
TraditionalForm is an example of a textual form intended primarily for output. It is possible to take any Mathematica expression and display it in TraditionalForm. But TraditionalForm does not have the precision of StandardForm, and as a result there is in general no unambiguous way to go back from a TraditionalForm representation and get the expression it represents.
Nevertheless, ToExpression[input, TraditionalForm] takes text in TraditionalForm and attempts to interpret it as an expression.
This takes a string and interprets it as TraditionalForm input.
 Out[7]=
In StandardForm the same string would mean a product of terms.
 Out[8]=
When TraditionalForm output is generated as the result of a computation, the actual collection of boxes that represent the output typically contains special Interpretation objects or other specially tagged forms that specify how an expression can be reconstructed from the TraditionalForm output.
The same is true of TraditionalForm that is obtained by explicit conversion from StandardForm. But if you edit TraditionalForm extensively, or enter it from scratch, then Mathematica will have to try to interpret it without the benefit of any additional embedded information.
 Site Index Choose Language