Programming in Mathematica / Edition 3

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $3.94
Usually ships in 1-2 business days
(Save 88%)
Other sellers (Paperback)
  • All (8) from $3.94   
  • New (4) from $26.21   
  • Used (4) from $3.94   

Overview

This revised and expanded edition of the standard reference on programming in Mathematica addresses all the new features in the latest Version 3 of the software. The support for developing larger applications has been improved, and the book now discusses the software engineering issues related to writing and using larger programs in Mathematica. As before, Roman Maeder, one of the original authors of the Mathematica system, explains how to take advantage of its powerful built-in programming language.

New topics in this edition include:

  • The programmable front-end;
  • The language for typesetting mathematical expressions and the treatment of exact numerical quantities;
  • A completely developed larger application, iterated function systems. This code allows readers to explore the fascinating world of chaos and fractals with Mathematica.
Current users of Mathematica, Version 2, and new users of Version 3 will benefit alike from this up-to-date reference to Mathematica programming.

020185449XB04062001

This second edition incorporates the new features and functions available in version 2.0 of the Mathematica software. It teaches Mathematica users elegant programming techniques and serves as an excellent reference for anyone who runs Mathematica software.

Read More Show Less

Editorial Reviews

Booknews
One of the original authors of the Mathematica system explains how to take advantage of the powerful built-in programming language. He shows in detail how to apply programming methods to the construction of actual programs. Annotation c. Book News, Inc., Portland, OR booknews.com
Read More Show Less

Product Details

  • ISBN-13: 9780201854497
  • Publisher: Addison-Wesley
  • Publication date: 12/16/1996
  • Edition description: 3rd ed
  • Edition number: 3
  • Pages: 384
  • Product dimensions: 7.55 (w) x 8.97 (h) x 0.94 (d)

Meet the Author

Roman Maeder was the third person to join the Mathematica development project, and was responsible for such parts of the system as polynomial factorization and language design. Maeder received his Ph.D. from the Swiss Federal Institute of Technology (ETH) in Zurich. Formerly a Professor of Computer Science at ETH, he is now an independent computing consultant.

020185449XAB04062001

Read More Show Less

Read an Excerpt

Mathematica was officially announced in June of 1988. Since then it has found many uses in very diverse fields. While it is useful to do a few calculations interactively, its real strength lies in the programming language it offers. Writing programs, one extends Mathematica with specialized new functions in one's own field of interest.

Mathematica's programming language is unlike any you have encountered before. The language's manual explains all its features and gives some very basic examples of their use. For writing good programs, however, this is not enough: there is clearly a need for a book explaining all the many features in context and giving more extensive examples of their use. The first edition of this book filled this gap for version 1.2 of Mathematica. Like the second edition, this third edition was prompted by a major new version of Mathematica, Version 3.0.

I have been in contact with many early users of Mathematica and I have also given students at the University of Illinois and the Swiss Federal Institute of Technology an opportunity to learn about it. I have seen many programs written in Mathematica, good ones and bad ones. The bad ones invariably solve a particular problem in an unnecessarily complicated way, perhaps because the programmers were unaware of the elegant constructs available in Mathematica. Let me point out these constructs and show you how they can be used to write concise, elegant, and efficient programs.

The best way to teach these Mathematica-specific programming methods is to look at examples of complete programs that solve some nontrivial problem. Even if the example chosen does not lie in the particular field of application that you are interested in, you will be able to use similar ideas for your own programs. Many of the examples presented here deal with graphics. Graphics applications are especially suited for learning programming, because it is easy to see whether your code is correct simply by looking at the picture it produces. Advanced graphics applications are also sufficiently challenging to require advanced programming methods. Other examples come from symbolic computation, geometry, dynamics, and numerical mathematics. Along the way, we also develop many short pieces of code that can be used as parts of larger programs or that help to customize Mathematica to your particular needs. Many of these found their way into the standard Mathematica distribution and are now available to all users.

Because there exists an excellent manual, this book does not explain everything from scratch, but assumes some familiarity with Mathematica. I assume also that you have access to a computer on which to try out the examples. In this book I want to tell you how you can use Mathematica for more than just typing in single commands. If you are using Mathematica for your work, teaching, or solving homework assignments, sooner or later you will encounter more advanced problems requiring many commands to solve, or you will be faced with doing the same calculation steps over and over again with different input. This is the point at which you want to start writing programs. Mathematica includes a rich and powerful programming language. Unlike the usual languages such as BASIC and C, it is not restricted to a small number of data types, but allows you to perform all its symbolic computations. The Mathematica manual can only hint at the possibilities. It explains all the features but does not show you which ones to use for a particular problem or how to fit things together into larger programs.

