100% found this document useful (1 vote)
22 views57 pages

Programming With Mathematica 4th Revised Edition Edition Paul Wellin PDF Download

The document provides information about the 4th Revised edition of 'Programming with Mathematica' by Paul Wellin, which covers foundational material for understanding the Mathematica language with practical problem-solving emphasis. It includes over 285 exercises and is suitable for self-study, with additional resources available online. The book is designed for a wide range of applications in fields such as science, engineering, and finance, and assumes no prior programming knowledge.

Uploaded by

oicdogvtq928
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
22 views57 pages

Programming With Mathematica 4th Revised Edition Edition Paul Wellin PDF Download

The document provides information about the 4th Revised edition of 'Programming with Mathematica' by Paul Wellin, which covers foundational material for understanding the Mathematica language with practical problem-solving emphasis. It includes over 285 exercises and is suitable for self-study, with additional resources available online. The book is designed for a wide range of applications in fields such as science, engineering, and finance, and assumes no prior programming knowledge.

Uploaded by

oicdogvtq928
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Programming with Mathematica 4th Revised edition

Edition Paul Wellin download pdf

https://ebookfinal.com/download/programming-with-mathematica-4th-
revised-edition-edition-paul-wellin/

Visit ebookfinal.com today to download the complete set of


ebook or textbook!
Here are some recommended products that we believe you will be
interested in. You can click the link to download.

An introduction to programming with Mathematica 3rd


Edition Paul R. Wellin

https://ebookfinal.com/download/an-introduction-to-programming-with-
mathematica-3rd-edition-paul-r-wellin/

Beginning Programming With Python For Dummies 1st Edition


John Paul Mueller

https://ebookfinal.com/download/beginning-programming-with-python-for-
dummies-1st-edition-john-paul-mueller/

Programming architecture Paul Coates

https://ebookfinal.com/download/programming-architecture-paul-coates/

CRC standard curves and surfaces with Mathematica Third


Edition Von Seggern

https://ebookfinal.com/download/crc-standard-curves-and-surfaces-with-
mathematica-third-edition-von-seggern/
Agile Web Development with Rails 4 4th Revised edition
Edition Sam Ruby

https://ebookfinal.com/download/agile-web-development-with-
rails-4-4th-revised-edition-edition-sam-ruby/

Introduction to the mathematics of operations research


with Mathematica 2. ed Edition Hastings

https://ebookfinal.com/download/introduction-to-the-mathematics-of-
operations-research-with-mathematica-2-ed-edition-hastings/

Murach s ASP NET 4 Web programming with C 2010 4th ed


Edition Boehm

https://ebookfinal.com/download/murach-s-asp-net-4-web-programming-
with-c-2010-4th-ed-edition-boehm/

Murach s ADO NET 4 Database Programming with C 2010 4th


Edition Anne Boehm

https://ebookfinal.com/download/murach-s-ado-net-4-database-
programming-with-c-2010-4th-edition-anne-boehm/

Functional Programming in Scala 1st Edition Paul Chiusano

https://ebookfinal.com/download/functional-programming-in-scala-1st-
edition-paul-chiusano/
Programming with Mathematica 4th Revised edition
Edition Paul Wellin Digital Instant Download
Author(s): Paul Wellin
ISBN(s): 9781107009462, 1107009464
Edition: 4th Revised edition
File Details: PDF, 11.27 MB
Year: 2013
Language: english
more information - www.cambridge.org/9781107009462
Programming with MathematicaR
An Introduction

Starting from first principles, this book covers all of the foundational material needed to
develop a clear understanding of the Mathematica language, with a practical emphasis on
solving problems. Concrete examples throughout the text demonstrate how Mathematica
can be used to solve problems in science, engineering, economics/finance, computational
linguistics, geoscience, bioinformatics, and a range of other fields.
r Assumes no formal knowledge of programming.
r Over 285 exercises give the reader plenty of practice using the language to solve problems.
r Ideal for self-study, or for anyone wishing to further their understanding of Mathematica.
r Mathematica notebooks containing examples, programs and solutions to exercises are
available from www.cambridge.org/wellin.

Paul Wellin worked for Wolfram Research from the early-1990s through 2011, directing the
Mathematica training efforts with the Wolfram Education Group. He has taught mathemat-
ics at both public schools and at the university level for over 12 years. He has given talks,
workshops, and seminars around the world on the integration of technical computing and
education and he has served on numerous government advisory panels on these issues. He
is the author of several books on Mathematica.
Programming with Mathematica
R

An Introduction

PAUL WELLIN
cambridge university press
Cambridge, New York, Melbourne, Madrid, Cape Town,
Singapore, São Paulo, Delhi, Mexico City
Cambridge University Press
The Edinburgh Building, Cambridge CB2 8RU, UK
Published in the United States of America by Cambridge University Press, New York

www.cambridge.org
Information on this title: www.cambridge.org/9781107009462


C Paul Wellin 2013

Text set in DTL Albertina 11/13 pt; captions set in Syntax LT System Mathematica
R
.
Designed and typeset by the author.

This publication is in copyright. Subject to statutory exception


and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.

First published 2013

Printed and bound in the United Kingdom by the MPG Books Group

Page 8. Photographs used courtesy of NASA.


Page 343. Quotation from “The Library of Babel” by Jorge Luis Borges. Translated by James E. Irby,
from LABYRINTHS, copyright  C 1962, 1964 by New Directions Publishing Corp.
Reprinted by permission of New Directions Publishing Corp.
Page 472. Bottom: Marcel Duchamp, “Roue de bicyclette” 
C 2012 Artists Rights Sociery (ARS),
New York / ADAGP, Paris / Succession Marcel Duchamp.

A catalogue record for this publication is available from the British Library

ISBN 978-1-107-00946-2 Hardback

Additional resources for this publication at www.cambridge.org/wellin

Mathematica and Wolfram Mathematica are registered trademarks of Wolfram Research, Inc.

Cambridge University Press has no responsibility for the persistence or


accuracy of URLs for external or third-party internet websites referred to
in this publication and does not guarantee that any content on such
websites is, or will remain, accurate or appropriate.
Contents

Preface · page xi

1 An introduction to Mathematica
1.1 Overview of basic operations · 1
Numerical and symbolic computation · Graphics and visualization · Working with data · Dynamic
interactivity · Programming

1.2 Getting started · 14


Starting up Mathematica · The notebook interface · Entering input · Mathematical expressions · Syntax of
functions · Lists · Semicolons · Alternative input syntax · Comments · Errors · Getting out of trouble · The front
end and the kernel

1.3 Getting help · 25


Function information · The Documentation Center

2 The Mathematica language


2.1 Expressions · 29
Types of expressions · Atoms · Structure of expressions · Evaluation of expressions · Exercises

2.2 Definitions · 40
Defining variables and functions · Immediate vs. delayed assignments · Term rewriting · Functions with
multiple definitions · Exercises

2.3 Predicates and Boolean operations · 48


Predicates · Relational and logical operators · Exercises

2.4 Attributes · 53
Exercises
vi Contents

3 Lists
3.1 Creating and displaying lists · 58
List structure and syntax · List construction · Displaying lists · Arrays · Exercises

3.2 The structure of lists · 67


Testing a list · Measuring lists · Exercises

3.3 Operations on lists · 70


Extracting elements · Rearranging lists · List component assignment · Multiple lists · Exercises

4 Patterns and rules


4.1 Patterns · 85
Blanks · Pattern matching by type · Structured patterns · Sequence pattern matching · Conditional pattern
matching · Alternatives · Repeated patterns · Functions that use patterns · Exercises

4.2 Transformation rules · 102


Creating and using replacement rules · Example: counting coins · Example: closed paths · Example: finding
maxima · Exercises

4.3 Examples and applications · 109


Finding subsequences · Sorting a list · Exercises

5 Functional programming
5.1 Introduction · 116
5.2 Functions for manipulating expressions · 118
Map · Apply · Thread and MapThread · The Listable attribute · Inner and Outer · Select and Pick · Exercises

5.3 Iterating functions · 132


Nest · FixedPoint · NestWhile · Fold · Exercises

5.4 Programs as functions · 137


Building up programs · Example: shuffling cards · Compound functions · Exercises

5.5 Scoping constructs · 146


Localizing names: Module · Localizing values: Block · Localizing constants: With · Example: matrix
manipulation · Exercises

5.6 Pure functions · 153


Syntax of pure functions · Using pure functions · Example: searching for attributes and options · Exercises ·
Contents vii

5.7 Options and messages · 164


Options · Messages · Exercises

5.8 Examples and applications · 170


Hamming distance · The Josephus problem · Regular graphs/polygons · Protein interaction networks · Palettes
for project files · Operating on arrays · Exercises

6 Procedural programming
6.1 Loops and iteration · 190
Newton’s method · Do loops and For loops · Example: random permutations · While loops · NestWhile and
NestWhileList · Exercises

