Sample Notebook

Demonstrating Cells and Their Expression Representation

CPSC 215 — Fall 2001

Section 1: Introduction

In Mathematica, everything that is typed into a FrontEnd interface window is internally represented as a symbolic expression.

You can inspect the internal representation of a cell by selecting it and using the menu item Format ⟶ Show Expression.

This will display the internal representation of the cell. Switch back to the original, formatted visualization by using the same menu command.

Section 2: More Complicated Examples

Formulas

How are more complicated formulas and two-dimensional layouts represented?

Here is a formula. Check out its internal cell representation.

((Sqrt[x])/2)

Or a summation:

(∑_(n = 1)^5) (n^2)

Or a matrix:

(({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}))

Programs and Function Definitions

A simple function definition

cube[x_] := (x^3)

cube[4]

Several definitions in a single cell

a = 3;
b = 4;
f[x_Integer, y_Integer] := x + y

    
f[a, b]

A more complex function definition

g[lst_List] := 
Module[{x = 
            Length[lst]}, 

lst/
          x
]

g[{1, 2, 3}]

Section 3: Graphics

Apart from the symbolic representation of the graphics object (g in the example below), check out the representation in the cell.

g = Plot[Sin[x], {x, 0, 2  Pi}];

If you select the above graphics cell and choose Format ⟶ Show Expression, you will see that the "drawing format" is PostScript. This PostScript format is widely used on laser printers today, as PostScript is a two-dimensional formatting language.