Through design and tradition, each programming language has developed a certain preferred style of good programming. It is possible to solve the same problem in many different ways, but there is usually some idea about what is a good or a bad program. In this book, I want to present examples of what the designers of Mathematica think is good programming style and show you why this is so. Even if you write your programs strictly for personal use, you will benefit from following a good style. For developing programs for others to use, adhering to this style is indispensable.

The programming examples in this book serve two purposes. First, they help explain concepts and show how things fit together to make up complete programs. Second, they are designed to be more than mere toy programs and should prove useful in their own right. In developing an example we always use the same method. We start out with a few commands or definitions that could be entered directly into Mathematica. We then extract the parts of the computation that are the same regardless of the input and define some functions or procedures that automate these steps. Then we apply standard techniques to these functions to make them into a package, adding documentation and certain programming constructs that make such a package easier to use. The goal is to write a program that would be useful not only to its author, who knows how it works, but also to other people. Finally, we might add a few more functions to the package or look at alternatives to what we did so far. In Chapter 1 these steps are described in full detail. Later on, when we concentrate on other aspects, we assume that you are familiar with these basic concepts and we shall not mention all the steps in detail. All the programs developed in this book are either part of the standard Mathematica distribution from Wolfram Research, or they are available free in electronic form.

Version 3.0 brings major new features. The programming language itself has not changed all that much, but many problems that required elaborate workarounds and many inconsistencies have been remedied. As a consequence, it is now possible to present the material on packages in a more logical fashion. The support for developing larger applications has been improved, and this edition discusses the software engineering issues of writing and using larger programs in Mathematica. The treatment of exact numeric quantities is another area of improvement, and the way numerical code should be written has changed. All programs have been revised to take advantage of the many new built-in functions. I added more material about functional and structural programming. These techniques are fundamental to writing good Mathematica code, but they are not available in most other programming languages and therefore need an expanded treatment.

The most important addition to Version 3.0 is, of course, the new frontend and the typesetting capabilities. The fact that notebooks and typeset formulae are represented as ordinary Mathematica expressions means that they can be manipulated easily with programs. This capability leads to some fascinating applications, and the new material on the frontend and typesetting teaches you how to develop such applications.

A complete, larger application (iterated function systems), more exercises, and an updated bibliography complete this expanded and revised edition.

This book is no replacement for the Mathematica manual The Mathematica Book. I do not expect that you have read everything in the manual, but you should have some basic experience with Mathematica before reading this book. Single commands are usually used without detailed explanation. You can use the index in The Mathematica Book to look up a description of a command that you did not know about. We also give references to places in The Mathematica Book where you can find explanations of concepts that are particularly relevant to a topic in this book. You should always turn to The Mathematica Book for explanations of features that are assumed known here, but that you have not used yet. The place to look for an explanation of all variants, defaults, or options for a particular command is the Reference Guide in the back of the book. All this information is also available in electronic form and can be accessed through the Help Browser of Mathematica.

All explanations about how Mathematica works are based on Version 3.0. The first edition of this book was about Version 1.2. Many things have changed in the new version. I added a few sections called "Changes from Earlier Editions"for the benefit of readers familiar with earlier versions of Mathematica or the first and second edition of this book.

I am grateful to many people who have contributed to this book. My thanks go first to the other developers of Mathematica. The language was shaped through countless discussions and many heated arguments. Trying to explain to each other why we think a certain feature should be done in a certain way has deepened our understanding of the matters involved and has given the language its overall consistency, despite the fact that it contains hundreds of commands and unifies many diverse programming paradigms.

Helpful ideas for this book came from Jim Feagin, Theodore Gray, Dan Grayson, Jerry Keiper, Silvio Levy, Troels Petersen, Will Self, Bruce Smith, Ilan Vardi, Ferrell Wheeler, and Stephen Wolfram. Some of the examples I used were inspired by Henry Cejtin, John Gray, Lee Rubel, William Thurston, Ilan Vardi, Jnrg Waldvogel, and Dave Withoff.

Help with the typographical side of producing this book came from Peter Altenberg, John Bonadies, Joe Kaiping, Daniel Lee, Cameron Smith, and Gregg Snyder, as well as from many other people at Wolfram Research, Inc. and the staff of Addison-Wesley. My past and present publishers, Allan Wylde and Peter Gordon, encouraged me to get started on this book and this new edition.

Roman Maeder
Programming In Mathematica
Herrliberg, Switzerland August 1996

Read More Show Less

Table of Contents

Preface.

About this Book.

Chapter Overview.

About the Examples.

Notation and Terminology.

