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 wagon@macalester.edu 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 A Brief Introduction 0.1 Notational Conventions 0.2 Typesetting 0.3 Basic Mathematical Functions 0.4 Using Functions 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 Plotting 19 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 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 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 3.5 Bicycles, Square Wheels, and Square-Hole Drills 90 98 vi Contents 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 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 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 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 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 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 20.1 The Riemann Zeta Function 505 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 21 Miscellany 519 523 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 — allowing the user to dynamically 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 animations, 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 mathematics 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: Well-chosen computations can shed light on familiar relations and reveal new patterns One is forced to think very precisely; gaps in understanding must be eliminated if a program is to work Dozens (or hundreds or thousands) of cases can be examined, perhaps showing new patterns or phenomena Methods of verifying the results must be worked out, again adding to one's overall understanding Different proofs of the same theorem can be compared from the point of view of algorithmic efficiency 564 References [PH] P Prusinkiewicz and J Hanan, Lindenmayer Systems, Fractals, and Plants, Lecture Notes in Biomathematics, vol 79, Springer, New York, 1989 [PL] P Prusinkiewicz and A Lindenmayer, The Algorithmic Beauty of Plants, Springer, New York, 1990 [RW] S Rabinowitz and S Wagon, A spigot algorithm for the digits of Π, American Mathematical Monthly 103 (1995) 195–203 [Reu] F Reuleaux, The Kinematics of Machinery, trans A Kennedy, Dover, New York, 1963 (reprint of 1876 translation of 1875 German original) [Rib] P Ribenboim, The New Book of Prime Number Records, Springer, New York, 1996 [RG] H Riesel and G Göhl, Some calculations related to Riemann's prime number formula, Mathematics of Computation 24 (1970) 969–983 [RSST] N Robertson, D P Sanders, P D Seymour and R Thomas, The four colour theorem, Journal of Combinatorial Theory Ser B 70 (1997) 2-44 [Sen] M Senechal, Quasicrystals and Geometry, Cambridge Univ Pr., New York, 1996 [SK] T L Saaty and P C Kainen, The Four Color Problem: Assaults and Conquest, McGraw-Hill, New York, 1977 [Sau] T Sauer, Computer arithmetic and sensitivity of natural measure, Journal of Difference Equations and Applications, 11 (2005) 669–676 [Sch] L Schoenfeld, Sharper bounds for the Chebyshev functions Θ x and Ψ x , II, Mathematics of Computation 30 (1976) 337–360 [Sim] A J Simoson, Pursuit curves for the Man in the Moone, College Mathematics Journal 38 (2007) 330–338 [Ste] H Steinhaus, Mathematical Snapshots, rev ed., Oxford University Press, New York, 1963 [SW] T Sibley and S Wagon, Rhombic Penrose tilings can be 3-colored, American Mathematical Monthly 106 (2000) 251–253 [SWS] Slavik, A., Wagon, S., and Schwalbe, D., VisualDSolve, Visualizing differential equations with Mathematica, Wolfram Research, Inc., Champaign, Ill., 2009 [teR] H J J te Riele, On the sign of the difference Π x puta-tion 48 (1987) 323–328 li x , Mathematics of Com- References 565 [TF] G B Thomas and R L Finney, Calculus and Analytic Geometry, 7th ed., Addison-Wesley, Reading, Mass., 1988 [Tor] B Torrence, TravelingSalesmanGame, from the Wolfram Demonstrations Project, http://demonstrations.wolfram.com/TravelingSalesmanGame, 2008 [Tro] M Trott, Bicycle rides, from the Wolfram Demonstrations Project, http://demonstrations.wolfram.com/BicycleRides, 2008 [Wag1] S Wagon, The Banach–Tarski Paradox, Cambridge Univ Pr., New York, 1985 [Wag2] S Wagon, An April Fool's hoax, Mathematica in Education and Research 7:1 (1998) 46–52 [Wag3] S Wagon, The ultimate flat tire, Math Horizons (Feb 1999) 14–17 [Wag4] S Wagon, A machine resolution of a four-color hoax, Abstracts for the 14th Canadian Conference on Computational Geometry, Aug 2002, Lethbridge, Canada, 181–192 [Wag5] S Wagon, The Banach–Tarski Paradox, from the Wolfram Demonstrations Project, http://demonstrations.wolfram.com/TheBanachTarskiParadox, 2007 [Wei1] E W Weisstein, Prime Counting Function, from MathWorld, A Wolfram Web Resource http://mathworld.wolfram.com/PrimeCountingFunction.html [Wei2] E W Weisstein, AKS Primality Test, from MathWorld, A Wolfram Web Resource http://mathworld.wolfram.com/AKSPrimalityTest.html [Wei3] E W Weisstein, Torus Cutting, from MathWorld, A Wolfram Web Resource http://mathworld.wolfram.com/TorusCutting.html [Wei4] E W Weisstein, Villarceau Circles, from MathWorld, A Wolfram Web Resource http://mathworld.wolfram.com/VillarceauCircles.html [Wei5] E W Weisstein, Polynomial Roots, from MathWorld, A Wolfram Web Resource http://mathworld.wolfram.com/PolynomialRoots.html [Wei6] E W Weisstein, Riemann Hypothesis, from MathWorld, A Wolfram Web Resource http://mathworld.wolfram.com/RiemannHypothesis.html [Win] P Winkler, Mathematical Mind-Benders, A K Peters, Wellesley, Mass., 2007 [Zag] D Zagier, The first 50 million prime numbers, The Mathematical Intelligencer (1977) 7–19 [Zwe] G Zweig, An effective tour construction and improvement procedure for the Traveling Salesman Problem, Operations Research 43:6 (1995) 1049–1057 Mathematica Index &&, and, , apply, ;, condition, 327 AppearanceElements, 148–149 AppendTo, 210 Apply, 8–9, 55 : , delayed assignment, Area, 400 : , delayed replacement, 38, 85 Array, 13 , delayed replacement, 38, 85 , equals as in an equation, 302 , function application, ??, information, , map, , not, factorial, 5–6 , or, ArrayDepth, 245 ArrayPlot, 298–299 AspectRatio, 25, 41–42, 79 AxesOrigin, 26 Attributes, AxesEdge, 120 AxesLabel, 120 _, pattern, , pattern alternative, 170 , postfix function notation, , previous output, &, pure function end, 11–12, 14 BarChart, 41 BaseForm, 172 BernoulliB, 507 BezierCurve, 150 , pure function variable, 11–12, 14, 121 Binomial, 140 Blend, 503 , replace, 12 , second previous output, BoundaryStyle, 239 , substitution rule, 12 BoxRatios, 120–123 , substitution rule, 12 CantorFunction, 174 Accumulate, 67 Cases, 172, 319 AccuracyGoal, 315 CellContext, 153 AddEdge, 435 CellPrint, 153 AdjacencyGraph, 454–455 CertifiedRandomPrime, 529 AlexanderPolynomial, 22 Chop, 126 Alignment, 145 CircularVertices, 436 AllCycles, 345 CityData, 434 AllRoots, 313 ClassifyCP1D, 327 Animate, 79 ClassifyCP2D, 324–325 AnimationRate, 139 Clear, 17 Apart, 17 CobwebPlot, 182–185, 191–194, 198 Appearance, 142, 148–149 Coefficient, 18 Mathematica Index 567 CoefficientArrays, 337 DeleteCases, 40, 426 CoefficientList, 18, 38 Denominator, 507 Collect, 18, 486 DensityPlot, 117, 385 ColorData, 115–116, 156, 369 DiagonalMatrix, 13, 310 ColorFunction, 42–43, 115, 126, 156, Differences, 231 -236, 241 Directive, 122 ColorFunctionScaling, 236, 241 Disk, 79 Column, 116 Distance, 414 Combinatorica package, 339, 345, Distribute, 10 -432–437, 534 Dividers, 63 Compile, 183, 202, 204 Divisible, 56 CompleteGraph, 432–434 Divisors, 55 ComplexBase, 176–178 Dot, 496 ComplexTicks, 279 Drop, 14 ComplexTrajectory, 283 DSolve, 364, 376 ComputationalGeometry package, Dynamic, 116, 126, 151–152, 154–156, -440 -299 ConjugateGradient, 312 ConnectedComponents, 534 EdgeForm, 80, 148 ConstantArray, 310-312 EdgeRenderingFunction, 536 ContourPlot, 114–115, 128, 137–138, EdgeStyle, 435 -156, 324 ElectricalGridSocketImages, ContourPlot3D, 255–257, 319, 371 -551 Contours, 117 Epilog, 41, 64 ContourStyle, 117, 256 ErreraGraph, 447, 456 ControlPlacement, 146 Evaluate, 32–33, 51, 83, 182, 369 ControlType, 147 EvaluationMonitor, 29, 352 Convert, 94 EulerFormulaDemo, 442–443 ConvertTemperature, 393 EulerPhi, 58–59, 307 ConvexVertex, 400–401 EventAction, 387 Costa, 257–258 EventLocator, 387 Count, 68 Exclusions, 35–36 CountryData, 20, 230–231, 434, 438, ExclusionStyle, 35 -543, 551–552 Expand, 17–18 Cylinder, 160 ExpIntegralEi, 514–517 D, 33, 83 FaceForm, 148, 241–242 DegreeSequence, 444 Factor, 142 DelaunayTriangulation, 440 FactorForm, 55 568 Mathematica Index FactorInteger, 55 GraphicsGrid, 46, 89, 138, 176 Fibonacci, 37–39, 72 Graphics, 79–80 FilledJuliaSet, 294–296 Graphics3D, 236 FilterRules, 51 GraphPlot, 434, 536, 539 FindFit, 332–333 GraphPlot3D, 471 FindInstance, 309–310 Gray, 79 FindMinimum, 98, 330–333, 351, Grid, 63, 96, 475 -353–354, 394–396 GridLines, 97 FindRoot, 193, 314–317, 366 FindRoots, 317–319, 511 HarmonicRearrangement, 526–528 FindRoots2D, 318–323, 372 Hue, 42 FindShortestTour, 224–226, -229–232, 343 IdentityMatrix, 13 FixedPoint, 11 InexactNumberQ, 52 FixedPointList, 11–12 Inner, Fold, 12 InputField, 147 FoldList, 12 InputForm, 3, 11, 187–188 FontFamily, 63 Inside, 401 Format, 498 IntegerDigits, 40 FourColorCountries, 439 InterpolatingFunction, 365–366 FourColoring, 453, 456, 463, 469 Interpolation, 365, 550 FractalTurtle, 211–213, 217–221, InterpolationOrder, 119 -233–234 IntersectClosed, 413 FrameStyle, 117 IntersectOpen, 413 FrameTicks, 26, 35, 117 Interval, 189, 323, 326, 348–349 FrobeniusSolve, 308, 343, 542 IntervalUnion, 323 FrobeniusNumber, 309, 542 InversePermutation, 339 FullForm, 15 FullSimplify, 18, 484 Julia, 292 Function, 122 JuliaSet package, 286 FunctionExpand, 18, 39 KitesAndDarts, 274 GCD, 55–56 KnotData, 22 GeneratedParameters, 306 KochPlanet, 263–265 GeometricTransformation, 101 Krylov, 312 Get, 16 GoldenRatio, 39, 270 LambertW, 303–304 Graph, 436 LCM, 55–56 GraphicsColumn, 185 LeftOf, 401, 413 Mathematica Index 569 Lighting, 242, 245 N, 52, 189–190 Line, 79 NDSolve, 366–369, 375, 387 LinearProgramming, 336–338, 342 Nest, 1, 33, 81, 180 LinearSolve, 310-312 NestList, 11, 33, 74, 172, 180 LineIntersection, 414 NestWhile, 531 Listable, 8, 492 NIntegrate, 96–98, 315, 476, 524 ListAnimate, 43 NMinimize, 331–332, 360–361 ListContourPlot, 118–119 NonCommutativeMultiply, 425, ListConvolve, 298–299 -492, 496 ListLinePlot, 40–41, 64 Normal, 28, 48, 310, 319 ListPlot, 37 NormalDistribution, 549 Locator, 148–151 NSolve, 312, 378, 396 LocatorAutoCreate, 150 NumberForm, 126 LogIntegral, 63–64 LowestCriticalPoint, 350–351 Opacity, 127, 410 Options, 24, 87 Manipulate, 30, 43, 47, 126, 139, Orientation, 400–401 -141–167, 299, 370, 416 Outer, Map, 7–8 MapAprilFools, 460–461 Pane, 116, 144–145, 154 MapColoring package, 432, 437–438 Paneled, 148–149 MapOfWesternEurope, 438 ParametricPlot, 42–48 Maximize, 333–335 ParametricPlot3D, 133, 236–244, MatrixForm, 13, 337 -259 MaxRecursion, 28–29, 121, 146 PDF, 549 Mean, 148 PhiMultiplicity, 308 Mesh, 28–29, 41, 45, 121, 130, 135–136, PhysicalConstants package, 22 -239 PlanarGraph, 437 MeshFunctions, 45, 121, 130, PlanarMap, 437–438 -135–136, 243–244, 316 PlaneGeometry package, 402, 413, MeshShading, 45, 135–136, 245 -419, 421 MeshStyle, 28–29, 41, 45, 121, 130 Plot, 24–36 Minimize, 334 Plot3D, 118–120, 123–127, 140 Mod, 56 PlotPoints, 28, 121, 146 Module, 80, 153 PlotRange, 24, 80 Modulus, 306 PlotStyle, 32, 181–182 MoebiusMu, 516 PolarPlot, 44 Monitor, 260 PolygonDiagonal, 401 Most, 14 PopupMenu, 147 570 Mathematica Index PowerExpand, 18–19, 91–92, 485 RootApproximant, 38–39 PowerMod, 56–58 RotationTransform, 101, 232 PrecisePlot, 51–52 Row, 147 Precision, 50, 187–188, 191 RSolve, 39 PrecisionGoal, 52, 315, 378 PrimalityProving package, 529 SaveDefinitions, 152 Prime, 54 SecondDerivativeTest, 129 PrimePi, 54, 60, 64–65, 68 SeedRandom, 421 PrimePiMod, 68 Select, 14, 56 PrimeProduct, 70–71 Sequence, 51 PrimeQ, 57–58, 76, 528 SeidelRoom, 408–411 ProductLog, 303 Series, 27, 48 Protect, 425, 492 SetAttributes, 52, 492 ProgressIndicator, 201 SetOptions, 26, 432 ProvablePrimeQ, 529 Setter, 145 PseudoPrimeQ, 58 SetterBar, 139, 145, 147 Shadow, 356 RandomGreatCircleGraph, 468 Shallow, 85 RandomPolygon, 402 Show, 30 RandomPermutation, 339 ShowAdjacencyGraph, 439–440 RandomPlanarGraph, 441 ShowGraph, 432–436, 534 RandomPlanarMap, 440 ShowLabeledGraph, 434 RandomReal, 118, 180 ShowMap, 439–441, 460 Range, 14, 54 ShowPlanarGraph, 441, 447, 454 Rationalize, 51, 335, 507 Sign, 400 Reap, 29, 211 SignedArea, 400, 413 Reduce, 59, 128, 303, 305–308, 313, Simplify, 17 -317, 444 SoiferGraph, 456 Remove, 17 Solve, 12, 57, 128, 302–306, 310 Replace, 12 Sow, 29, 211 RegionFunction, 121–122, 245, 248, SparseArray, 310–312, 337 -250, 256, 259 Specularity, 127, 256–258 RegionPlot, 371 SplineDegree, 150 Rest, 14 SquaresR, 309 RiemannR, 62, 65, 513, 518, 520–522 StableMarriage, 339 RiemannSiegelZ, 318, 510–511 StarrPlot, 46–47 Riffle, 183 StefanConstant, 22 RightOf, 401, 413 SteinerPoint, 421 Root, 302, 306, 317 SteinerTree, 421 Mathematica Index 571 StereographicInverse, 470 TSPSpaceFillingCurve, 228 StandardForm, Tube, 250, 253 StringReplace, 210 Tuples, 426 StrongPseudoprimeQ, 74–75 Turtle package, 213, 228 Style, 63 SynchronousUpdating, 152 Units package, 22, 94, 393 Unprotect, 417, 425, 492–493 Table, 32 TableForm, 96 VectorAngle, 231–232 TableHeadings, 96 VertexColoring, 436, 441 Take, 14 VertexRenderingFunction, 539 Tally, 41, 286 VertexStyle, 435 Text, 64 VerticalSlider, 146 Thick, 26 Viewpoint, 123–126, 154–155 Thread, 9, 128, 426 ThreeColor, 405 WeierstrassInvariants, 257 Together, 17 WeierstrassP, 257 Tooltip, 31–34 WeierstrassZeta, 257 ToAdjacencyLists, 436 With, 170 ToRadicals, 305, 333, 502 WorkingPrecision, 50, 315, 378 ToRules, 59, 128, 306 ToString, 145 Zeta, 62, 507–508 TrackedSymbols, 153 ZetaZero, 318, 511 TraditionalForm, TranslationTransform, 101 $MaxExtraPrecision, 51, 190 Transpose, 55 $MaxPrecision, 355–356 Triangulate, 402–403 $MinPrecision, 355–356 TSPILP, 345 Subject Index Adamchik, V., 483 bifurcation plot, 204–208 adaptive plotting, 28, 120, 332, 351–352 bit-shift, 196–197 adaptive precision, 51, 189 blank, adjacency graph, 437, 439–440 Bleichenbacher, D., 75–76, 528 Agrawal, M., 76, 528 Bornemann, F., 520 alternating harmonic series, 525–528 Borwein, P., 474, 480, 482 angled text, 64 boundary scanning method, 297–299 animation, 43, 79–80 box ratios, 120–121, 123 Appell, K., 447 brachistochrone, 95 April Fools hoax, 459–461 breadth-first search, 540 Archimedes, 474 Brélaz algorithm, 436, 441 arcsine, 26 Brent, R., 478 area, signed, 400 Bryant, J., 101 arithmetic-geometric mean, 478–480 butterfly, 44 art gallery theorem, 404 Ash, M., 135 caching, 71–72, 260 Atwood, B., 158 cake cutting puzzle, 162–165 autocatalator, 367–368 Calvert, B., 135 Campbell, D., 202 Bailey–Borwein–Plouffe formula for Π, Cantor, G., 222 -480–487 Cantor function, 173–174 Bailey, D., 474, 480, 482 Cantor set, 169–173, 175, 215 Banach–Tarski paradox, 491–504 cardioid, 282 Bartholdi, J J., 223 Carmichael's conjecture, 59–60, 308 basin of attraction, 382, 385 catenary, 98 Baugh, D., 65 CCA algorithm for TSP, 224–226 Benford, F., 542 center of area, 417 Benford's law of first digits, 542–556 center of edges, 419 Berger, R., 269 center of gravity of polygon, 417 Bernoulli, John, 95 centroid, 417 Bernoulli, James, 95 Cervantes, U., 257 Bernoulli number, 506 chaos, 196 Bézier curve, 149–150 Chebyshev, P., 10, 53, 61–65 bicycle wheel, 105–111 check digits, 423–429 Subject Index 573 Chicken McNuggets, 308 dual graph, 437 Cho, W., 544 Duffing equation, 355, 376, 382–385 Chvátal, V., 404 Dunbar, S., 389 cobweb plot, 181–187, 191, 198 Collet, P., 205 ears, 404 comments, Eckmann, J.-P., 205 compiled functions, 202 epicycloid, 48 Coleman, C., 376, 378 equilibrium points, 372 Concorde program, 231 Errera, A., 447–448 cone, 237 Errera graph, 447, 457–458 constants of integration, 364 escape time algorithm, 284, 293–296 contexts, 16 Euclid, 70, 474 contour plot algorithm for roots, 319 Euclidean algorithm, 531 Conway, J H C., 275 Euclid number, 70, 73 convex vertex, 400 Euler, L., 478, 507 Costa, C., 257 Euler's formula, 441–443 Costa surface, 235–236, 257–261 Europe, 230 critical point, 113, 115, 127–129, 134, 323 evaporation, 397 curl, 158 curves in space, 236 Farris, F., 47–48 cycloid, 78, 82 Fatou set, 284 cylinder, 237 Fay, T., 44 Feigenbaum, M., 205 data sets, 19–20 Feigenbaum constant, 206 Davies, R., 135 Feller, W., 546 Delaunay triangulation, 440–441 Fermat's little theorem, 58 de la Vallée-Poussin, C., 519 Fewster, R., 545 delayed assignment, 3, Fibonacci numbers, 37–39, 72, 271 delayed replacement, 38, 85 Finn, D., 108–109 derivative, 33, 82–83 Fisk, S., 404 Devaney, R., 182 flags, 20 differential equations, 363–397 Ford, K., 60, 308 differential evolution, 360–361 Fowler, D., 139 Dijkstra's algorithm, 538, 540 four-color algorithm, 449–456, 461 Diophantine equations, 306 four-color theorem, 445–448 Dirichlet, G., 66 fractal dimension, 215 discontinuities, 35–36 free product of groups, 492, 495, 499 double torus, 254–255 Fricke, R., 496 574 Subject Index Fritsch, G., 448 Hilbert, D., 215 Frobenius problem, 308, 343 Hill, T P., 545 Frobenius number, 536–542 Hoffman, D., 257 Holmes, Sherlock, 389 Gaines, B., 544 Hubbard, J., 373–374, 385 Gale–Shapley algorithm, 339–340 Huygens, C., 90, 92, 474–475 Gallian, J., 427 hyperbolic plane, 495–504 Gardner, M., 269, 459 hypocycloid, 88–89 Gauss, C F., 53, 61–63, 65, 474, 478 Gaussian integers, 523, 530 in-line cell, Gaussian primes, 523, 530–536 integer linear programming, 342–343 Gaussian quadrature, 476 integration by parts, 524 Gethner, E., 448 interpolating function, 365 Glynn, J., 298 interval arithmetic, 189–190, 323, Godwin, F., 385 -346–351 Goffinet, D., 177 inverse iteration algorithm, 284–285 Göhl, G., 512, 514 ISBN numbers, 427 Gordon, B., 532 Israel, R., 45, 250 Gourdon, P., 511 Gray, A., 257 Jacobian, 354 Gray, T., 298 Jacobson, M V., 208 great circle graph, 468 Julia sets, 278, 284–296, 299–300 Greek letters, Green's theorem, 158 Karcher, H., 254 Gregory series, 489 Kayal, N., 76, 528 group, 423, 492 Kempe, A B., 431, 445–448, 457 group, dihedral, 424 Kempe's algorithm, 445–449, 456, 462, Grünbaum, B., 269 -464, 469 Kempe chains, 445–451, 462–463, Hadamard, J., 519 -465–466, 469 happy marriage, 341 keyboard shortcuts, Haken, W., 447 Kittell, I., 457 Hardy, G H., 68 Klein, F., 496 harmonic rearrangement theorem, 527 Klein–Fricke tiling, 496–499 Hausdorff, F., 493, 495 Knapp, R., 354, 376 Hausdorff paradox, 493–494, 500 Kocay, W., 469 Heawood, P J., 447 Koch snowflake, 212–215 helium balloon, 390–392 high precision, 353, 378 Lakes of Wada, 374 Subject Index 575 Lanford, O., 205 McGregor, W., 459 Legendre, A.-M., 53, 61–64 Meals-On-Wheels, 223 Lehmer, D H., 509 Meeks, W H., 257 Lehmer's phenomenon, 509–511 Meister, G., 404 Leibniz, G., 95 minimum, global, 322–323, 330–331, Leibniz series, 477–478 -346–352, 360 Levenberg–Marquardt method, 332, mixed partial derivatives, 130–132 -353–355 Möbius function, 62 l'Hopital, Marquis de, 95 Möbius strip, 240–242 Lichtblau, D., 343 Moore graph, 436 Lidicki, B., 462 Morley's theorem, 422 Lincoln, A., 84–86 morphing, 242–243, 260 Lindenmayer, A., 210 Morse theory, 325 linear fractional transformation, 495 Mycielski, J., 492, 499 linear programming, 334–336, 340 line integral, 157 Newcomb, S., 542 lion claws, 95 Newton, I., 92, 95, 474 Littlewood, J E., 68 Newton's law of cooling, 393 li x , 53, 63 Newton's law of gravity, 388 locators, 148–151 Newton's second law of motion, 390 logarithmic integral, 53, 63, 514–515 Newton's method, 11 L-systems, 210 nine-point circle, 417 Lucas pseudoprime, 76 nonanlytic function, 108 Luxembourg, 229–230 nonperiodic tiling, 268–269 Lyapunov exponent, 199–201 normal distribution, 547 nullcline curves, 371 machine precision, 190 machine reals, 187, 329 Oldham coupling, 101, 103–105 Machin's formula for Π, 478 Oliveira e Silva, T., 55 Maclaurin polynomial, 48 optimization, 323, 360 Man in the Moone, 385 optimization, constrained, 334 Mandelbrot, B., 262, 296–300 optimizing happiness, 341–342 Mandelbrot set, 193, 208, 278, 283, 292 option inspector, 19 map coloring, 458–467 options, 24, 87 marriage problem, 338 Or, I., 224 maximum, global, 113, 134 orientation of polygon, 400 maximum, local, 113, 134, 136 O'Rourke, J., 404 McClure, M., 278, 462 otectomy, 404 576 Subject Index packages, 15 PSL2 , 495 Pascal triangle, 139 pure function, 11 Peano curve, 215–218, 221 pursuit problem, 389 Peano, G., 215 Pell equation, 307 quadratic map, 165, 181, 183, 188, pendulum, forced and damped, -192–193, 329 -373–374 quasicrystals, 270 Penrose, R., 270 queue, 541 Penrose kites-and-darts, 273, 467 Penrose rhombs, 267, 274, 465–466 Rabinowitz, S., 482 Penrose tiling, 267, 275, 465–467 radiation, 396 pentagon, 423 railroad track puzzle, 314 phase plane, 368–369, 378 random search, 331–332, 361 pitchfork bifurcation, 185 recurrence formula, 39 planar graph, 433 recursion, 405, 449, 524–525 planar graph, random, 441 residual plot, 367 planimeter, 158, 161 Reuleaux, F., 100 plotting, 24–52 Reuleaux triangle, 77, 100 plotting, parametric, 42–48 Riccati equation, 389 Plouffe, S., 474, 480, 482 Riemann, B., 53, 61–65, 512 Pocklington's theorem, 529 Riemann function R x , 62, 506, 512, Poincaré disk model, 501–502 -519–510, 522 Poincaré section, 374 Riemann hypothesis, 65, 75, 506, polar coordinates, 133, 239 -508–511, 515 polar plot, 43–44 Riemann–van Mangoldt formula, 512, Polking, J., 380–381 -514 polygon triangulation, 401–402 Riemann Ζ function, 62, 65, 318, polynomial equation, 302 -506–522 polynomial roots, 312 Riesel, H., 512, 514 popular city names, Robertson, N., 447 Portmann, R., 397 Robinson, R M., 269–270 postage stamp problem, 308, 536 Rogers, M., 146 prime number race, 66–70 Romberg integration, 476 prime numbers, 53–75, 512, 528 roundoff error, 49, 165, 376 prime number theorem, 61 primes in arithmetic progressions, 66 saddle point, 135–136 probabilistic algorithm, 456 Salamin, E., 478 pseudoprime, 58 Salamin–Brent formula for Π, 478–479 Subject Index 577 Sanders, D., 447 string rewriting, 210 234 Sangwin C., 101 strong pseudoprime, 58, 73–75 Sarkovskii, A N., 195 subtractive cancellation, 187, 524 Sarkovskii theorem, 195 sum of squares, 309 Saxena N., 76, 528 symbolic summation, 477 Schoenfeld, L., 516 Seidel, R., 406 tautochrone, 90–94 Seidel room, 407–413 tax return auditing, 542 separatrix, 373, 383 Taylor series, 108 Sexton, H., 135 te Riele, H., 65, 511 Seymour, P., 447 tetrahedron, fractal, 261 shadowing, 165–167, 329, 353–360 Thomas, R., 447 Shephard, G C., 269 Thué equation, 307 shortest-path tree, 536 tooltip, 31–34 SIAM 100-Digit Challenge, 310, 322, Torrence, B., 224 -346, 360 torus, 235, 239, 245–250, 260 Sibley, T., 275 torus dissection puzzle, 243 Siegel disk, 283 torus knot, 22 Sierpin´ ski transparency, 127 , W., 60 similarity dimension, 214 traveling salesman problem, 223–227, Skewes number, 65 -344–346 Skewes, S., 65 turtle, 210–211 slider, fine control, 143 two-ear theorem, 404 Soifer, A., 448, 457 typesetting, space-filling curve, 209, 215–221 sphere, 238 underscore, spherical coordinates, 238 unicycle, 108 Springer, W M., 448 United States counties, 431, 462 square hole drill, 77, 99–105 United States map, 439, 442, 445, 464 square wheel bicycle, 98–99 United States postal service, 427 stack, 233 usage message, 15, 87 standard packages, 15 Starr, N., 45 Vamanamurthy, M K., 135 Stefan–Boltzmann law, 396 van Mangoldt, H., 512 Steiner tree, 421 vector field, 158 Steinhaus, H., 95 Velleman, D., 243 stereographic projection, 468 Verhoeff, J., 424, 427 Stewart, W A., 224 Villarceau circles, 250–253 578 Subject Index Wagon, S., 482–483, 499 word definitions, 21 Waldvogel, J., 519 Wang, H., 269 Zagier, D., 61 Watts, H J., 100 Zweig, G., 224 Whitesides, T., 442 Wilson's theorem, 56–57 Φ n , 58–60, 307–308 Winkler, P., 162 Π, 474–489 Wittenbauer point, 417 Π x , 54–55, 60–63, 515 .. .Mathematica in Action Stan Wagon Mathematica in Action Problem Solving Through Visualization and Computation Third edition Stan Wagon Department of Mathematics and Computer Science... 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... FractionBox "1","23" 23 begin an in- line cell 0.3 Basic Mathematical Functions Pi ( ), I ( ), Infinity ( ), E ( ), EulerGamma, and GoldenRatio are built -in constants To turn a symbolic value into