6.2 Flow control · 208


Conditional functions · Piecewise-defined functions · Which and Switch · Argument checking · Exercises

6.3 Examples and applications · 219


Classifying points · Sieve of Eratosthenes · Sorting algorithms · Exercises

7 Recursion
7.1 Fibonacci numbers · 231
Exercises

7.2 Thinking recursively · 234


Length of a list · Recursion with multiple arguments · Multiplying pairwise elements · Dealing cards,
recursively · Finding maxima · Higher-order functions · Exercises

7.3 Dynamic programming · 239


Exercises

7.4 Classical examples · 244


Merge sort · Run-length encoding · Exercises

8 Numerics
8.1 Numbers in Mathematica · 251
Types of numbers · Digits and number bases · Random numbers · Exercises

8.2 Numerical computation · 265


Precision and accuracy · Representation of approximate numbers · Exact vs. approximate numbers · High
precision vs. machine precision · Computations with mixed number types · Working with precision and
accuracy · Exercises
viii Contents

8.3 Arrays of numbers · 282


Sparse arrays · Packed arrays · Exercises

8.4 Examples and applications · 291


Newton’s method revisited · Radius of gyration of a random walk · Statistical tests · Exercises

9 Strings
9.1 Structure and syntax · 310
Character codes · Sorting lists of characters · Ordered words · Exercises

9.2 Operations on strings · 316


Basic string operations · Strings vs. lists · Encoding text · Indexed symbols · Anagrams · Exercises

9.3 String patterns · 325


Finding subsequences with strings · Alternatives · Exercises

9.4 Regular expressions · 332


Word stemming · Exercises

9.5 Examples and applications · 343


Random strings · Partitioning strings · Adler checksum · Search for substrings · DNA sequence analysis ·
Displaying DNA sequences · Blanagrams · Exercises

10 Graphics and visualization


10.1 Structure of graphics · 365
Graphics primitives · Graphics directives · Graphics options · Combining graphics elements · Structure of built-
in graphics functions · Example: Bézier curves · Example: hypocycloids · Exercises

10.2 Efficient structures · 386


Multi-objects · GraphicsComplex · Numeric vs. symbolic expressions · Exercises

10.3 Sound · 396


The sound of mathematics · Sound primitives and directives · Exercises

10.4 Examples and applications · 402


Space filling plots · Plotting lines in space · Simple closed paths · Points in a polygon · Visualizing standard
deviations · Root plotting · Trend plots · Brownian music · Exercises

11 Dynamic expressions
11.1 Manipulating expressions · 449
Control objects · Control wrapper · Viewers · Animating the hypocycloid · Visualizing logical operators ·
Exercises
Contents ix

11.2 The structure of dynamic expressions · 470


Dynamic · DynamicModule · Dynamic tips · Exercises

11.3 Examples and applications · 481


Creating interfaces for visualizing data · File openers · Dynamic random walks · Apollonius' circle · Exercises

12 Optimizing Mathematica programs


12.1 Measuring efficiency · 494
Evaluation time · Memory storage

12.2 Efficient programs · 496


Low-level vs. high-level functions · Pattern matching · Reducing size of computation · Symbolic vs. numeric
computation · Listability · Pure functions · Packed arrays · Exercises

12.3 Parallel processing · 515


Basic examples · Distributing definitions across subkernels · Profiling · Exercises

12.4 Compiling · 523


Compile · Compiling to C · Exercises

13 Applications and packages


13.1 Random walk application · 534
Lattice walks · Off-lattice walks · RandomWalk · Error and usage messages · Visualization · Animation ·
Exercises

13.2 Overview of packages · 555


Working with packages · Package location

13.3 Contexts · 558

13.4 Creating packages · 563


Package framework · Creating and installing the package · RandomWalks package · Running the package ·
Exercises
x Contents

Solutions to exercises
2 The Mathematica language · 575
3 Lists · 578
4 Patterns and rules · 582
5 Functional programming · 588
6 Procedural programming · 614
7 Recursion · 621
8 Numerics · 626
9 Strings · 638
10 Graphics and visualization · 651
11 Dynamic expressions · 666
12 Optimizing Mathematica programs · 676
13 Applications and packages · 681

Bibliography · 687

Index · 695
Preface
Programming with Mathematica
Well-designed tools are not simply things of beauty to be admired. They are, above all, a joy to
use. They seem to have their own consistent and readily apparent internal logic; using them
seems natural – intuitive even – in that it is hard to imagine using any other tool, and, typically, a
minimal amount of effort is required to solve the problem for which those tools were designed.
You might even begin to think that your problems were designed for the tool rather than the
other way around.
Programming with Mathematica is, first and foremost, a joy. Having used various programming
languages throughout my life (starting with Algol and Fortran), it is now hard for me to
imagine using a tool other than Mathematica to solve most of the computational problems that I
encounter. Having at my fingertips an extremely well-thought-out language, combined with
tools for analysis, modeling, simulation, visualization, interface creation, connections to other
technologies, import and export, seems to give me everything I might need.
Ultimately though, no tool can solve every problem you might encounter; what really makes
Mathematica the indispensable tool for many computational scientists, engineers, and even artists
and musicians, is its capability for infinite extension through programming. As a language, built
upon the shoulders of such giants as Lisp, Prolog, Apl and C++, Mathematica has extended some
of the best ideas from these languages and created some new ones of its own. A powerful pattern
matching language together with a rule-based paradigm for transforming expressions provides
for a natural approach to writing programs to solve problems. By “natural” I mean a quick and
direct implementation, one that mirrors as closely as possible the statement of the problem to be
solved. From there, it is just a short path to prototyping and eventually a program that can be
tested for correctness and efficiency.
But there are tools, and there are tools! Some tools are very domain-specific, meaning that they
are designed for a narrow set of tasks defined by a certain discipline or framework and are inap-
propriate for tasks outside of their domain. But Mathematica has taken a different approach. It
provides broadly useful tools by abstracting the computational tasks (through symbolic expres-
sion manipulation) in such a way that it has found wide use in fields as varied as genomics and
bioinformatics, astronomy, image processing, social networks, linguistics, and much more.
xii Preface

In addition to the breadth of fields that can be addressed with Mathematica, the variety and
extent of the computational tasks that now challenge us have greatly expanded since the turn of
the millennium. This is due to the explosion in the sheer amount of information and data that
people study. This expansion mirrors the rapid growth in computer hardware capabilities of the
1990s and 2000s which saw speed and storage grow exponentially. Now the challenge is to find
software solutions that are up to the task of managing this growth in information and data. Given
the variety of data objects that people are interested in studying, tools that provide generality and
avoid domain-specific solutions will be the most broadly useful across disciplines and across
time. Mathematica has been around now for over two decades and it continues to find application
in surprising places.

Using this book


This book is designed for anyone who wants to learn how to write Mathematica programs to solve
problems. It does not presuppose a formal knowledge of programming principles as taught in a
modern course on a language such as C or Java, but there is quite a bit of overlap between this
material and what you would expect in such a formal course. You will learn about the basic
building blocks of the Mathematica language: expressions; the syntax of that language; and how to
put these objects together to make more complicated expressions. But it is more than just a
primer on the language. The focus is on solving problems and, as such, this is an example-driven
book. The approach here is practical. Programming is about solving problems and besides the
obvious necessity of learning the rules of the language, many people find it instructive and
concrete to see concepts put into action. The book is packed with examples both in the text
proper and in the exercises. Some of these examples are quite simple and straightforward and can
be understood with a modicum of understanding of Mathematica. Other examples and exercises
are more involved and may require a bit more study before you feel that you have mastered the
underlying concepts and can apply them to related problems. Since this book is written for
readers with various backgrounds in programming languages and using Mathematica, I think it
best to not identify “levels of difficulty” with the examples and exercises.
Becoming a proficient programmer requires not only a clear understanding of the language
but also practice using it. As such, one of the aims of this book is to provide the novice with
examples of good programming style and practice. Many of the examples in the chapters are, by
design, concise, in order to focus on a concept that is being developed. More involved examples
drawing together several different conceptual ideas appear in the examples and applications
sections at the end of many of the chapters. Depending upon your needs and level of expertise,
you can either start with first principles, move on to basic examples, and then to more involved
applications of these concepts, or you might find yourself looking at interesting examples and
then, as the need arises, jumping back into the discussion of syntax or usage earlier in a chapter.
Preface xiii

The exercises (over 290 of them) are designed to extend and expand upon the topics discussed
in the chapters in which they occur. You cannot learn how to program by simply reading a book;
the old maxim, “you learn by doing” is as true of learning how to speak a foreign (natural) lan-
guage as it is true of learning a computer programming language. Try to do as many exercises as
you can; create and solve problems that interest you; “life is not a spectator sport” and neither is
learning how to program.
Due to resource limitations, all the solutions could not be included in the printed book. Fortu-
nately, we live in an age of easily disseminated information, and so you will find an extended set
of solutions to most of the exercises in both notebook and PDF format at www.cam-
bridge.org/wellin. In addition, many of the programs developed in the sections and exercises are
included as packages at the same website.