The Programming in Mathematica Web Site.

Teaching Mathematica Programming.

1. Introduction.

From Calculations to Programs.

Basic Ingredients of a Package.

A Second Function in the Package.

Options.

Defaults for Positional Arguments.

Parameter Type Checking.

2. Packages.

Contexts.

Packages that Use Other Packages.

Protection of Symbols in a Package.

Package Framework and Documentation.

Loading Packages.

Large Projects.

3. Defaults and Options.

Default Values.

Options for Your Functions.

Setting Options of Several Commands.

4. Functional and Procedural Programming.

Procedures and Local Variables.

Loops.

Structured Iteration.

Iterated Function Application.

Map and Apply.

Application: The Platonic Solids.

Operations on Lists and Matrices.

5. Evaluation.

Evaluation of the Body of a Rule.

Pure Functions.

Nonstandard Evaluation.

Nonlocal Flow of Control.

Definitions.

Advanced Topic: Scopes of Names.

6. Transformation Rules.

Simplification Rules and Normal Forms.

Application: Trigonometric Simplifications.

Globally Defined Rules.

Pattern Matching for Rules.

Traversing Expressions.

7. Numerical Computations.

Numbers.

Numerical Evaluation.

Numeric Quantities.

Application: Differential Equations.

8. Interaction with Built-In Rules.

Modifying the Main Evaluation Loop.

User-Defined Rules Take Precedence.

Modifying System Function.

Advanced Topic: A New Mathematical Function.

9. Input and Output.

Input and Output Formatting.

Input from Files and Programs.

Running Mathematica Unattended.

Session Logging.

Advanced Topic: Typesetting Mathematics.

10. Graphics Programming.

Graphics Packages.

Animated Graphics.

The Chapter Pictures.

11. Notebooks.

Packages and Notebooks.

The Structure of Notebooks.

Frontend Programming.

12. Application: Iterated Function Systems.

Affine Maps.

Iterated Function Systems.

Examples of Invariant Sets.

Documentation: Help Notebooks and Manuals.

Appendix A. Exercises.

Programming Exercises.

Solutions.

Appendix B. Bibliography.

Background Information and Further Reading.

References.

Index.

Programs.

Subjects and Names. 020185449XT04062001

Read More Show Less

Preface

Mathematica was officially announced in June of 1988. Since then it has found many uses in very diverse fields. While it is useful to do a few calculations interactively, its real strength lies in the programming language it offers. Writing programs, one extends Mathematica with specialized new functions in one's own field of interest.

Mathematica's programming language is unlike any you have encountered before. The language's manual explains all its features and gives some very basic examples of their use. For writing good programs, however, this is not enough: there is clearly a need for a book explaining all the many features in context and giving more extensive examples of their use. The first edition of this book filled this gap for version 1.2 of Mathematica. Like the second edition, this third edition was prompted by a major new version of Mathematica, Version 3.0.

I have been in contact with many early users of Mathematica and I have also given students at the University of Illinois and the Swiss Federal Institute of Technology an opportunity to learn about it. I have seen many programs written in Mathematica, good ones and bad ones. The bad ones invariably solve a particular problem in an unnecessarily complicated way, perhaps because the programmers were unaware of the elegant constructs available in Mathematica. Let me point out these constructs and show you how they can be used to write concise, elegant, and efficient programs.

The best way to teach these Mathematica-specific programming methods is to look at examples of complete programs that solve some nontrivial problem. Even if the example chosen does not lie in the particular field of application that you are interested in, you will be able to use similar ideas for your own programs. Many of the examples presented here deal with graphics. Graphics applications are especially suited for learning programming, because it is easy to see whether your code is correct simply by looking at the picture it produces. Advanced graphics applications are also sufficiently challenging to require advanced programming methods. Other examples come from symbolic computation, geometry, dynamics, and numerical mathematics. Along the way, we also develop many short pieces of code that can be used as parts of larger programs or that help to customize Mathematica to your particular needs. Many of these found their way into the standard Mathematica distribution and are now available to all users.

Because there exists an excellent manual, this book does not explain everything from scratch, but assumes some familiarity with Mathematica. I assume also that you have access to a computer on which to try out the examples. In this book I want to tell you how you can use Mathematica for more than just typing in single commands. If you are using Mathematica for your work, teaching, or solving homework assignments, sooner or later you will encounter more advanced problems requiring many commands to solve, or you will be faced with doing the same calculation steps over and over again with different input. This is the point at which you want to start writing programs. Mathematica includes a rich and powerful programming language. Unlike the usual languages such as BASIC and C, it is not restricted to a small number of data types, but allows you to perform all its symbolic computations. The Mathematica manual can only hint at the possibilities. It explains all the features but does not show you which ones to use for a particular problem or how to fit things together into larger programs.

