p. 2
printed from the mathematica help browser 1 library of congress cataloging-in-publication data wolfram stephen 1959 mathematica book stephen wolfram 5thed p cm includes index isbn 1579550223 hardbound 1 mathematica computer file 2 mathematics dataprocessing i title qa76.95.w65 2003 510 .285 5369 dc21xxxxxxx cip comments on this book will be welcomed at comments@wolfram.com in publications that refer to the mathematica system please cite this book as stephen wolfram the mathematica book 5th ed wolfram media 2003 first and second editions published by addison-wesley publishing company under the title mathematica a system for doing mathematics by computer third and fourth editions co-published by wolfram media and cambridge university press published by isbn 1579550223 wolfram media inc web www.wolframmedia.com +12173989090 fax +12173989095 mail 100 trade center drive champaign il 61820 usa copyright © 1988 1991 1996 1999 2003 by wolfram research inc all rights reserved no part of this book may be reproduced stored in a retrieval system or transmitted in any form or by any means electronic mechanical photocopying recording or otherwise without the prior written permission of the copyright holder email info@wolframmedia.com phone ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 3
2 printed from the mathematica help browser wolfram research is the holder of the copyright to the mathematica software system described in this book including without limitation such aspects of the system as its code structure sequence organization look and feel programming language and compilation of command names use of the system unless pursuant to the terms of a license granted by wolfram research or as otherwise authorized by law is an infringement of the copyright the author wolfram research inc and wolfram media inc make no representations express or implied with respect to this documentation or the software it describes including without limitations any implied warranties of merchantability or fitness for a particular purpose all of which are expressly disclaimed users should be aware that included in the terms and conditions under which wolfram research is willing to license mathematica is a provision that the author wolfram research wolfram media and their distribution licensees distributors and dealers shall in no event be liable for any indirect incidental or consequential damages and that liability for direct damages shall be limited to the amount of the purchase price paid for mathematica in addition to the foregoing users should recognize that all complex software systems and their documentation contain errors and omissions the author wolfram research and wolfram media shall not be responsible under any circumstances for providing information on or corrections to errors and omissions discovered at any time in this book or the software it describes whether or not they are aware of the errors or omissions the author wolfram research and wolfram media do not recommend the use of the software described in this book for applications in which errors or omissions could threaten life injury or significant loss mathematica mathlink and mathsource are registered trademarks of wolfram research j/link mathlm mathreader .net/link notebooks and webmathematica are trademarks of wolfram research all other trademarks used are the property of their respective owners mathematica is not associated with mathematica policy research inc or mathtech inc printed in the united states of america ¶ acid-free paper 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 4
printed from the mathematica help browser 1 about the author stephen wolfram is the creator of mathematica and a well-known scientist he is widely regarded as the most important innovator in technical computing today as well as one of the world s most original research scientists born in london in 1959 he was educated at eton oxford and caltech he published his first scientific paper at the age of fifteen and had received his phd in theoretical physics from caltech by the age of twenty wolfram s early scientific work was mainly in high-energy physics quantum field theory and cosmology and included several now-classic results having started to use computers in 1973 wolfram rapidly became a leader in the emerging field of scientific computing and in 1979 he began the construction of smp the first modern computer algebra system which he released commercially in 1981 in recognition of his early work in physics and computing wolfram became in 1981 the youngest recipient of a macarthur prize fellowship late in 1981 wolfram then set out on an ambitious new direction in science to develop a general theory of complexity in nature wolfram s key idea was to use computer experiments to study the behavior of simple computer programs known as cellular automata and in 1982 he made the first in a series of startling discoveries about the origins of complexity the publication of wolfram s papers on cellular automata led to a major shift in scientific thinking and laid the groundwork for a new field of science that wolfram named complex systems research through the mid-1980s wolfram continued his work on complexity discovering a number of fundamental connections between computation and nature and inventing such concepts as computational irreducibility wolfram s work led to a wide range of applications and provided the main scientific foundations for the popular movements known as complexity theory and artificial life wolfram himself used his ideas to develop a new randomness generation system and a new approach to computational fluid dynamics bothof which are now in widespread use following his scientific work on complex systems research wolfram in 1986 founded the first research center and first journal in the field then after a highly successful career in academia first at caltech then at the institute for advanced study in princeton and finally as professor of physics mathematics and computer science at the university of illinois wolfram launched wolfram research inc wolfram began the development of mathematica in late 1986 the first version of mathematica was released on june 23 1988 and was immediately hailed as a major advance in computing in the years that followed the popularity of mathematica grew rapidly and wolfram research became established as a world leader in the software industry widely recognized for excellence in both technology and business wolfram has been president and ceo of wolfram research since its inception and continues to be personally responsible for the overall design of its core technology following the release of mathematica version 2 in 1991 wolfram began to divide his time between mathematica development and scientific research building on his work from the mid-1980s and now with mathematica as a tool wolfram made a rapid succession of major new discoveries by the mid-1990s his discoveries led him to develop a fundamentally new conceptual framework which he then spent the remainder of the 1990s applying not only to new kinds of questions but also to many existing foundational problems in physics biology computer science mathematics and several other fields after more than ten years of highly concentrated work wolfram finally described his achievements in his 1200-page book a new kind of science released on may 14 2002 the book was widely acclaimed and immediately became a bestseller its publication has been seen as initiating a paradigm shift of historic importance in science in addition to leading wolfram research to break new ground with innovative technology wolfram is now developing a series of research and educational initiatives in the science he has created other books by stephen wolfram è cellular automata and complexity collected papers 1993 ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 5
2 printed from the mathematica help browser è a new kind of science 2002 author s website www.stephenwolfram.com author s address email s.wolfram@wolfram.com mail c/o wolfram research inc 100 trade center drive champaign il 61820 usa for comments on this book or mathematica send email to comments@wolfram.com ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 6
printed from the mathematica help browser 1 about mathematica mathematica is the world s only fully integrated environment for technical computing first released in 1988 it has had a profound effect on the way computers are used in many technical and other fields it is often said that the release of mathematica marked the beginning of modern technical computing ever since the 1960s individual packages had existed for specific numerical algebraic graphical and other tasks but the visionary concept of mathematica was to create once and for all a single system that could handle all the various aspects of technical computing in a coherent and unified way the key intellectual advance that made this possible was the invention of a new kind of symbolic computer language that could for the first time manipulate the very wide range of objects involved in technical computing using only a fairly small number of basic primitives when mathematica version 1 was released the new york times wrote that the importance of the program cannot be overlooked and business week later ranked mathematica among the ten most important new products of the year mathematica was also hailed in the technical community as a major intellectual and practical revolution at first mathematica s impact was felt mainly in the physical sciences engineering and mathematics but over the years mathematica has become important in a remarkably wide range of fields mathematica is used today throughout the sciences physical biological social and other and counts many of the world s foremost scientists among its enthusiastic supporters it has played a crucial role in many important discoveries and has been the basis for thousands of technical papers in engineering mathematica has become a standard tool for both development and production and by now many of the world s important new products rely at one stage or another in their design on mathematica in commerce mathematica has played a significant role in the growth of sophisticated financial modeling as well as being widely used in many kinds of general planning and analysis mathematica has also emerged as an important tool in computer science and software development its language component is widely used as a research prototyping and interface environment the largest part of mathematica s user community consists of technical professionals but mathematica is also heavily used in education and there are now many hundreds of courses from high school to graduate school based on it in addition with the availability of student versions mathematica has become an important tool for both technical and non-technical students around the world the diversity of mathematica s user base is striking it spans all continents ages from below ten up and includes for example artists composers linguists and lawyers there are also many hobbyists from all walks of life who use mathematica to further their interests in science mathematics and computing ever since mathematica was first released its user base has grown steadily and by now the total number of users is above a million mathematica has become a standard in a great many organizations and it is used today in all of the fortune 50 companies all of the 15 major departments of the u.s government and all of the 50 largest universities in the world at a technical level mathematica is widely regarded as a major feat of software engineering it is one of the largest single application programs ever developed and it contains a vast array of novel algorithms and important technical innovations among its core innovations are its interconnected algorithm knowledgebase and its concepts of symbolic programming and of document-centered interfaces the development of mathematica has been carried out at wolfram research by a world-class team led by stephen wolfram the success of mathematica has fueled the continuing growth of wolfram research and has allowed a large community of independent mathematica-related businesses to develop there are today well over a hundred specialized commercial packages available for mathematica as well as more than three hundred books devoted to the system ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 7
printed from the mathematica help browser 1 new in version 5 mathematica version 5 introduces important extensions to the mathematica system especially in scope and scalability of numeric and symbolic computation building on the core language and extensive algorithm knowledgebase of mathematica version 5 introduces a new generation of advanced algorithms for a wide range of numeric and symbolic operations numerical computation major optimization of dense numerical linear algebra new optimized sparse numerical linear algebra support for optimized arbitrary-precision linear algebra generalized eigenvalues and singular value decomposition linearsolvefunction for repeated linear-system solving p norms for vectors and matrices built-in matrixrank for exact and approximate matrices support for large-scale linear programming with interior point methods new methods and array variable support in findroot and findminimum findfit for full nonlinear curve fitting constrained global optimization with nminimize support for n -dimensional pdes in ndsolve support for differential-algebraic equations in ndsolve support for vector and array-valued functions in ndsolve highly extensive collection of automatically-accessible algorithms in ndsolve finer precision and accuracy control for arbitrary-precision numbers higher-efficiency big number arithmetic including processor-specific optimization enhanced algorithms for number theoretical operations including gcd and factorinteger direct support for high-performance basic statistics functions symbolic computation solutions to mixed systems of equations and inequalities in reduce complete solving of polynomial systems over real or complex numbers solving large classes of diophantine equations forall and exists quantifiers and quantifier elimination representation of discrete and continuous algebraic and transcendental solution sets findinstance for finding instances of solutions over different domains ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 8
2 printed from the mathematica help browser exact constrained minimization over real and integer domains integrated support for assumptions using assuming and refine rsolve for solving recurrence equations support for nonlinear partial and q difference equations and systems full solutions to systems of rational ordinary differential equations support for differential-algebraic equations coefficientarrays for converting systems of equations to tensors programming and core system integrated language support for sparse arrays new list programming with sow and reap evaluationmonitor and stepmonitor for algorithm monitoring enhanced timing measurement including absolutetiming major performance enhancements for mathlink optimization for 64-bit operating systems and architectures support for computations in full 64-bit address spaces interfaces support for more than 50 import and export formats high efficiency import and export of tabular data png svg and dicom graphics and imaging formats import and export of sparse matrix formats mps linear programming format cascading style sheets and xhtml for notebook exporting preview version of .net/link for integration with .net notebook interface enhanced help browser design automatic copy/paste switching for windows enhanced support for slide show presentation authortools support for notebook diffs standard add-on packages statistical plots and graphics ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 9
printed from the mathematica help browser 3 algebraic number fields new in versions 4.1 and 4.2 enhanced pattern matching of sequence objects enhanced optimizer for built-in mathematica compiler enhanced continued fraction computation greatly enhanced dsolve additional traditionalform formats efficiency increases for multivariate polynomial operations support for import and export of dxf stl fits and stds data formats full support for csv format import and export support for utf character encodings extensive support for xml including symbolicxml subsystem and notebookml native support for evaluation and formatting of nand and nor high-efficiency cellularautomaton function j/link mathlink-based java capabilities mathmlform and extended mathml support extended simplification of floor erf productlog and related functions integration over regions defined by inequalities integration of piecewise functions standard package for visualization of regions defined by inequalities anova standard add-on package enhanced combinatorica add-on package authortools notebook authoring environment ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 10
printed from the mathematica help browser 1 the role of this book the scope of the book this book is intended to be a complete introduction to mathematica it describes essentially all the capabilities of mathematica and assumes no prior knowledge of the system in most uses of mathematica you will need to know only a small part of the system this book is organized to make it easy for you to learn the part you need for a particular calculation in many cases for example you may be able to set up your calculation simply by adapting some appropriate examples from the book you should understand however that the examples in this book are chosen primarily for their simplicity rather than to correspond to realistic calculations in particular application areas there are many other publications that discuss mathematica from the viewpoint of particular classes of applications in some cases you may find it better to read one of these publications first and read this book only when you need a more general perspective on mathematica mathematica is a system built on a fairly small set of very powerful principles this book describes those principles but by no means spells out all of their implications in particular while the book describes the elements that go into mathematica programs it does not give detailed examples of complete programs for those you should look at other publications the mathematica system described in the book this book describes the standard mathematica kernel as it exists on all computers that run mathematica most major supported features of the kernel in mathematica version 5 are covered in this book many of the important features of the front end are also discussed mathematica is an open software system that can be customized in a wide variety of ways it is important to realize that this book covers only the full basic mathematica system if your system is customized in some way then it may behave differently from what is described in the book the most common form of customization is the addition of various mathematica function definitions these may come for example from loading a mathematica package sometimes the definitions may actually modify the behavior of functions described in this book in other cases the definitions may simply add a collection of new functions that are not described in the book in certain applications it may be primarily these new functions that you use rather than the standard ones described in the book this book describes what to do when you interact directly with the standard mathematica kernel and notebook front end sometimes however you may not be using the standard mathematica system directly instead mathematica may be an embedded component of another system that you are using this system may for example call on mathematica only for certain computations and may hide the details of those computations from you most of what is in this book will only be useful if you can give explicit input to mathematica if all of your input is substantially modified by the system you are using then you must rely on the documentation for that system additional mathematica documentation for all standard versions of mathematica the following is available in printed form and can be ordered from wolfram research ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 11
2 printed from the mathematica help browser getting started with mathematica a booklet describing installation basic operation and troubleshooting of mathematica on specific computer systems extensive online documentation is included with most versions of mathematica all such documentation can be accessed from the help browser in the mathematica notebook front end in addition the following sources of information are available on the web www.wolfram.com the main wolfram research website documents.wolfram.com full documentation for mathematica library.wolfram.com/infocenter the mathematica information center a central web repository for information on mathematica and its applications ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 12
printed from the mathematica help browser 1 suggestions about learning mathematica getting started as with any other computer system there are a few points that you need to get straight before you can even start using mathematica for example you absolutely must know how to type your input to mathematica to find out these kinds of basic points you should read at least the first section of part 1 in this book once you know the basics you can begin to get a feeling for mathematica by typing in some examples from this book always be sure that you type in exactly what appears in the book do not change any capitalization bracketing etc after you have tried a few examples from the book you should start experimenting for yourself change the examples slightly and see what happens you should look at each piece of output carefully and try to understand why it came out as it did after you have run through some simple examples you should be ready to take the next step learning to go through what is needed to solve a complete problem with mathematica solving a complete problem you will probably find it best to start by picking a specific problem to work on pick a problem that you understand well preferably one whose solution you could easily reproduce by hand then go through each step in solving the problem learning what you need to know about mathematica to do it always be ready to experiment with simple cases and understand the results you get with these before going back to your original problem in going through the steps to solve your problem you will learn about various specific features of mathematica typically from sections of part 1 after you have done a few problems with mathematica you should get a feeling for many of the basic features of the system when you have built up a reasonable knowledge of the features of mathematica you should go back and learn about the overall structure of the mathematica system you can do this by systematically reading part 2 of this book what you will discover is that many of the features that seemed unrelated actually fit together into a coherent overall structure knowing this structure will make it much easier for you to understand and remember the specific features you have already learned the principles of mathematica you should not try to learn the overall structure of mathematica too early unless you have had broad experience with advanced computer languages or pure mathematics you will probably find part 2 difficult to understand at first you will find the structure and principles it describes difficult to remember and you will always be wondering why particular aspects of them might be useful however if you first get some practical experience with mathematica you will find the overall structure much easier to grasp you should realize that the principles on which mathematica is built are very general and it is usually difficult to understand such general principles before you have seen specific examples one of the most important aspects of mathematica is that it applies a fairly small number of principles as widely as possible this means that even though you have used a particular feature only in a specific situation the principle on which that feature is based can probably be applied in many other situations one reason it is so important to understand the underlying principles of mathematica is that by doing so you can leverage your knowledge of specific features into a more general context as an example you may first learn about transformation rules in the context of algebraic expressions ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 13
2 printed from the mathematica help browser but the basic principle of transformation rules applies to any symbolic expression thus you can also use such rules to modify the structure of say an expression that represents a mathematica graphics object changing the way you work learning to use mathematica well involves changing the way you solve problems when you move from pencil and paper to mathematica the balance of what aspects of problem solving are difficult changes with pencil and paper you can often get by with a fairly imprecise initial formulation of your problem then when you actually do calculations in solving the problem you can usually fix up the formulation as you go along however the calculations you do have to be fairly simple and you cannot afford to try out many different cases when you use mathematica on the other hand the initial formulation of your problem has to be quite precise however once you have the formulation you can easily do many different calculations with it this means that you can effectively carry out many mathematical experiments on your problem by looking at the results you get you can then refine the original formulation of your problem there are typically many different ways to formulate a given problem in mathematica in almost all cases however the most direct and simple formulations will be best the more you can formulate your problem in mathematica from the beginning the better often in fact you will find that formulating your problem directly in mathematica is better than first trying to set up a traditional mathematical formulation say an algebraic one the main point is that mathematica allows you to express not only traditional mathematical operations but also algorithmic and structural ones this greater range of possibilities gives you a better chance of being able to find a direct way to represent your original problem writing programs for most of the more sophisticated problems that you want to solve with mathematica you will have to create mathematica programs mathematica supports several types of programming and you have to choose which one to use in each case it turns out that no single type of programming suits all cases well as a result it is very important that you learn several different types of programming if you already know a traditional programming language such as basic c fortran perl or java you will probably find it easiest to learn procedural programming in mathematica using do for and so on but while almost any mathematica program can in principle be written in a procedural way this is rarely the best approach in a symbolic system like mathematica functional and rule-based programming typically yields programs that are more efficient and easier to understand if you find yourself using procedural programming a lot you should make an active effort to convert at least some of your programs to other types at first you may find functional and rule-based programs difficult to understand but after a while you will find that their global structure is usually much easier to grasp than procedural programs and as your experience with mathematica grows over a period of months or years you will probably find that you write more and more of your programs in non-procedural ways learning the whole system as you proceed in using and learning mathematica it is important to remember that mathematica is a large system although after a while you should know all of its basic principles you may never learn the details of all its features as a result even after you have had a great deal of experience with mathematica you will undoubtedly still find it useful to look through this book when you do so you are quite likely to notice features that you never noticed before but that with your experience you can now see how to use ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 14
printed from the mathematica help browser 3 how to read this book if at all possible you should read this book in conjunction with using an actual mathematica system when you see examples in the book you should try them out on your computer you can get a basic feeling for what mathematica does by looking at a tour of mathematica in section t.0 you may also find it useful to try out examples from this tour with your own copy of mathematica whatever your background you should make sure to look at the first three or four sections in part 1 before you start to use mathematica on your own these sections describe the basics that you need to know in order to use mathematica at any level the remainder of part 1 shows you how to do many different kinds of computations with mathematica if you are trying to do a specific calculation you will often find it sufficient just to look at the sections of part 1 that discuss the features of mathematica you need to use a good approach is to try and find examples in the book which are close to what you want to do the emphasis in part 1 is on using the basic functions that are built into mathematica to carry out various different kinds of computations part 2 on the other hand discusses the basic structure and principles that underlie all of mathematica rather than describing a sequence of specific features part 2 takes a more global approach if you want to learn how to create your own mathematica functions you should read part 2 part 3 is intended for those with more sophisticated mathematical interests and knowledge it covers the more advanced mathematical features of mathematica as well as describing some features already mentioned in part 1 in greater mathematical detail each part of the book is divided into sections and subsections there are two special kinds of subsections indicated by the following headings advanced topic advanced material which can be omitted on a first reading special topic material relevant only for certain users or certain computer systems the main parts in this book are intended to be pedagogical and can meaningfully be read in a sequential fashion the appendix however is intended solely for reference purposes once you are familiar with mathematica you will probably find the list of functions in the appendix the best place to look up details you need about the examples in this book all the examples given in this book were generated by running an actual copy of mathematica version 5 if you have a copy of this version you should be able to reproduce the examples on your computer as they appear in the book there are however a few points to watch until you are familiar with mathematica make sure to type the input exactly as it appears in the book do not change any of the capital letters or brackets later you will learn what things you can change when you start out however it is important that you do not make any changes otherwise you may not get the same results as in the book never type the prompt in[n that begins each input line type only the text that follows this prompt you will see that the lines in each dialog are numbered in sequence most subsections in the book contain separate dialogs to make sure you get exactly what the book says you should start a new mathematica session each time the book does some special topic subsections give examples that may be specific to particular computer systems ©1988-2003 wolfram research inc all rights reserved.
[close]
p. 15
4 printed from the mathematica help browser any examples that involve random numbers will generally give different results than in the book since the sequence of random numbers produced by mathematica is different in every session some examples that use machine-precision arithmetic may come out differently on different computer systems this is a result of differences in floating-point hardware if you use arbitrary-precision mathematica numbers you should not see differences almost all of the examples show output as it would be generated in standardform with a notebook interface to mathematica output with a text-based interface will look similar but not identical almost all of the examples in this book assume that your computer or terminal uses a standard u.s ascii character set if you cannot find some of the characters you need on your keyboard or if mathematica prints out different characters than you see in the book you will need to look at your computer documentation to find the correspondence with the character set you are using the most common problem is that the dollar sign character shift-4 may come out as your local currency character if the version of mathematica is more recent than the one used to produce this book then it is possible that some results you get may be different most of the examples in a tour of mathematica as well as parts 1 and 2 are chosen so as to be fairly quick to execute assuming you have a machine with a clock speed of over about 1 ghz and most machines produced in 2003 or later do then almost none of the examples should take anything more than a small fraction of a second to execute if they do there is probably something wrong section 1.3.12 describes how to stop the calculation ©1988-2003 wolfram research inc all rights reserved.
[close]