Scope of this book


This book evolved from an earlier project, An Introduction to Programming with Mathematica, the
third edition of which was also published by Cambridge University Press. As a result of several
factors, including a long time between editions, much new material due to major upgrades in
Mathematica, the original authors traveling different paths – it seemed as if a new title was in
order, one that both reflects and builds upon this history while incorporating the latest elements
of Mathematica itself.
The several versions of Mathematica that have been released since the third edition of An
Introduction to Programming with Mathematica was published now include extensive coverage in new
application areas, including image processing, control systems, wavelets, graphs and networks,
and finance. The present book draws from many of these areas in the never-ending search for
good examples that not only help to illustrate conceptual problems, but also serve as interesting
and enlightening material on their own. The examples, exercises, and applications draw from a
variety of fields, including:
Ê textual analysis and natural language processing: corpus linguistics, word stemming, stop words,
comparative textual analysis, scraping websites for data, sorting strings, bigrams and n-
grams, word games (anagrams, blanagrams, palindromes), filtering text;
Ê bioinformatics: analysis of nucleotide sequences, computing GC ratios, displaying blocks of
genetic information, searching for subsequences, protein-protein interaction networks, dot
plots;
Ê computer science: hashing (checksums), encoding/encryption, sorting, adjacency structures,
triangular numbers, Hamming numbers, Fibonacci numbers, Euler numbers, root finders,
random number generation algorithms, sieving;
Ê finance and economics: time-series analysis, trend plots, stock screens;
xiv Preface

Ê data analysis: filtering signals, cleaning data, stem plots, statistical tests, lag plots,
correlograms, visualizing spread of data;
Ê geometry: convex hull, diameter of pointsets, point-in-polygon problems, traveling salesman-
type problems, hypocycloids and epicycloids, Apollonius’ circle;
Ê image processing: resizing, filtering, segmentation;
Ê graphs and networks: random graphs, regular graphs, bond percolation, connected
components.

Chapter 1 is designed as a brief tour of the current version of Mathematica as of the publication
of this book. The examples give a sense of the scope of Mathematica’s usage in science, engineer-
ing, and other analytic fields. Included is a basic introduction to the syntax of Mathematica expres-
sions, working with the Mathematica interface, and also pointers to the documentation features.
Several important topics are introduced in Chapter 2 that are used throughout the book, in
particular, structure of expressions, evaluation of expressions, various aspects of function defini-
tions, predicates, relational and logical operators, and attributes.
Lists are an essential data type in Mathematica and an understanding of how to work with them
provides a practical framework for the generalization of these ideas to arbitrary expressions.
Chapter 3 focuses on structure, syntax, and tools for working with lists. These topics are all
extended in later chapters in the context of various programming tasks. Included in this chapter
are discussions of functions for creating, displaying, testing, measuring lists, various visualization
tools, arrays (sparse and otherwise), list component assignment, and using Span to extract
ranges of elements.
Patterns and rules are introduced in Chapter 4. Even though pattern-based programming may
be new to many, patterns are so essential to all programming in Mathematica, that it seems most
natural to introduce them at this point and then use them in later chapters on functional and
procedural programming. Topics include a discussion of structured patterns, conditional pat-
terns, sequence pattern matching, using data types to match an expression, repeated patterns,
replacement rules, and numerous examples of functions and programs that make heavy use of
pattern matching.
The chapter on functional programming (Chapter 5) introduces the many functions built into
Mathematica associated with this programming paradigm: Map, Apply , Thread, Outer ,
Select, Pick , and many others. Scoping constructs are explicitly called out in a separate
section. A section on pure functions includes numerous examples to help understand this impor-
tant construct in the context of concrete problems. Adding options, error trapping and messag-
ing, so important for well-designed functions and programs, are discussed in this chapter so that
they can be used in all that follows. Numerous applied examples are included such as protein
Preface xv

interaction networks, Hamming distance, defining new graphics objects, creating palettes for
project files, and much more.
Procedural programming may be most familiar to those who learned programming in a more
traditional language such as Fortran or C. The syntax of procedural programming in Mathemat-
ica is quite similar to that in C and Chapter 6 is designed to help you transition to using Mathemat-
ica procedurally but also mixing it with other programming styles when and where appropriate.
Looping constructs and their syntax are discussed in terms of basic examples which are then built
upon and extended in the remainder of the book. Included are piecewise-defined functions, flow
control, and several classical examples such as sieving for primes and sorting algorithms.
The chapter on recursion, Chapter 7, gives a basic introduction to programming recursively-
defined functions. The main concepts – base cases, recursion on the tail, recursion with multiple
arguments, and so on – are introduced through illustrative examples. The chapter concludes with
a discussion of dynamic programming, a technique for greatly speeding up recursive computa-
tions by automatically creating definitions at runtime.
Chapter 8 introduces the various types of number you can work with in Mathematica – exact,
machine-precision, arbitrary-precision as well as different number types and arrays of numbers.
It includes an extended discussion of random number generators and functions for sampling and
choosing random numbers. The examples and applications section includes a program to com-
pute the radius of gyration tensor of a random walk as well as material on statistical tests, both
built-in and user-defined tests for checking the randomness of sequences of numbers.
The chapter on strings, Chapter 9, is included in recognition of the ubiquity of these objects in
broad areas of science, engineering, linguistics, and many other fields. Topics include an introduc-
tion to the structure and syntax of strings, basic operations on strings including those that mirror
similar operations on lists, an extensive discussion on string patterns including regular expres-
sions such as are found in languages like Perl and Python, and many applications and examples
drawn from linguistics, computer science, and bioinformatics.
Chapter 10 on visualization is designed to give you a good sense of the symbolic graphics
language so that you can both create your own graphics scenes and functions and also make your
objects as efficient as possible. Included is a discussion of primitives, directives, and options, all of
which is mirrored in the section on sound. A section on efficient graphics structures is included
that discusses multi-objects such as multi-points and multi-lines, as well as material on
GraphicsComplex , a compact way to represent a graphical object with many repeated primi-
tive elements. Many extended examples are included for functions to plot points in space con-
nected by lines, economic or financial trend plots, space-filling molecule plots for proteins and
other chemicals, and root plotting functions.
Dynamic objects were introduced in Mathematica 6, and there have, sadly, been few resources
for learning the ins and outs of dynamic programming. Dynamic objects provide tools to create
xvi Preface

interactive elements in your documents from as simple as an animation to as complex as…well,


as complex as you can imagine. In Chapter 11 we introduce dynamic objects, starting with top-
level functions Animate and Manipulate , moving on to viewers and various control objects
that can be used to control changing parameters. The primitive elements that lie underneath all
these top-level functions are Dynamic and DynamicModule, which are the foundations of the
entire interactive machinery now built into Mathematica. The chapter closes with several applica-
tions including building up interfaces to work with multi-dimensional data, extending work
earlier in the book on palettes for file openers, event handlers to interact more with your mouse,
and a simple geometry demonstration due to Apollonius.
As a result of the many comments and suggestions from people in the broad Mathematica
community, I have included a chapter on writing efficient programs, Chapter 12. Although there
are many approaches you might take to solve a problem, it is often difficult for the novice to tell
which is the most appropriate, or the most efficient, or which scales best. Several “good practices”
are considered, including choosing the right function, choosing the right algorithm, listability,
pure functions, packed arrays, and so on. Sections on parallel computation and on compiling are
also included. These issues are discussed through the use of concrete examples drawn from
earlier parts of the book.
The chapter on applications, Chapter 13, builds upon much of the work in the rest of the book
but extends it for those who wish to turn their code into programs and applications that can be
shared with colleagues, students, or clients. The focus is on making your Mathematica programs as
much like built-in functions as possible, thereby taking advantage of the interface elements that a
user of your code would already know and expect from working in Mathematica, things like
writing modular functions, usage messages, overloading, and creating and working with
packages.
In trying to keep this book both introductory and concise, many topics had to be left out.
Some of these topics include: creation of new data types; the internals for ordering of rules;
upvalues, downvalues and other internal transformation rules; tuning and debugging; connect-
ing to external programs and databases; interacting with web servers. All of these topics are both
interesting and important but there was simply not enough room in the present volume to
include them.

Colophon
This book was written and developed in Mathematica. Stylesheets were created to the page specifi-
cations designed by the author while adhering to the constraints of the publisher’s production
department. Pages were output to PostScript and then distilled to PDF with Adobe Distiller using
a configuration file supplied by the publisher to set such parameters as resolution, font embed-
dings, as well as color and image conversions.
Preface xvii

