2.9.1 Forms of Input and Output
|Here is one way to enter a particular expression. || |
|Here is another way to enter the same expression. || |
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. || |
|OutputForm uses only ordinary keyboard characters and is the default for text-based interfaces to Mathematica. || |
OutputForm[ x^2 + Sqrt[y] ]
|InputForm yields a form that can be typed directly on a keyboard. || |
InputForm[ x^2 + Sqrt[y] ]
|FullForm shows the internal form of an expression in explicit functional notation. || |
FullForm[ x^2 + Sqrt[y] ]
Some output forms for expressions.
|FullForm[expr] ||the internal form of an expression |
|InputForm[expr] ||a form suitable for direct keyboard input |
|OutputForm[expr] ||a two-dimensional form using only keyboard characters |
|StandardForm[expr] ||the default form used in Mathematica notebooks |
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. || |
TraditionalForm[ x^2 + Sqrt[y] + Gamma[z] EllipticK[z] ]
|TeXForm yields output suitable for export to TeX. || |
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. || |
CForm[ x^2 + Sqrt[y] ]
|FortranForm yields output suitable for export to Fortran. || |
FortranForm[ x^2 + Sqrt[y] ]
Output forms not normally used for Mathematica input.
|TraditionalForm[expr] ||traditional mathematical notation |
|TeXForm[expr] ||output suitable for export to TeX|
|MathMLForm[expr] ||output suitable for use with MathML on the web |
|CForm[expr] ||output suitable for export to C |
|FortranForm[expr] ||output suitable for export to Fortran |
Section 2.9.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.
|• Exchange textual representations of expressions. |
|• Exchange expressions directly via MathLink. |