Majewski MuPAD Pro Computing Essentials
Springer Berlin Heidelberg New York Barcelona Hong Kong London Milan Paris Tokyo
Miroslaw Majewski MuPADPro Computing Essentials, Springer
Miroslaw Majewski Zayed University College of Information Systems P.O. Box 4783 Abu Dhabi United Arab Emirates http://www.mupad.com/majewski/ Cataloging-in-Publication Data applied for Die Deutsche Bibliothek - CIP-Einheitsaufnahme Majewski,Miroslaw: MuPAD pro computing essentials 1 Miroslaw Majewski. - Berlin; Heidelberg; New York; Barcelona; Hong Kong; London; Milan; Paris; Tokyo: Springer, 2002 ISBN-13: 978-3-540-43574-7 e-isbn-13: 978-3-642-97910-1 DOl: 10.1007/978-3-642-97910-1 ISBN-13: 978-3-540-43574-7 Mathematics Subject Classification (2000): 97U50, 97U70 This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilm or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer-Verlag. Violations are liable for prosecution under the German Copyright Law. Springer-Verlag Berlin Heidelberg New York amember of Bertels mann Springer Science+Business Media GmbH http://www.springer.de Springer-Verlag Berlin Heidelberg 2002 The use of general descriptive names, registered names, trademarks etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. Cover graphics by the author using POV-Ray Cover design: design & production, Heidelberg Typesetting by the author using Scientific Notebook from MacKichan Software, Inc. Printed on acid-free paper SPIN 10877255 40/3142ck-54 3210
PREFACE~ The selection of topics making up mainstream mathematics has always been in a state of flux, depending on the state of mathematical knowledge and discovery, our changing understanding and interpretation of basic mathematical theorems and concepts, newly-found solutions to important mathematical problems, the interests of young researchers, and the computational needs of users of mathematics. An additional force is about to make inroads into determining our choice of topics: the personal computer and the computer algebra systems created for it. This book is one of the first to provide us with an exciting glimpse into the vast range of possibilities for rethinking what and how we teach in our mathematics courses. The book MuP AD Pro Computing Essentials does not pretend to be all things to all people. It is a very personal account of one new perspective of how mathematics can be taught and studied with the help of computer algebra. The selection of topics in this book is broad enough to satisfy the needs of most college and undergraduate university mathematics majors programs. Teachers of mathematics are currently locked in vigorous debate about the virtues of computer-assisted teaching and learning. Opponents of the use of this technology argue that student fails to learn the basics. All they manage to acquire is a facility for pressing appropriate buttons to achieve mathematical output that they fail to understand. This is precisely why it is essential that the proponents of computer-assisted teaching and learning write good books that illustrate the pedagogical and mathematical benefits of technology. The present book is an excellent example of what is needed. Let us consider the range of topics covered in the text. The first five chapters deal with the mechanics of using MuPAD. In doing so, they provide a quick introduction to basic principles of mathematical programming. This is appropriate for several reasons. First of all, it is required reading for those interested in using MuPAD. But it is also indispensable for all mathematics student who hope to use their knowledge in the workplace. Today and in the years to come,
mathematics graduates worth their salt are expected to be able to program in much the same way as they were expected to be able to use logarithm tables, slide rules and other gadgets in the past. The real contribution of the computer algebra approach to teaching and learning begins with Chapter 6. The study of graphs and surfaces has been revolutionized with help of computers. It is generally agreed that today's students are visually than verbally oriented. What better way to begin their mathematical career than to build on this skill Chapters 9 to 13 provide an excursion into the more traditional topics of college mathematics: the language of sets, number systems, and some algebra, trigonometry, calculus and linear algebra. As such, the book is in many ways a launching pad for the study of deeper mathematics with the help of MuPAD. The rapid development of specialized and advanced MuP AD libraries makes it possible to advance the project well beyond the practical limits set for this book. I am looking forward to introducing my students to new ways of thinking about mathematics using the MuP AD Pro Computing Essentials. Prof. Fred Szabo Concordia University Montreal, Canada
Contents 1. Introduction........ 1 1.1 What is Special about MuPAD... 2 1.2 What may you expect... 3 1.3 Writing "between"... 3 2. A Quick Introduction to MuPAD. 7.1 The Very First Look... 7 :2..:2. Getting Started... 9 :2..3 A Quick Look at MuPAD's Interface... 13.4 Formatting Documents in MuPAD... 16.5 Getting Help... 18.6 Chapter Summary... 21.7 Review Exercises... 22 3. Programming in MuPAD - Declarations 25 3.1 Declaring Variables and Functions... 25 3.2 Declaring Functions... 28 3.3 Writing Formulae in MuPAD... 30 3.4 Writing More than One Line of Code... 32 3.5 The Basics of the Domain Concept... 33 3.6 Chapter Summary... 37 3.7 Review exercises... 40 4. Programming in MuPAD - Control Structures... 43 4.1 Decisions... 43 4.1.1 MuPAD Syntax: the "if.. then" Statement... 45 4.1.2 Indentation in MuPAD... 46 4.1.3 Quadratic Equation Example... 47 4.1.4 Formatting the Output... 50 4.1.5 elif - a Useful Shortcut... 51 4.2 Programming Iterations in MuPAD... 52 4.2.1 The "for" loop... 52 4.2.2 MuPAD S ntax: the "for" Loo... 53
II MuPAD Pro Computing Essentials 4.2.3 The "while" and "repeat.. Loops... 54 4.2.4 MuPAD Syntax: the "while" and "repeat" Loops... 56 4.3 Selections... 56 4.3.1 MuPAD Syntax: the "case" Structure... 59 4.4 Chapter Summary... 60 4.5 Programming Exercises... 62 5. Programming in MuPAD - Procedures and Libraries..... 65 5.1 What is a Procedure... 68 5.2 Examples of Procedures... 68 5.3 Getting Output from Procedures... 75 5.4 Returning Unevaluated or Symbolic Expressions... 78 5.5 Shall We use Global or Local Variables?... 80 5.6 Using the Right Data Types in Procedures... 83 5.7 Domains and Types Summary... 87 5.8 Using Procedures to Produce Data Structures... 92 5.8.1 Sequences... 92 5.8.2 Lists... 94 5.8.3 Sets... 95 5.8.4 Strings... 95 5.B.5 Vectors and Matrices... 97 5.9 Procedures with Variable Number of Parameters... 100 5.10 Recursive Procedures... 103 5.11 Using Libraries... 107 5.12 User Defined Libraries of Procedures... 110 5.13 Final Comments on MuPAD Coding Guidelines... 114 5.13.1 Magic Numbers... 115 5.13.2 Comments... 115 5.13.3 Braces... 116 5.14 Chapter Summary... 118 5.15 Programming Exercises... 122 6. Introduction to MuPAD Graphics........ 125 6.1 Obtaining Quick Plots... 125 6.1.1 Procedure plotfunc2d... 126
Contents III 6.1.2 Procedure plotfun3d... 130 6.2 General Concept of MuPAD Plots... 131 6.2.1 Object Attributes & Options... 135 6.3 Object Options... 139 6.3.1 Color... 139 6.3.2 Grid... 142 6.3.3 Smoothness... 143 6.3.4 LineWidth... 143 6.3.5 LineStyle... 144 6.3.6 Style for 20 Objects... 144 6.3.7 Style for 3D Objects... 144 6.3.8 PointStyle & PointWidth... 147 6.3.9 Filled... 150 6.3.10 RealValuesOnly... 150 6.3.11 Discont... 150 6.3.12 Title & TitlePosition... 150 6.4 Scene-Specific Plotting Options... 151 6.4.1 Axes... 151 6.4.2 Labeling... 151 6.4.3 Environment... 152 6.4.5 Output... 153 6.4.6 Object Options Defined in Scene... 154 6.5 Operations on Graphical Objects... 155 6.5.1 Operation copy... 155 6.5.2 Operation modify... 156 6.5.3 Operation Group... 157 6.6 Chapter Summary... 159 6.7 Programming Exercises... 163 7. Exploring Mathematical Curves and Surfaces......... 165 7.1 VCam Tool... 165 7.2 Plots in 20 Space & Plot Types... 170 7.2.1 Procedure Function2d... 170 7.2.2 Procedure Curve2d... 173
IV MuPAD Pro Computing Essentials 7.2.3 Developing Polar Plots... 176 7.2.4 Developing Implicit Plots... 178 7.3 Plots in 3D Space... 184 7.3.1 Procedure Function3d... 184 7.3.2 Procedure Surface3d... 190 7.3.3 Procedure spherical... 192 7.3.4 Procedure cylindrical... 196 7.3.5 Procedure Curve3d... 198 7.4 Chapter Summary... 200 7.5 Programming Exercises... 201 8. A Few Applications of MuPAD Graphics...... 207 8.1 Calculus Graphics... 207 8.1.1 Plotting Contours... 207 8.1.2 Developing Density Plots... 211 8.1.3 Vector Fields... 213 8.1.4 Plotting Inequalities... 215 8.1.5 Operations on Functions... 217 8.2 Presentation Graphics... 219 8.2.1 Presentation Graphics in MuPAD Version 2.0... 220 8.2.2 Presentation Graphics in MuPAD Versions 2.x... 223 8.3 Working with Geometry Objects... 224 8.4 Turtle Graphics & L -systems... 236 8.4.1 Turtle Graphics in MuPAD... 236 8.4.2 Plotting L-systems... 240 8.5 Chapter Summary... 245 8.6 Pro rammin Exercises... 248 9. Exploring Numbers with MuPAD... 253 9.1 Integers in MuPAD... 253 9.2 Rational Numbers in MuPAD... 261 9.3 Real Numbers in MuPAD... 266 9.4 Complex Numbers in MuPAD... 271 9.5 Chapter Summary... 276 9.6 Programming Exercises... 279
Contents v 10.1 Polynomials...... 283 10.2 Rational Expressions... 290 10.3 Algebraic Expressions... 293 10.4 Trigonometric and other Functions... 294 10.5 Solving Equations and Inequalities... 299 10.6 Chapter Summary... 308 10.7 Programming Exercises... 309 11. Working with Sets and Sentences MuPAD. 311 11.1 Logic in MuPAD... 311 11.1.1 Polish Notation... 314 11.2 Working with Sets... 320 11.3 Chapter Summary... 329 11.4 Programming Exercises... 330 12. Exploring Calculus with MuPAD. 333 12.1 Limits... 333 12.2 Derivative... 340 12.3 Working with Integrals... 350 12.4 Infinite Series and Products... 359 12.5 Calculus of Two Variables... 365 12.5.1 Limits of Functions of Two Variables... 366 12.5.2 Partial Derivatives... 367 12.6 Chapter Summary... 371 13. Linear Equations, Matrices and Determinants... 377 13.1 Checking Resources... 377 13.2 Solving Linear Equations... 379 13.3 Matrices and Operations on Matrices... 381 13.3.1 Declaring Matrices in MuPAD... 381 13.3.2 Global Operations on Matrices... 387 13.3.3 Local Matrix Operations... 395 13.4 Determinants... 401
MuPAD Pro Computing Essentials 13.5 Chapter Summary... 406 13.6 Programming Exercises... 409 Appendix 1: MuPAD Libraries and Procedures... 413 A1.1 MuPAD Libraries (ver. 2.5, 18/01/2002)... 414 A1.2 Operators Represented by Symbols...415 A1.3 MuPAD Standard Collecton... 415,,1.4 Library 'adt' - Abstract Data Types... 423 A 1.5 Library 'Ax' - Basic Axiom Constructors... 423 A1.6 Library 'Cat' - Category Constructors...423 A1.7 Library 'combinat' - Combinatorial Functions... 424 A1.8 Library 'detools' - Methods for Differential Equations... 425 A1.9 Library 'Dom' - Domain Constructors... 426 A1.10 Library 'fp' - Utilities for Functional Programming... 427 A1.11 Library 'generate' - Generate Foreign Formats...428 A1.12 Library 'groebner' - Utilities for Groebner Bases... 428 1.13 Library 'import' - Utilities for Reading Data... 428 A1.14 Library 'intlib' - Definite and Indefinite Integration...428 A1.15 Library 'linalg' - the Linear Algebra Package... 428 A1.16 Library 'Unopt' - Tools for Linear Optimization... 431 A1.17 Library 'listlib' - Operations on Lists... 431 A1.18 Library 'matchlib' - Pattern Matching Tools...432 A1.19 Library 'module' - Module Management Tools... 432 A1.20 Library 'Network' - Tools for Directed Graphs...432 A1.21 Library 'numeric' - Tools for Numerical Methods... 433 A1.22 Library 'numlib' - Elementary Number Theory...435 A1.23 Library 'orthpoly' - Orthogonal Polynomials... 436 A1.24 Library 'output' - Tools for the Output of Data... 437 A1.25 Library 'plot' -- 20 and 3D Graphical Objects... 437 A1.26 Library 'polylib' - Tools for Polynomials... 439 A1.27 Library 'prog' - Programming Utilities... 440 A1.28 Library 'property' - Properties of Identifiers... 440 A1.29 Library 'RGB' - Color Names... 441 A1.30 Library 'Series' - Tools for Series Expansions... 444
Contents VII A1.31 Library 'solvelib' - Tools for Solving Equations... 444 A1.32 Library 'specfunc' - Elementary and Special Functions... 445 1.33 Library 'stats' - Statistical Functions... 446 A1.34 Library 'stringlib' - Tools for String Manipulation... 450 A1.35 Library 'student' - the Student Package... 451 A1.36 Library 'transform' - Integral Transformations... 451 1.37 Library 'Type' - Predefined Types... 451,<\1.38 MuPAD Environmental Variables... 453 Appendix 2: MuPAD Resources.... 455