The text for this book, including mathematical formulas, is set in Albertina, a humanist font
designed by the Dutch calligrapher Chris Brand (1921–1999), and digitized by the Dutch Type
Library (dtl). Captions and labels use the fairly animated sans serif Syntax, designed by the Swiss
typographer Hans Eduard Meier (1922– ).

Acknowledgments
Although writing a book may appear to others as a solitary project, authors know better. I con-
sider myself very fortunate to have had wonderful colleagues to work with and have benefited in
innumerable ways from their expertise. The following people provided concrete help in dis-
cussing various topics and answering my many questions: Darren Glosemeyer on date plotting
functions, statistical tests, and statistical plots; Harry Calkins on graphics and general language
issues; Charles Pooh on graphs and networks; Dan Lichtblau on internal algorithms and numer-
ous language issues; Michael Kelly for some suggestions on trend lines implementation; Adriano
Pascoletti for permission to use and modify his code for computing points in nonconvex poly-
gons; Tom Sherlock and Faisal Whepley for help on front-end related issues; Oyvind Tafjord for
various questions and issues with string manipulation and regular expressions; Andre Kuzniarek
and Larry Adelston for layout and production questions.
In addition, I am grateful to the reviewers who provided valuable feedback on early drafts of
this book: Harry Calkins, Darren Glosemeyer, Mariusz Jankowski, Dan Lichtblau, and Oyvind
Tafjord. Any mistakes that remain are mine and mine alone. If you think you have found one,
please let me know so that I can update an errata page on the publisher’s website as well as in any
future printings of this book.
The entire editorial and production stages of this project have been miraculously smooth, in
no small part due to the team at Cambridge University Press. In particular, my editor, David
Tranah and his team, have been both supportive and encouraging throughout the project, provid-
ing all that an author can ask for. Clare Dennison and Abigail Jones were most helpful on the
innumerable editorial and production details that accompany a book project such as this.
Loved ones are the unnamed partners in writing a book. Although unrecognized to the reader,
they nonetheless play a critical role for the author. They provide nourishment (in its many
guises), support, feedback, and that all-too-critical element, time. I have been blessed with a
supportive family throughout this project. In particular, my wife Sheri has lovingly provided all
these things and more.
Finally, I would like to dedicate this book to the memory of a very special friend, Bob Johnson.
Bob was the person most responsible for getting me involved with Mathematica when, back in
1989, as chair of the mathematics department at Sonoma State University, he asked me to join
him in the basement (computers were always in basements in those days!?) at Sonoma State and
we took our first look at a strange new program called Mathematica running on a strange new
xviii Preface

computer housed in a strange black magnesium cube. The excitement of realizing that the worlds
of mathematics, science, and engineering would be dramatically changed by this new program
was matched by the joy Bob and I experienced in learning how to incorporate this tool into our
research and teaching. Bob was that unusual person who knew how to keep his eyes on the prize
and his encouragement of my efforts made a huge difference in my life and in the lives of others
as well. Thanks Bob.

Paul R. Wellin
Random documents with unrelated
content Scribd suggests to you:
"Why not?" Brutar demanded. "Every living thing has a mind."
Eo added, "Since the essence of everything is mentality—naturally
the spark of life must bring that mentality to consciousness."
"These things then," I said, "they know that they are alive?"
"Of course. And Rob, what you told Brutar of your Earth-agriculture
—what you called your vegetable kingdom—seems not so very
different from ours."
"But it is different," I said. "Our plants—our growing things—are not
aware that they are alive."
Eo demanded gently, "How do you know that? Is it not perhaps that
your own mentality is lacking, to gauge the power of theirs?"
I smiled. "It may be so.... Brutar, these lolos plants—what is their
purpose?"
"With them we are going to your Earth," he said. "This lolos plant of
itself has a power very wonderful. We crush it; and the blood of it
taken into our body, sends the mind upon strange and pleasant
wanderings."
"Evil wanderings," said Eo.
A drug! As Brutar further explained, I realized it. And I wondered if
this lolos plant—the name of it—sounded thus since to my own
mentality it suggested the lotus flower. I think that was so.
The blood of this plant was a powerful narcotic. Brutar had been
addicted to its use; and his wandering mind had come into the
Borderland. He had seen our Earth-realm; gone further until he
experienced the sensations of our physical consciousness. Had come
back, to gather his followers; to create in quantity the blood of this
lolos that all might go to conquer and enjoy this greater realm.
Brutar was absorbed in his subject. Listening to him, I had
nevertheless noticed that Bee's attention was fixed upon Eo. She
was whispering to him. With his sweet, boyish face, he was listening
to her, enraptured. He was close beside her, and I saw that he was
touching her. Brutar, still talking to me, bent to show me one of the
lolos plants. It shrank away from him as though in fear. He frowned;
struck it a blow with his hand. His attention momentarily was
diverted from us. I heard Eo murmur softly, yet tensely.
"You are right—girl. This is evil—I realize it now.... Rob! Hold
yourself firm! Stay with me! We will try to escape...."

I must revert now to Will, Thone and Ala in the Big-City. They had
felt Bee's thoughts; they knew we were in danger; Ala had caught
just enough to know that we were with Brutar.
"We must go," Thone hastily declared. "Try and follow them, Ala....
That Brutar is a mind very powerful for evil."
With Will held firmly between them, they swept out into space. To
Will it was a dream, a nightmare of mental chaos. Rushing through
the dark—through seemingly endless Space for endless Time. But he
saw none of the distorted things that I had seen, for he was in
friendly hands. A rushing black Nothingness sweeping past. A vague
dream of flight; but presently he found his mind clearing.
The void was illimitable. But soon it seemed not wholly empty. To
one side was a faint glow—an infinite distance away, as though it
might have been a nebula gleaming over Space a thousand million
Light-years of distance. Or something shining from another Time—
eons away. It moved sidewise as they swept along. It glowed, faded,
was gone.
"We will not go there," Ala murmured. She seemed to shudder. "That
is the Realm of Disease. I hope never to go there."
Endless Time passing. Or perhaps, as Will was thinking, Time was in
abeyance, standing still, non-existent.
And Will saw other far-off gleaming patches, like faint drifting star-
dust. Soon they were gone. He did not ask what they might be.
Ala still felt Bee's thoughts. Then they ceased. Will became aware of
a confusion; a fluttering; as though now the flight had lost direction.
He gazed around intently, searchingly, but the space at that moment
was wholly empty.
"Where are we?" he asked.
Thone and Ala were exchanging thoughts. Thone said:
"Where are we? There is no answer, Will. There is nothing here. We
are nowhere."
A confusion. It seemed that Ala and Thone felt that Brutar's self-
created world might be found by approaching the Realm of Disease.
Will waited, listening silently while they talked of it....
Abruptly Will saw something. A blur—a vague luminosity beneath
them. It was moving. Suddenly he knew it was not large and far-
away, but small and very close. It mounted; broke visually apart,
resolved itself into two dark blobs. Shapes. The moving shapes of a
man and a woman.
They came nearer. The woman was Bee! It was Bee and the
youthful Eo. He was clinging to her; she seemed helping him
struggle upward.
They reached Will. Bee gasped, "He—he is hurt! Oh Will—it's you!
Help him—his mind struggles to leave us! He is wounded. I think—I
think he is going to die!"
She seemed crying as she flung herself into Will's arms. "I don't
want him to die. He is my friend—so gentle, so lovable—I don't want
him to die!"
CHAPTER XIV
THE REALM OF DEATH
I must tell again of that moment when we—Bee and I—were
standing beside the lolos field with Brutar and Eo. Brutar had turned
away. Eo—prompted, I had no doubt, by Bee—murmured, "This is
evil! We will escape—"
My arm reached for Bee. I told myself intensely that now we must
escape ... now I must fling my thoughts—my mind—out into the
void.... And stay with Eo; he would lead us....
I think my groping hand never reached Bee. I felt a swishing sound.
A swirl of thoughts struck me—like feathers blown against me in a
gale. But they seemed to cling. Invisible, imponderable—barely
palpable; dimly I could feel these thoughts like a net entangling me.
I was floundering. Surging through blackness. Where was Bee? I
thought I saw her and Eo whirling near me. But it was a thought
unreal—hallucination; for as I tried to grip it and make them visible,
they were gone. My thought of them dissolved into a realization that
I did not see them, for they were vanished.
But Brutar I saw; a distorted wraith of him ... his grim, menacing
face ... grim with combat....
I was rushing through blackness. But as an undertow may suck the
strongest swimmer, something was pulling me back ... a hampering
net around me ... materializing into greater ponderability ... holding
me firmly.... The blackness about me was taking form. I strove to
think I saw the Big-City. Told myself that that hovering shape above
me was Thone—the friendly Thone; not Brutar.
But it was not Thone; and this place that was clarifying to my vision
was not the Big-City. The lolos field! I came—was dragged, sucked
back to it! The lolos field—I was standing there where before I had
been. And the menacing shape was Brutar—my captor standing
there grimly confronting me.
But Bee and Eo were gone.
These two, escaping, came upon Thone, Will and Ala as I have
related. Came upon them hovering nowhere in the void. Eo was
stricken. Brutar, with what quickness and evil power of mind I could
not conceive, had struck at Eo. A wound, a derangement not
physical, but mental. His mind now—sick, stricken with disease.
Almost wandering; yet not quite unhinged—for the power of his will
was holding it. Bravely he clung to sanity. Fought for it. Yet those—
his friends with him—knew then that he fought a losing battle.
They hung there in the void. Bee was sobbing, "I don't want him to
die! He is my friend."
He held tightly to her. His eyes were very wistful. "They call you a
girl—and now I know I love you!"
The void was moving. It seemed so to Will; seemed that the
blackness was moving past them. Or was it that they—the little knot
of their hovering shapes—was moving? Then Will realized that it was
Eo—his stricken, wandering mind—dragging them somewhere. The
void seemed moving—for how long Will did not know. And then, far
away, in Space and in eons of Time, something became visible. A
faint star-dust glow. A luminous patch. It broadened; spread to the
sides, and up and down until everywhere before them lay its
gleaming radiance.
The realm of disease! Will heard Ala murmur it in accents of sorrow
and apprehension. Eo was rushing for it—and no power that they
had could stop him.
The radiance intensified. A fear—a shuddering horror possessed Will.
With every instinct within him, he recoiled from the approach.
Revolted. But he held tightly to Thone and to Bee; told himself that
they would lead him safely.
Everything was glowing; they were wholly within the glow now. A
silvery glow that shone everywhere about them. But soon to the
silver there came a greenish cast. It deepened. A green, with its
sickly look of death. Green, with the silver turning to a pallid, flat,
dead whiteness. And then a mingled brown; a murk, like a fog
pervading everything.
Abruptly Will became conscious that Eo was no longer with them.
His last despairing cry; and Bee's echo. He was going—floating
downward; while they, uncontaminated, hovered above, at the edge
of the realm, to see it but not to enter.
Will saw but dimly. Saw shapes floating in there. Dismembered
shapes. Others, whole, floating inert. A cauldron, with bubbles of
sight and sound, and smell. Shrouded in murk. Unreal.... A wailing ...
sobbing ... faint aerial voices wailing like ghosts distraught.... And a
stench—the thought of it, no more——but to Will the thought, the
knowledge of all this was horrible, fearsome. Singularly fearsome;
above everything at that moment he feared this realm, this state of
unnatural, tortured existence....
They could still talk to Eo. See him there, laboring, losing his brave
fight to come back to them. He seemed very far away; and yet very
close, for though his form was down there, engulfed with all the
leprous horrors of disease, his voice was very plainly heard. And his
face, the image of it, the physical representation of it to Will's
thought, seemed again at hand. His eyes were very wistful. He was
smiling gently at Bee.
"Soon, girl, I will be gone—into death—it is very near now. I can see
it—see it, just ahead...."
Will saw it, too. Another realm beyond the one they were skirting.
The realm of death. It lay close ahead. Dark. Mysterious. Scarce to
be seen, but only imagined.
Again came Eo's faint voice. "I shall—be there in a moment. It is
very—beautiful. I can see it—right here—" And then he suddenly
whispered, "I love you, my girl Bee—"
And vanished.