Through design and tradition, each programming language has developed a certain preferred style of good programming. It is possible to solve the same problem in many different ways, but there is usually some idea about what is a good or a bad program. In this book, I want to present examples of what the designers of Mathematica think is good programming style and show you why this is so. Even if you write your programs strictly for personal use, you will benefit from following a good style. For developing programs for others to use, adhering to this style is indispensable.

The programming examples in this book serve two purposes. First, they help explain concepts and show how things fit together to make up complete programs. Second, they are designed to be more than mere toy programs and should prove useful in their own right. In developing an example we always use the same method. We start out with a few commands or definitions that could be entered directly into Mathematica. We then extract the parts of the computation that are the same regardless of the input and define some functions or procedures that automate these steps. Then we apply standard techniques to these functions to make them into a package, adding documentation and certain programming constructs that make such a package easier to use. The goal is to write a program that would be useful not only to its author, who knows how it works, but also to other people. Finally, we might add a few more functions to the package or look at alternatives to what we did so far. In Chapter 1 these steps are described in full detail. Later on, when we concentrate on other aspects, we assume that you are familiar with these basic concepts and we shall not mention all the steps in detail. All the programs developed in this book are either part of the standard Mathematica distribution from Wolfram Research, or they are available free in electronic form.

Version 3.0 brings major new features. The programming language itself has not changed all that much, but many problems that required elaborate workarounds and many inconsistencies have been remedied. As a consequence, it is now possible to present the material on packages in a more logical fashion. The support for developing larger applications has been improved, and this edition discusses the software engineering issues of writing and using larger programs in Mathematica. The treatment of exact numeric quantities is another area of improvement, and the way numerical code should be written has changed. All programs have been revised to take advantage of the many new built-in functions. I added more material about functional and structural programming. These techniques are fundamental to writing good Mathematica code, but they are not available in most other programming languages and therefore need an expanded treatment.

The most important addition to Version 3.0 is, of course, the new frontend and the typesetting capabilities. The fact that notebooks and typeset formulae are represented as ordinary Mathematica expressions means that they can be manipulated easily with programs. This capability leads to some fascinating applications, and the new material on the frontend and typesetting teaches you how to develop such applications.

A complete, larger application (iterated function systems), more exercises, and an updated bibliography complete this expanded and revised edition.

This book is no replacement for the Mathematica manual The Mathematica Book. I do not expect that you have read everything in the manual, but you should have some basic experience with Mathematica before reading this book. Single commands are usually used without detailed explanation. You can use the index in The Mathematica Book to look up a description of a command that you did not know about. We also give references to places in The Mathematica Book where you can find explanations of concepts that are particularly relevant to a topic in this book. You should always turn to The Mathematica Book for explanations of features that are assumed known here, but that you have not used yet. The place to look for an explanation of all variants, defaults, or options for a particular command is the Reference Guide in the back of the book. All this information is also available in electronic form and can be accessed through the Help Browser of Mathematica.

All explanations about how Mathematica works are based on Version 3.0. The first edition of this book was about Version 1.2. Many things have changed in the new version. I added a few sections called "Changes from Earlier Editions"for the benefit of readers familiar with earlier versions of Mathematica or the first and second edition of this book.

I am grateful to many people who have contributed to this book. My thanks go first to the other developers of Mathematica. The language was shaped through countless discussions and many heated arguments. Trying to explain to each other why we think a certain feature should be done in a certain way has deepened our understanding of the matters involved and has given the language its overall consistency, despite the fact that it contains hundreds of commands and unifies many diverse programming paradigms.

Helpful ideas for this book came from Jim Feagin, Theodore Gray, Dan Grayson, Jerry Keiper, Silvio Levy, Troels Petersen, Will Self, Bruce Smith, Ilan Vardi, Ferrell Wheeler, and Stephen Wolfram. Some of the examples I used were inspired by Henry Cejtin, John Gray, Lee Rubel, William Thurston, Ilan Vardi, Jnrg Waldvogel, and Dave Withoff.

Help with the typographical side of producing this book came from Peter Altenberg, John Bonadies, Joe Kaiping, Daniel Lee, Cameron Smith, and Gregg Snyder, as well as from many other people at Wolfram Research, Inc. and the staff of Addison-Wesley. My past and present publishers, Allan Wylde and Peter Gordon, encouraged me to get started on this book and this new edition.

Roman Maeder
Programming In Mathematica
Herrliberg, Switzerland
August 1996

020185449XP04062001

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)