Book contents
- Frontmatter
- Contents
- Preface
- 1 An introduction to Mathematica
- 2 The Mathematica language
- 3 Lists
- 4 Patterns and rules
- 5 Functional programming
- 6 Procedural programming
- 7 Recursion
- 8 Numerics
- 9 Strings
- 10 Graphics and visualization
- 11 Dynamic expressions
- 12 Optimizing Mathematica programs
- 13 Applications and packages
- Solutions to exercises
- Bibliography
- Index
- Frontmatter
- Contents
- Preface
- 1 An introduction to Mathematica
- 2 The Mathematica language
- 3 Lists
- 4 Patterns and rules
- 5 Functional programming
- 6 Procedural programming
- 7 Recursion
- 8 Numerics
- 9 Strings
- 10 Graphics and visualization
- 11 Dynamic expressions
- 12 Optimizing Mathematica programs
- 13 Applications and packages
- Solutions to exercises
- Bibliography
- Index
Summary
Of the many data types that are used in programming – numbers, strings, symbols, lists – numbers are perhaps the most familiar. You can work with all kinds of numbers in Mathematica, but what distinguishes it from traditional programming languages and other computational systems is that with it you can operate on numbers of any size and to any degree of precision. In this chapter we will explore some of the issues related to working with numerical quantities and show how you can incorporate these ideas into programs that involve numerical computations to gain greater control over the precision and accuracy of your results as well as to improve the efficiency of your numerical computations and programs.
Numbers in Mathematica
One of the first things you will notice as you start using Mathematica is the manner in which it treats numbers compared with other systems such as calculators, traditional programming languages, and other technical computing software. In most traditional programming languages, you must declare the type of number your functions can take as an argument. Although Mathematica automatically handles such details for you an understanding of the different number types and how they invoke different algorithms is helpful for taking full advantage of Mathematica's numerical capabilities and for writing efficient programs.
Mathematica operates differently depending upon the type of input you give it. For example, the following two inputs each compute sin(π / 3) but something quite different results.
- Type
- Chapter
- Information
- Programming with Mathematica®An Introduction, pp. 251 - 308Publisher: Cambridge University PressPrint publication year: 2013