Or did he vanish? The shell of him then seemed lying in Bee's arms.
But it was an empty nothing; the shell of a shape of something
which once had been, but now was not....
Thone said gravely, "Watch it, Will. The Thought is gone from it. Our
own thought-matter is all that is left. You shall see of what
permanence that is."
The dead shell lay inert. It was dissolving.... Grewsome.... Will
turned away; then forced his vision back to see a leprous wraith—a
rotting shape which presently, like a melting fog, began to dissipate.
Dissolving, until the very last essence of it was gone into
nothingness.
Ala seemed to sigh. "It is very horrible. Yet I think that we are wrong
to consider it so, for it is Nature."
Will recovered himself. The realm of disease had withdrawn to a
memory. Around him the blackness seemed purified. But ahead he
could see—or thought he saw—that other endless realm where dwell
what we call the dead. Questions flooded him. Eo was there? Could
they not go and see him? Could he—this Entity which had once been
Eo—could he not still speak to them from beyond the borders of
death?
Thone said, "We will approach it if you wish."
Unnameable time; and then Will found that they were there,
hovering; and a realm, a place—a something he knew not what—lay
spread above them. Earnestly he groped for it. Not with his physical
hands; but with his senses. His thought went there and back. He
thought he saw shapes up there. Hovering, glowing shapes in a
great light space. And with futile, childish imagination he endowed
them with beautiful, ethereal qualities; transfigured them into
glowing human shapes of beauty and peace. And thought he saw
them; and that they might speak to him. Or that perhaps, because
Thone might be more than human, they might communicate with
Thone, and thence to him.
And then he laughed. It was all so childish!
Thone said, "Eo is there, in the darkness and the light. You can think
of him. Your thought will go there. And it will come back to you,
fraught with what qualities your imagination may lend it. But nothing
else."
"No," said Will, "nothing else. I understand that now."
CHAPTER XV
THE BIRTH OF A THOUGHT
They turned away in the void—away from the dark-light mystery of
the realm of death, and drove themselves back to the Big-City. The
search for Brutar's encampment was at the moment futile; they
knew they could not reach it. And though Bee had escaped with Eo,
she did not know whether I escaped or not.
They hoped to find me safely returned to the Big-City. But I was not
there. But still Thone felt that I might come. To Will—with his
inherent, instinctive conception of a placid, measured Time—the
delay seemed dangerous. He was impatient; anxious to do
something. But there was nothing which of himself he could do; and
Thone was an Intelligence very keen. Will decided that upon Thone
he must rely.
They went back to the home globe, to rest and to wait for my
possible arrival. Will in a way was glad of the inactivity, for he
remembered that of Thone's plans he knew almost nothing. He
would learn all he could; and with something definitely arranged,
they could act to better purpose.
Will felt the pangs of hunger. They brought a glowing brazier
wherein something smouldered. He ate—inhaled, there is no word
for it. Satisfied his pangs; and drank of the silver mist which came
flowing into the globe at a word of command.... And slept; lost
consciousness, to find himself in blackness with Time wholly gone.
But still I did not come back to the Big-City. There were times when
with Thone, Will journeyed about the city streets, gazing at this
strange life. He saw thought-workers, as I had seen them in Brutar's
encampment. Saw the water being created; saw the thought-matter
moulded and spun into new globes—moulded to all the diverse
purposes of this Ego-life.
He slept again; several times; and ministered to the slight wants of
his tenuous body. A great length of time seemed passing; and still I
did not arrive.
There were many talks that Will had with Thone. Ala and Bee were
generally there, as befitted those of their sex.
Sex? It was interesting to Will. The creation of the individual Ego of
this strange realm, so different an existence, and yet in fundamental
conception so like his own. Already he believed that the same
Creator governed both. With strange ways that we mortals so little
understand, over all the realms, the states of existence, the
Universes that possibly could exist—only one Creator held sway. The
Thought—there could be but One.
Will said, "You once spoke, Thone, of yourself as Ala's parent. And
the necessity of the Thought to the creation of Ego-life. Will you
explain that? In our world we have two sexes. Have you also?"
"Yes," said Thone. "In the higher forms of life—we humans, as you
would say—there are, like yours, two sexes. Call me a man—and Ala
a woman. The difference is one of mental capacity; mental qualities,
inherent perhaps to the Ego. I call it the Soul, though we have no
name for it. I mean that something which makes each individual
different from every other.
"The qualities inherent to the individual mould and form the
mentality. Characterize thus, what we call its sex. The one sex is a
complement to the other. An attraction exists between them—a
desire for proximity so that of their own inherent force they will draw
together. And the one mentality derives force—a mental life-force—
from the other. An exchange—for it yields its own necessary qualities
in return. Thus we have the mating—the basis of the family. Without
it no complete mental health is possible. There is no mentality
capable of existing in health by itself."
"And a birth?" Will suggested.
"Communion of thought. The desire, the longing of two closely
interwoven mentalities of complementary qualities. When they
combine with an intensity of longing, the thought-matter they
mutually create brings into existence another, smaller shape like
themselves. It is very small—very tenuous—scarce to be seen save
by those two who have produced it. It lies inert. Almost formless,
though they sit beside it and strive with their loving thoughts of
what it should be—strive to give it form. It may continue to lie inert;
and at last in spite of their efforts, it may dissolve, dissipate—be
gone, back into Nothingness from whence they drew it. The Thought
was not within it; it never was anything then save a human longing
unblessed.
"Or again, the Thought may be there. It lives. Grows ponderable.
Moves of itself. Thinks of itself. Then it is something itself—
something independent of all save its creator-divine.... The little
nourishment of its body is easily supplied; the mother-parent gives it
lovingly the needed gentler nourishment of the mind; daily she adds
to it the loving tendrils of her thought-matter so tenuous that to the
sight it seems mere light.
"But if the spark is there, glowing brightly, the little Ego lives. Grows
in size. Displays a growing mental capacity of its own. Its own
mental qualities make themselves known, to identify it as a man-
child, or a woman-child. And the Ego, developing, brings it to
individuality. It is Itself; unlike everyone else. The new Individual....
That, my friend Will, is a birth."
Will thought a moment. "There is a beauty to it."
Bee said, "I don't quite understand—" She gazed at Will, puzzled;
and Will felt and understood her confusion. He said:
"Your explanation, Thone, seems to make Man differ from Woman
only in qualities of the Soul and Mind. You do not speak of the body;
yet to me, Ala here appears of very different form from yourself."
Thone smiled. "You say, 'to me.' You have answered yourself, my
friend. The physical aspect of everything is but the reflected image
of it within our own mentality. The gentleness of Ala—those qualities
which make her what she is—are seen by you in the form of what
you call a woman."
"But," protested Will, "does she not look the same to you?"

