Mathematica in Action Stan Wagon Mathematica in Action Problem Solving Through Visualization and Computation Third edition Stan Wagon Department of Mathematics and Computer Science Macalester College 1600 Grand Avenue St. Paul, MN 55105 USA [email protected] Wolfram Mathematica ® is a registered trademark of Wolfram Research, Inc. ISBN 978-0-387-75366-9 e-ISBN 978-0-387-75477-2 DOI 10.1007/978-0-387-75477-2 Springer New York Dordrecht Heidelberg London Library of Congress Control Number: 2010928640 © Springer Science+Business Media, LLC 2010 All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer Science+Business Media, LLC, 233 Spring Street, New York, NY 10013, USA), except for brief excerpts in connection with reviews or scholarly analysis. Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed is forbidden. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com) Contents Preface ix 0 A Brief Introduction 1 0.1 Notational Conventions 2 0.2 Typesetting 3 0.3 Basic Mathematical Functions 5 0.4 Using Functions 7 0.5 Replacements 12 0.6 Lists 13 0.7 Getting Information 15 0.8 Algebraic Manipulations 17 0.9 Customizing Mathematica 19 0.10 Comprehensive Data Sets in Mathematica 19 1 Plotting 23 1.1 Plot 24 1.2 An Arcsin Curiosity 26 1.3 Adaptive Plotting 28 1.4 Plotting Tables and Tabling Plots 31 1.5 Dealing with Discontinuities 34 1.6 ListPlot 37 1.7 ParametricPlot 42 1.8 Difficult Plots 48 2 Prime Numbers 53 2.1 Basic Number Theory Functions 54 2.2 Where the Primes Are 60 2.3 The Prime Number Race 66 2.4 Euclid and Fibonacci 70 2.5 Strong Pseudoprimes 73 3 Rolling Circles 77 3.1 Discovering the Cycloid 78 3.2 The Derivative of the Trochoid 82 3.3 Abe Lincoln’s Somersaults 84 3.4 The Cycloid’s Intimate Relationship with Gravity 90 3.5 Bicycles, Square Wheels, and Square-Hole Drills 98 vi Contents 4 Three-Dimensional Graphs 113 4.1 Using Two-Dimensional Tools 114 4.2 Plotting Surfaces 119 4.3 Mixed Partial Derivatives Need Not Be Equal 130 4.4 Failure of the Only-Critical-Point-in-Town Test 134 4.5 Raising Contours to New Heights 137 4.6 A New View of Pascal’s Triangle 139 5 Dynamic Manipulations 141 5.1 Basic Manipulations 142 5.2 Control Variations 144 5.3 Locators 148 5.4 Fine Control 151 5.5 Three Case Studies 157 6 The Cantor Set, Real and Complex 169 6.1 The Real Cantor Set 170 6.2 The Cantor Function 173 6.3 Complex Cantor Sets 175 7 The Quadratic Map 179 7.1 Iterating Functions 180 7.2 The Four Flavors of Real Numbers 187 7.3 Attracting and Repelling Cycles 192 7.4 Measuring Instability: The Lyapunov Exponent 199 7.5 Bifurcations 202 8 The Recursive Turtle 209 8.1 The Literate Turtle 210 8.2 Space-Filling Curves 215 8.3 A Surprising Application 223 8.4 Trees, Mathematical and Botanical 233 9 Parametric Plotting of Surfaces 235 9.1 Introduction to ParametricPlot3D 236 9.2 A Classic Torus Dissection 243 9.3 The Villarceau Circles 250 9.4 Beautiful Surfaces 254 9.5 A Fractal Tetrahedron 261 Contents vii 10 Penrose Tiles 267 10.1 Nonperiodic Tilings 268 10.2 Penrose Tilings 270 10.3 Penrose Rhombs 274 11 Complex Dynamics: Julia Sets and the Mandelbrot set (by Mark McClure) 277 11.1 Complex Dynamics 278 11.2 Julia Sets and Inverse Iteration 284 11.3 Escape Time Algorithms and the Mandelbrot Set 292 12 Solving Equations 301 12.1 Solve 302 12.2 Diophantine Equations 306 12.3 LinearSolve 310 12.4 NSolve 312 12.5 FindRoot 314 12.6 Finding All Roots in an Interval 315 12.7 FindRoots2D 318 12.8 Two Applications 322 13 Optimization 329 13.1 FindMinimum 330 13.2 Algebraic Optimization 333 13.3 Linear Programming and Its Cousins 334 13.4 Case Study: Interval Methods for a SIAM Challenge 346 13.5 Case Study: Shadowing Chaotic Maps 353 13.6 Case Study: Finding the Best Cubic 360 14 Differential Equations 363 14.1 Solving Differential Equations 364 14.2 Stylish Plots 367 14.3 Pitfalls of Numerical Computing 376 14.4 Basins of Attraction 382 14.5 Modeling 385 15 Computational Geometry 399 15.1 Basic Computational Geometry 400 15.2 The Art Gallery Theorem 404 15.3 A Very Strange Room 406 15.4 More Euclid 413 viii Contents 16 Check Digits and the Pentagon 423 16.1 The Group of the Pentagon 424 16.2 The Perfect Dihedral Method 427 17 Coloring Planar Maps 431 17.1 Introduction to Combinatorica 432 17.2 Planar Maps 437 17.3 Euler’s Formula 441 17.4 Kempe’s Attempt 445 17.5 Kempe Resurrected 449 17.6 Map Coloring 458 17.7 A Great Circle Conjecture 468 18 New Directions for Π 473 18.1 The Classical Theory of Π 474 18.2 The Postmodern Theory of Π 480 18.3 A Most Depressing Proof 483 18.4 Variations on the Theme 488 19 The Banach-Tarski Paradox 491 19.1 A Paradoxical Free Product 492 19.2 A Hyperbolic Representation of the Group 495 19.3 The Geometrical Paradox 499 20 The Riemann Zeta Function 505 20.1 The Riemann Zeta Function 506 20.2 The Influence of the Zeros of Ζ on the Distribution of Primes 512 20.3 A Backwards Look at Riemann’s R x 519 21 Miscellany 523 (cid:72) (cid:76) 21.1 An Educational Integral 524 21.2 Making the Alternating Harmonic Series Disappear 525 21.3 Bulletproof Prime Numbers 528 21.4 Gaussian Moats 530 21.5 Frobenius Number by Graphs 536 21.6 Benford’s Law of First Digits 542 References 557 Mathematica Index 566 Subject Index 572 Preface This book is an example-based introduction to techniques, from elementary to advanced, of using Mathematica, a revolutionary tool for mathematical computation and exploration. By integrating the basic functions of mathematics with a powerful and easy-to-use programming language, Mathematica allows us to carry out projects that would be extremely laborious in traditional programming environments. And the new developments that began with version 6 — allowing the user to dynami- cally manipulate output using sliders or other controls — add amazing power to the interface. Animations have always been part of Mathematica, but the new design allows the manipulation of any number of variables, an important enhancement. Mathematica in Action illustrates this power by using demonstrations and anima- tions, three-dimensional graphics, high-precision number theory computations, and sophisticated geometric and symbolic programming to attack a diverse collection of problems.. It is my hope that this book will serve a mathematical purpose as well, and I have interspersed several unusual or complicated examples among others that will be more familiar. Thus the reader may have to deal simultaneously with new mathe- matics and new Mathematica techniques. Rarely is more than undergraduate mathematics required, however. An underlying theme of the book is that a computational way of looking at a mathematical problem or result yields many benefits. For example: (cid:159) Well-chosen computations can shed light on familiar relations and reveal new patterns. (cid:159) One is forced to think very precisely; gaps in understanding must be eliminated if a program is to work. (cid:159) Dozens (or hundreds or thousands) of cases can be examined, perhaps showing new patterns or phenomena. (cid:159) Methods of verifying the results must be worked out, again adding to one's overall understanding. (cid:159) Different proofs of the same theorem can be compared from the point of view of algorithmic efficiency.
Description: