Effectively Using Notebooks in Version 11.3

John Fultz, wolfram research, inc.

Outline

What Is a Notebook?

Some Patterns for Notebook Usage

Power Notebook Usage

A Notebook Is a Structured Document

The structure is delineated by the “cell.”

Cells typically have distinct brackets on the right.

A cell may contain narrative text, code, math, images or some combination.

This is a narrative cell.

StringReverse["This is an input cell with code which can be evaluated."]

ExampleData[{"TestImage3D","CTengine"}] (* this produces an inline image *)

Solve[a (x^2)+b x + c == 0, x] (* this code has typeset math *)

The Structure of a Notebook Is Hierarchical

Cells can be grouped, and groups can be collapsed.

By default, some cell styles automatically group other styles.

Cell grouping can be performed manually, too.

This Is a Subsection Cell; It Groups Many Other Cell Types

This is a subsubsection cell. It is grouped by the subsection cell.

This is a text cell.

StringSplit["Input cells form their own groups with output cells."]

The Notebook’s Styles Are Defined in a Stylesheet

Styles are displayed in the Format ▶ Styles menu.

The most common styles can be accessed via keyboard shortcuts.

It is easy to add a new style to a given notebook.

A cell with some style

Notebooks Help You Track the History of Computation

In and Out numbers track evaluations in the current session.

Inputs and outputs from earlier sessions have different In/Out flagging.

Mismatched inputs and outputs are called out with dimmed outputs.

(* Evaluate this to see In/Out lines *) 
Table[RandomInteger[],10]

(* Quitting the session removes the numbers, but leaves the labels *)
Quit

(* Making changes to the input will dim the output *)
Plot3D[Cos[x y], {x, 0, 2π},{y,0,2π}]

Notebook Environment Supports Rich Wolfram Language™ Authoring Experience

Triple-clicking establishes useful structured selections in code.

Use Ctrl+. (Ctrl+period) to expand selections.

Code editor provides completions, templates and other Wolfram Language facilities.

A random bit of input to demonstrate various selection modes

Manipulate[
Graphics[GeometricTransformation[First[ArrayPlot[CellularAutomaton[30,{{1},0},20]]],{{a,b},{c,d}}],PlotLabel->NumberForm[MatrixForm[{{a,b},{c,d}}],2]],
{{a,1},-2,2},{{b,0},-2,2},{{c,0},-2,2},{{d,1},-2,2}]

Notebooks Support Rich Data Embedding

Outputs can be turned into inputs; this can help break the dependencies on external data files not available to other readers of your notebook.

Use of non-textual inputs allows for more a comprehensible programming experience.

Data can be “iconized” into concise notebook representations.

(* Instead of repeatedly fetching this image from the web, embed it into the notebook *)
Import["http://www.wolfram.com/homepage/img/feature-system-modeler-5.png"]

(* Or embed a large dataset into the notebook *)Iconize[Import["https://github.com/fivethirtyeight/data/raw/master/nba-elo/nbaallelo.csv"], "FiveThirtyEight NBA data"]

Notebooks Are Fully Computable Entities

Notebook elements are discoverable objects that can be manipulated.

Notebooks can be easily scraped using NotebookImport.

Notebooks and cells are represented as symbolic expressions that can be processed by Wolfram Language programs.

c=EvaluationCell[]

CurrentValue[c, Background]=LightBlue;

ListPicker[None,NotebookImport[EvaluationNotebook[],"Item"->"Text"]]

NotebookRead[c]

NotebookWrite[EvaluationNotebook[],% /. "c"->"theCell"]

Notebooks Can Be Documents, Interfaces or Any Combination

Create embedded interfaces using Manipulate.

The help system uses fully interactive notebooks.

Notebooks can become dialog boxes and palettes.

Manipulate[Module[{img=ColorQuantize[,colors]},Column[{img,ImageHistogram[img]}]],{colors,2,10,1}]