"That I do not know," he returned earnestly. "Nor do you. We can


only see, think, imagine for ourselves. Our conscious universe is our
own; it exists of our own creation, and what it is of itself apart from
us, I do not know."
"We have on Earth," Will said, "a school of philosophical thinking
which believes that nothing exists apart from the mentality
perceiving it. Believes that without a consciousness of existence,
nothing can exist."
"That may be so," Thone replied gravely.
Bee was still puzzled. She said to Thone, "Ala, to me, looks different
from you. She looks, as Will says, like a girl. Won't you tell us how
she looks to you?"
He thought a moment. "She looks—like Ala," he said slowly. "I think
we mould our images from the individual itself—not upon a
generality of sex. She looks to me like Ala, as I know her to be. Very
gentle. Very keen of reasoning. Very quick—" He smiled. "Yet not
always so very logical. She looks like the Ala of my creation—mine
and that other mentality whom you would call her mother—" His
voice turned solemn, with a singular hush to it. "Her mother—who
has long since gone into that realm of mystery."
At other times they talked of practical subjects. Brutar's coming
invasion of Earth; my own fate, since I still was missing, unheard
from. And they talked of what could be done to overcome Brutar and
his horde of followers.
Thone, it seemed to Will, had accomplished very little. He had
learned of Brutar's purpose; and of the establishment of his realm.
Thone had sent—by the aid of the lolos plant—an adventurer into
the Borderland who had seen Brutar and some of his cohorts
experimenting with the Earth-state. Then Ala had gone into the
Borderland; had met Will; had arranged to bring him, Bee and
myself back to see her parent.
Little of accomplishment! A public meeting of protest, which we had
attended; and which Brutar invaded. But now Thone was organizing
his Thinkers—his army, as it might have been called on Earth. Their
purpose was to seek out Brutar's realm by concerted effort of
thought; to find it while Brutar's preparations were still incomplete;
and to destroy it.
The very conception of warfare of this kind was difficult for Will to
encompass. There were no weapons—nothing of the sort we on
Earth would call weapons. Will showed Thone his broad belt, and the
contents of its pouches. He drew out a revolver and a knife. Thone
inspected them curiously—shadowy, glowing objects which almost
floated when tossed into the air, so imponderable were they.
Will explained their Earthly uses. He said, a trifle shamefacedly, "I
brought them—but I felt they would be of no advantage here."
He pulled the trigger of the revolver. If it discharged, there was no
result which his Ego-senses could perceive. Thone said, handing him
the knife, "Strike me with it."
The action was instinctively revolting; yet Will drove the knife-blade
into the semblance of Thone's arm. Thone said, "It seems to hurt."
To Will the knife might have been a feather he was thrusting against
a pillow. He withdrew the blade; fancied he saw in Thone's arm an
open gash. But if he did, the gash closed at once. The outlines of
the arm were quivering, unreal, under Will's earnest gaze. And he
knew that if he persisted in regarding it, the arm would turn
formless to his sight.
He exclaimed, "Useless! Of course." And tossed the knife away. But
Thone recovered it. "In the Borderland it would be more effective,
Will. Keep it."
Thone explained how his army of Thinkers might destroy Brutar's
encampment. The thought-matter, created, was held in substance
only by continued mental effort. And this withdrawn, at once the
disintegrating forces of Nature would dissolve it into nothingness.
"So it is," Thone said, "when an Ego dies. The persistent,
subconscious effort of mind during life is all that holds the shell of
body in existence. Withdraw that—and you have dissolution."
"And with inorganic matter—" Will began.
"With this globe, for instance," said Thone. "With everything we
have created, a worker-mentality must guard it. Replenish it."
To Will that seemed not very strange. "On Earth," he said, "we must
repair. Nature slowly but steadily tears down that which we have
built."

"Of course," Thone responded. "We will destroy Brutar's


