• Contact sales

Numerical Computing with MATLAB

By Cleve Moler, MathWorks


How much did the reduced air resistance in Mexico City contribute to Bob Beamon’s extraordinary performance in the long jump at the 1968 Olympic games? What is the effect of burning fossil fuels on the carbon dioxide concentration in the Earth’s atmosphere? How does the expected return for the game of blackjack change if you remove all the kings from the deck of cards? How does Google rank Web pages?

These are examples of the programming projects that tie together several of the topics covered in Numerical Computing with MATLAB, my new textbook for an introductory course in numerical methods, MATLAB, and technical computing. I am pleased to describe the book for you here.

The emphasis in the book is on informed use of mathematical software. I want students to learn enough about the mathematical functions in MATLAB that they will be able to use them correctly, appreciate their limitations, and modify them when necessary to suit their own needs.

The Chapters

  1. Introduction to MATLAB
  2. Linear Equations
  3. Interpolation
  4. Zero and Roots
  5. Least Squares
  6. Quadrature
  7. Ordinary Differential Equations
  8. Random Numbers
  9. Fourier Analysis
  10. Eigenvalues and Singular Values
  11. Partial Differential Equations

George Forsythe initiated such a software-based numerical methods course at Stanford University in the late 1960s. The 1977 textbook by Forsythe, Malcolm, and Moler and the 1989 textbook by Kahaner,Moler, and Nash that evolved from the Stanford course were based upon libraries of Fortran subroutines. This new book can be thought of as a modern, MATLAB oriented replacement for those texts.

Two editions of the book are available, an electronic edition published by The MathWorks and a conventional print edition published by the Society for Industrial and Applied Mathematics (SIAM).

The book is intended for students in engineering and science who want to have a better understanding of the numerical methods implemented in MATLAB and similar mathematical software systems. The prerequisites for the course, and the book, include:

  • Calculus
  • Some familiarity with ordinary differential equations
  • Some familiarity with matrices
  • Some computer programming experience

If students have never used MATLAB, the first chapter will help them get started. If they are already familiar with MATLAB, they can glance over most of the first chapter quickly. Everyone should read the section in the first chapter about floating-point arithmetic.

Regular readers of Cleve’s Corner will find the book familiar. Several sections of the book, including the ones on floating-point arithmetic, stiffness, random number generation, and the L-shaped membrane, are expanded versions of previous columns in MATLAB News & Notes.

A collection of more than 70 M-files, which I refer to as NCM, forms an essential part of the book. These are available from the MathWorks Web site devoted to the book. There are three types of NCM files:

  • gui files: interactive graphical demonstrations
  • tx files: textbook implementations of built-in MATLAB functions
  • others: miscellaneous files, primarily associated with exercises

For example, one of the of the tx files, lutx, shows the algorithm used by the built-in function involved in the most important computation in MATLAB: the solution of simultaneous linear equations. Another tx file, ffttx, provides a compact implementation of the fast algorithm for the finite Fourier transform. The original Forsythe et al. text was successful in part because its Fortran programs were small enough to be read and understood. In retrospect, I think the codes distributed with Kahaner et al. were too large and unwieldy. MATLAB enables us to return to programs that can be printed in the book and discussed in class.

The book makes extensive use of computer graphics.When you have NCM available, the MATLAB statement


produces a window where each of 20 thumbnail plots launches a graphical demonstration of some problem, algorithm, or mathematical application (Figure 1).Most of these GUI programs are interactive. You may already be familiar with eigshow, because it is distributed with MATLAB. The other GUIs have the same spirit as eigshow. For example, with lugui, you choose the pivots in Gaussian elimination.With fzerogui, the plot zooms in on the point where a function crosses the x-axis.



Figure 1: Each of 20 thumbnail plots launches a graphical demonstration of some problem, algorithm, or mathematical application. Click on image to see enlarged view.

There are more than 200 exercises. Some of them involve modifying and extending the programs in NCM. I don’t want students to write their own programs from scratch. I would rather they start with the programs that I’ve written. For example, one exercise asks them to modify lutx to keep track of the sign of the permutation and then compute the determinant. Another exercise has students remove the step size calculation from the ODE solver, ode23tx, and implement the classical Runge-Kutta algorithm with fixed-step size.

Some of the exercises involve ill-posed problems.What does bslashtx do with a singular system of linear equations? How does quadtx behave if the integral doesn’t exist?

An exercise from Forsythe et al. that involved U. S. Census data from 1900 through 1970 now has three more data points and a GUI. Exercises in the chapter on least squares examine the Statistical Reference Datasets from the National Institute of Standards and Technology.

A Cleve’s Corner about Google, "The World’s Largest Matrix Computation," has been expanded to become a section on "PageRank and Markov Chains" and several exercises about sparse matrices and Web graphs. The example about touch-tone dialing that has been in MATLAB for many years, phone.m, has been expanded into the section introducing the FFT.

I’ve been working on this book for several years. Along with a few colleagues, I’ve had a chance to use it in both undergraduate and graduate university courses, and in two-day MathWorks training courses. I hope that students and teachers will find it useful for their own courses, and in their own individual study.

Published 2004

Receive the latest MATLAB and Simulink technical articles.

Related Resources

Latest Blogs