encampment, himself and all his followers. Rather should I say, we
will force them to stop replenishing—and Nature will destroy."
Then Will said, "Let me ask you this: I understand that if you, with
your weaving of the net of thoughts, are quicker, more powerful
than I, you will beat down my resistance. Entrap me; force my body
to follow you."
"Or to depart from me," Thone added. "I could force you back—as
far from me as I could spin the net."
"I was thinking—suppose we must fight them in the Borderland—"
"A combat at once physical and mental," Thone retorted. He smiled.
"You think we are ill-prepared, Will? That is not so. My men of
Science have studied this condition—experimented with it very fully.
The Borderland—the transition into your Earth-state—all such things
are new to us. But we are coming to understand them. And I think
that Brutar's people know little of their subject...."
He paused in contemplation; then went on slowly. "We are not sure
how permanent may be the transition by the lolos-blood into the
state of your Earth-matter. Brutar may be mistaken in that—"
He paused again. His smile had a gleam of irony; and there came
into his voice an ironic note. "I am not sure but that from the
Borderland, our opposing thoughts might not reach your Earth-state.
They might, perhaps, do strange things to those of Brutar's people
who have reached there—who have taken with them what they may
think are effective weapons."
That Thone had learned, or divined much of Brutar's purpose, and
that he was prepared to combat it, was evident. But at the moment
he chose to speak no further. He added abruptly, "My Thinkers are
organized. Very soon they will be ready. The mind, my friend Will,
grows strong only with use. Every moment that they can, they are
developing the strength of battle.... Come here and see."
They passed upward upon the side of the globe; and at once its
opaque wall began to glow; become translucent; transparent, until
through it Will saw the city. An open space, from this angle
seemingly tilted on end, was nearby. Within it a horde of shapes
were squatting. Figures which after a moment of inspection seemed
men—gaunt of body, but with craniums distended. A horde—a
myriad; Will could not have guessed at their number. Squatting in a
giant spiral curving inward to its center point. From the heads of
them all light was streaming. It spun in a band close over them;
whirled, flashed with iridescent color. A spiral band of light,
concentrating at the center point into a beam that shot away and
was lost in the darkness.
The globe wall became again opaque; the scene vanished. Thone
said softly, "There is much power for combat in mentalities like
those. And very soon I will put them to searching for Brutar's realm."
A cry from Ala interrupted him. The girl had been seated as though
in meditation; but now she flung herself erect.
"I can find this encampment of Brutar—I can lead you to it now!"
Thone stared.
"Are you getting thoughts from it?" Will demanded eagerly. And Bee
gave a glad exclamation. She asked, "Is Rob there? Is he safe, Ala?
Can you take us to him?"
"I do not know if he is there, or safe. Oh, I cannot tell you those
things! I only know I can take you to Brutar's realm!"
"You feel no thoughts from there?" said Thone.
"No."
Thone was standing with the others. No delay now. He was ready.
He said to Will, "It is the nameless power. Those only whom you call
women have it."
"Intuition," Will supplied.
"We say, the nameless.... You may try, Ala. And, if once you take me
there—" A restrained, grave triumph was upon him.
"Once I have been there, with perfect sureness I can lead our
Thinkers to the attack."
Again in the void.... The power of woman's mentality—the nameless
power; illogical, against all reason, all science; not to be explained....
But it was leading them.... A rush through the darkness of vague,
unreasoning woman's thought; a distance, a time felt, but
unmeasurable; a direction not to be fathomed.... And then, ahead of
them as in a clinging group they followed Ala, the glow of a poised
realm became visible. They neared it; hovered in the void regarding
it. And knew and saw that it was Brutar's realm—that great, tenuous
globe hanging there like a gigantic bubble. They could see within it;
see details as though by some magnification the details were close
at hand.
The encampment was deserted! Abandoned! The lolos field was
uprooted; its plants gone. The globes, the workshops, the streets,
fields—all were deserted. And more than that, with the removal of all
conscious, constructive, replenishing mentality, disintegration already
was taking place. A leprous realm. Holes of Nothingness were visibly
eating their way into everything. Rotting walls ... rotting
habitations....
Under the gaze of the watchers the whole realm was melting.
Dissolving into slow-flowing viscosity; cesspools of putridity, rising
into mists, vapors—a puff of Nothingness....
The realm was vanished. The void was black, empty and silent. The
little group of apprehensive watchers turned away.
Brutar—presumably taking me with him—had already started his
invasion of Earth!
CHAPTER XVI
THE MARCH OF THE GHOSTS
I remained a captive of Brutar; and at length the time came when
he was ready to start his conquest of Earth. His army, his followers,
quietly had departed from the encampment, and were waiting for
him in the Borderland. He stood before me—we two the last living
minds remaining in his self-created realm. Around me I could see it
even then beginning to rot and crumble.
He said, "The blood of the lolos is ready for us, Rob. But before we
start I will warn you—if once more you try to escape you will be
killed." I could not doubt but that he spoke his true intent.
He brought then a bowl, or brazier, in which like food the dried
burning blood of the lolos was glowing. It was a dull red in the
gloom, with tiny green tongues licking upward from it. I could not
see the smoke. But I could sense it—smell it. We reclined by the
brazier. The fumes brought a reeling of my senses. Unpleasant,
frightening.... Then pleasant indeed. A drowsy drifting into rosy
vacancy. I had intended not to yield myself wholly, but my will
weakened.... I told myself that Brutar would guide me....
Out of the darkness at last with returning consciousness I found a
gentle net of Brutar's thoughts cradling me. And himself regarding
me impatiently.
"Come, Rob. We are here. Stay close by me—and if you help me as I
wish, reward shall be yours."
There was a tenseness to his voice. I gazed around. We were in the
Borderland—that same dark void with its rolling slopes. Near at hand
I saw some two hundred of Brutar's workers—his fighters—drawn up
in orderly array. Shadows like myself. And behind them a rabble of
Egos in the fashion of men, women and children. His followers,
waiting to enter the Earth-realm when the fighters had conquered it.
I saw, too, hovering near Brutar and me, a dozen shapes of men—
the leaders of Brutar's army awaiting his instructions.
When I was more fully alert Brutar drew me aside. He spoke with a
new force and succinctness. Because now the time for action had
come and I think also that as we neared our Earth-state, there was
a tendency toward restoration of all Earthly qualities.
"Rob," he said, "I'll tell you now my plan. Your greatest city is near
at hand—somewhere near here."
"New York," I said.
"Yes. I plan to attack it—demolish it. It's a very small portion of your
Earth, of course, but with that evidence of my power I think your
Earth-leaders will cease to fight me—will admit my supremacy. If not
—well, then I shall demolish each of your great cities in turn—"
He told me then that these two hundred men, with his dozen sub-
leaders, were all the fighting force he at first proposed to use. We
were about to attack New York City. His people would wait, here in
the Borderland, for our success; then would enter the Earth-state to
take possession of it.
"You can help me, Rob, because you know your city better than I do.
Look around us now—tell me exactly, where are we?"
I saw then the shadows of ghostly houses. My own world! Grey,
spectral houses ... streets ... a church ... trees lining a street of
residences in a small quiet town. It lay in a plane tilted at a slight
angle, and perhaps thirty feet above us. I looked up to the street
overhead. Quiet? It was thronged with people—ghostly shapes
crowded up there staring down at us. It seemed to be night up
there; I could see the street lights; spots of light in the houses, and
the headlights of scurrying automobiles.
The town was in a turmoil. I knew that its people saw us down here
as a myriad half-materialized ghosts. They were crowding to watch
us. They realized that now at last the ghosts had come in a horde!
Perhaps to attack. I saw policemen on the streets; and presently a
company of soldiers came along. Spurts of flame showed as
evidently they fired tentatively toward the ground. But there was no
sound.
Brutar chuckled. "Well, they're really frightened now! And they have
cause to be. Where are we, Rob?"
It seemed possibly a suburb of New York City. I did not recognize it
at once. Then off to one side I saw a shadowy river, with ghostly
cliffs on its further bank. The Hudson!
"I don't know where we are," I said carefully. "Where do you want to
go first, Brutar?"
"To New York City—down there where there is river all around, and a
great pile of buildings."
Lower New York. But I would not lead him. I protested ignorance.
A shape approached us, a man. He gestured. "I know it is that way,
Brutar."
We started. The two hundred fighters in a triple file came after us.
Brutar had ordered the mob of men and women to wait where they
were. We advanced slowly, and I saw with sinking heart that we
were going southward. Upper New York City soon lay close ahead.

It was a strange, soundless march. The slopes of the Borderland


carried us sometimes above, and sometimes below the ground of
Earth. But generally we were below it. Up there over our heads the
shadowy landscape was silently slipping backward. It was all too
familiar now. We were under upper Broadway. Huge apartment
houses loomed high up there, with the Hudson almost at our level to
the right.
Our advance was followed up above. From every window people
were peering fearsomely down at us. The cross streets were
jammed. But ahead of us policemen were clearing them. And down
empty Broadway, and down each of the North and South Avenues
troops of the State Militia were marching, keeping as nearly as
possible directly over us.
"Brutar," I said, "you cannot fight this world. Look at them there.
They're ready—waiting."
Machine guns were posted at most of the street corners now; and as
we passed beneath them they were moved swiftly forward to other
streets ahead of us. The boat traffic of the river was being cleared.
Police boats, armed and ready, were paralleling our march. A war-
vessel lay anchored ahead, off Grant's Tomb. Its funnels were
smoking, and as we neared it, very slowly it steamed along with us.
And over in Jersey and on Long Island I had no doubt they were
ready with watching troops and every precaution. Let one of us who
now were mere ghosts dare to materialize further, and at once we
would be killed. What could Brutar do?
He laughed at my thoughts. "You shall see, Rob, when we get
among the great houses and I lay my weapons."
I could not fathom what he meant, but the sure confidence of his
tone had an ominous ring to it. Weapons? I saw none. We were
empty-handed, Brutar and I. And the twelve sub-leaders were
empty-handed as well. But of Brutar's attacking force marching
behind us, I had noticed that each man was carrying a single article.
I could not call them weapons; I did not know what they were. They
seemed more like grey, ghostly bricks, each man carrying one.
What were they? I could no more than guess. Some material,
doubtless of Brutar's creation, brought into this Borderland state.
Would these ghosts, each with a simple brick like these—would they
dare to materialize—dare to enter our Earth-state upon an equality
of being with the armed, massed troops awaiting them? It seemed
incredible. Two hundred ghosts marching in spectral array beneath
the city, with soldiers above; and machine guns, and war-vessels
alert to destroy them.
I told myself that there was nothing to fear. I had thought of escape.
Desperately I would try to rejoin Will and Bee that we might do
something to stem this invasion. Or escape, and get up there to
Earth, to tell the authorities what I knew. But sober reason told me
that as yet I knew very little. I had best stay with Brutar, to learn
what I could.
We passed under the length of Manhattan; came at last to lower
Broadway. We were close beneath it. The great shadowy piles of
masonry towered above us. Looking upward I could see the
shadowy outlines of the foundations of the buildings; to the right the
tubes leading to New Jersey beneath the river; the network of water
mains; gas; light; arteries of the city. And I could see up through the
sub-cellars, the cellars, and into the buildings themselves. Towering
structures with all their anatomy laid bare as though some giant X-
ray were turned upon them.
We stopped; gathered in a group. We were just beneath City Hall
Park, standing partly within one of the Subway tunnels. No trains
were running. Soldiers were massed on the station platform. They
came along the tracks—transparent ghosts of uniformed, armed men
—came until some of them passed directly through us; and stood
nearby, grimly watching and waiting.
In the empty park overhead, policemen were on guard, and troops
were bringing in machine guns. I could see, too, that soldiers were
now massing on the shadowy Brooklyn Bridge; police boats were
clustering on the river there; and armed men were waiting in the
cellar of every building nearby. There were towering giants of
buildings all about us here.... The Woolworth Building was close at
hand....
Brutar said, "I should not care just now, to materialize further, Rob.
These men look very determined." His laugh was ironical. "They are
watching us closely—much good it will do them!"
He called his little band of fighters to him; they stood partly on the
Subway tracks and partly beneath them. And he gave his low-toned
instructions.
I saw ten of his men move aside as he indicated them. "Yes," he
said. "You first. And I think I would work upon that large house over
there."
Silently, with their ghostly glowing bricks in hand, the ten advanced.
Across the Subway tracks, through the spectral earth and rock strata
under Broadway. Climbing or floating upward, I could not tell.
Moving through and into the vitals of the Woolworth Building.
CHAPTER XVII
THE ATTACKING SPECTRES
I said to Brutar, "You asked my help. But you have let me do nothing
to help you—and you explain nothing, so that I have no idea what is
going on. Am I not enough your friend by now?"
Brutar smiled; I think he was fatuous enough to believe that he had
won me over.
"You will be able to help me, Rob. We're going to place these
weapons everywhere. There is a statue near here somewhere—a
giant figure rising from water. I want you to lead us to it. Later—
when we have finished with this great house."
"Weapons?" I echoed. "What sort of weapons?"
He continued to smile. "You called them bricks a while ago. That's
what they are—inert material we brought with us. I had devised
other things, but thought that these would suffice. Come here—I'll
show you."
He took one of the bricks. As I stood with him to examine it, a score
of the ghostly troopers came across the Subway tracks and fronted
us.
It was a light substance, but quite ponderable. Solid, yet rather of
the consistency of soft rubber; I seemed to be able to mould its
shape slightly with my fingers. Blue-green of color or silver
phosphorescence; and it glowed and shimmered in my hands.
I gave it back to Brutar. "You're going to place these—where?"
"Everywhere," he said. "You shall see. Let us go watch my men
place them up there in the great house.... This fellow is very bold!
He doesn't seem afraid of me!"
He strode vigorously at the intent and curious soldier—passed
through him; but the soldier did not move.
"Come, Rob—let's go up and watch them."
We moved under the Woolworth Building, up to and through the
bottoms of its great elevator shafts. And climbing—upon what I
cannot say or guess—we passed upward and into the building.
Through its walls; its skeleton framework of steel; floating back and
forth through its many storied offices.... Roaming ghosts!
The ten ghosts of Brutar were floating silently about. We ourselves
could be seen by those within the building—seen as spectres
hovering, moving with what silent, sinister purpose they did not
know.
Yet they tried to resist us. We came, for instance, upon one of
Brutar's men, with the brick still in his hand.
"Shall I place it here?" he asked. "We have chosen this side—I
thought this might be a good spot."
We were some four stories above ground. Before us was one of the
great upright girders of the structure.
"I should think so," Brutar agreed.
The man held the glowing, oblong brick within the shadowy steel.
He released it, and it floated gently downward—wafted down like a
feather very slowly. But it kept within the outlines of the girder.
"You'd better follow it," said Brutar. "It will stop presently—and
perhaps where you want it."
Inside the building the Earth-people had seen us—we three hovering
there. Men and soldiers were running from room to room, and up
and down the staircases trying to get near us. There was a room
and a portion of a hallway close to where we now hovered. They
were soon thronged with men, crowding against the walls, within
which our white shapes were visible. But the walls, solid to them,
stopped their advance. They stood regarding us; and now I could
see fear upon their faces as their glances followed the downward
floating brick. And as it descended a story, many of them rushed
down, scrambling against the walls, striving to reach into the place
where they saw it.
Did they divine its purpose? I thought so; for as presently it came to
rest, lodged in the upright steel where cross girders were riveted, I
saw men come rushing with crowbars and axes. Frantically they
were tearing at the walls, ripping out the wood and plaster, striving
to reach and perhaps to dislodge that shimmering thing lying there
in the vitals of the building.
Brutar laughed. "You see, Rob? They're beginning to understand
now—and they're frightened. It is materializing—that brick, as you
call it, is materializing!"
Growing solid! In a surging torrent of horror complete realization
rushed over me. I scarce heard Brutar's gloating words: "That inert
matter, freed of physical contact with our Borderland bodies, tends
slowly to change to the state of the thing nearest to it. As heat by
contact communicates, so does the vibratory rate of all substances.
That brick, lodged there, is materializing. Slowly now—but soon very
fast. Presently it will be as solid as the steel girder itself—a brick
resting there complete in your Earth-state—demanding space of its
own, for its own existence!"

Space of its own! What diabolical force of Nature would this unleash!
These molecules, atoms, electrons of the steel and brick thus
intermingled! In a Space but half sufficient! A force created of
unknown, unthinkable power—immeasurable as that proverbial
irresistible force meeting an immovable body. Two solid bodies here,
intermingled to their very essence, striving to occupy the same
space at the same time!
Brutar was drawing at me. "Look at them, Rob! Trying to get at it!
And up there—and down below—see them?"
The glowing bricks were lodged up and down the building—all
seemingly on the one side. Down underground, lodged in the very
foundations of the structure I could see three of them piled together.
And frantic shapes of men digging for them through the walls of the
cellars.
"Come further away, Rob. We can see it better from a distance. It
should be very interesting."
We retreated, going back until again we were standing just beneath
the level of City Hall Park. Brutar's men gathered around us—two
hundred ghosts clustered there watching the fruit of their diabolical
efforts. There were soldiers with machine guns in the park. The guns
impotently, ridiculously, were trained upon us. And around the edge
of the park a cordon of police kept back the crowds. I wondered
what time of night it might be. Evening, possibly; and then I saw the
spectral clock of the little tower of the squat City Hall. It was just
before midnight.
Our march, perhaps not so much sinister as weird to the public, had
drawn a jam of the morbidly curious to this part of the city. They
were packed everywhere. And all the normal activities of the city
were stopped. No traffic on the streets. Vehicles motionless.
The great Woolworth Building stood like the ghost of some grave
giant, serene, majestic in the power of its size. Its summit up there
in the gloom seemed lighted; spots of blurred light were everywhere
within it.
The whole scene of shadows seemed unreal. Like a dream. But as I
saw those frantic figures scrambling within the threatened building,
hacking futilely at its foundations to try and remove in time those
dim, glowing bricks materializing from another realm—the stark,
strange reality of it all was forced upon me.
We waited. How long I cannot say. Spectators of two realms, each to
the other mere ghosts, standing there watching and waiting. For a
time nothing happened throughout all the scene. And then a change
was apparent in the crowds about the park. No longer were they
watching us, the ghosts, but they were eyeing now the Woolworth
Building. At first curiously, incredulous to believe the news which
was spreading about. Then restlessly, and then, as orders evidently
were passed to the troops and to the policemen, these began
pushing and shoving at the people. The crowd resisted at first;
moved reluctantly. Then a fear seemed to surge over them—fear
growing to panic. They began trying to run—waves of them
everywhere surging in panic away from the doomed building.
Hundreds went down underfoot, trampled upon in the streets by
their fellows, mad, insane now with fear. And from every nearby
building its occupants came tumbling out like frightened rats;
scurrying out to join the panic of the streets. A chaos everywhere....
And we ghosts stood quiet and serene in its midst.
Brutar murmured. "Watch the great house. They know it is doomed.
See, they have stopped their efforts in there—now at the last, trying
to save themselves."
The Woolworth Building was emptying.... Abandoned....
Breathlessly I stood and gazed upon the ghostly scene. The
tremendous building towered there motionless. But presently I
fancied it stirred; its graceful roof up there seemed swaying....
Shifting.... Or was it a trick of my straining vision? But then I saw it
was not, for palpably the tower swayed.... Leaned. Further—leaning
until all at once I knew it could not recover.... Poised, and then was
toppling.
A breathless instant. Slowly at first, like a felled forest giant, the
great structure was coming down. Slowly, then with a rush it fell to
the south—fell in great shattering segments. Crashed with a
soundless crash upon the several blocks of nearby buildings.
Crashed and tore with the thousands of tons of its weight,
smothering everything beneath its crashing masonry and steel.... A
soundless chaotic scene of ruin and death over all those city blocks,
with huge rising clouds of dirt and smoke mercifully to obscure it.
CHAPTER XVIII
THE RESCUING ARMY
I stood gaping, every sense within me shuddering at that soundless
scene of ruin and death. And then it came upon me that now I could
escape. Brutar had turned triumphantly to his underlings. I heard his
voice: "The first success! Now let us try the others!"
No one seemed to be noticing me. I turned and swept myself away
into the darkness....
I was aware of the grey outlines of New York floating by above
me.... A dim idea was in my mind that I must rejoin Will and
Thone....
Out there beneath the Westchester hills the silent mob of Brutar's
ghostly followers still waited. Near them was the main body of his
army, inactive, waiting here while he with his chosen few were
experimenting upon New York!
Experimenting! This little experimental test, and it had brought down
the Woolworth Building! What then would they do with a general
attack?
I passed around the mob—silent, fleeing spectres—and sped again
into darkness. With no conscious thought of passing time, or
direction to my flight. Yet there must have been some instinct to
guide me. The thought of Bee came strong. A growing triumph, a
relief, told me I was nearing her; and I think now that it was her
thought of me which guided my flight.
Darkness. But overhead lay the shadows of my own world. Winding
grey hills; towns that lay like grey, colorless pictures in a book,
queerly distorted as I looked, upward and through them....
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like