Symbolic Math Toolbox™ 5 Mupad® Tutorial
Total Page:16
File Type:pdf, Size:1020Kb
Symbolic Math Toolbox™ 5 MuPAD® Tutorial How to Contact The MathWorks www.mathworks.com Web comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support [email protected] Product enhancement suggestions [email protected] Bug reports [email protected] Documentation error reports [email protected] Order status, license renewals, passcodes [email protected] Sales, pricing, and general information 508-647-7000 (Phone) 508-647-7001 (Fax) The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098 For contact information about worldwide offices, see the MathWorks Web site. Symbolic Math Toolbox™ MuPAD® Tutorial © COPYRIGHT 1997–2008 by SciFace Software GmbH & Co. KG. The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to The MathWorks, Inc. Trademarks MuPAD is a registered trademark of SciFace Software GmbH & Co. KG. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders. Patents The MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more information. Preface This book explains the basic use of the MuPAD® computer algebra system, and gives some insight into the power of the system. MuPAD is available as part of the Symbolic Math Toolbox™ in MATLAB®. This introduction addresses mathematicians, engineers, computer scientists, natural scientists and, more generally, all those in need of mathematical computations for their education or their profession. Generally speaking, this book addresses anybody who wants to use the power of a modern computer algebra package. There are two ways to use a computer algebra system. On the one hand, you may use the mathematical knowledge it incorporates by calling system functions interactively. For example, you can compute symbolic integrals or generate and invert matrices by calling appropriate functions. They comprise the system’s mathematical intelligence and may implement sophisticated algorithms. Chapters 2 through 14 discuss this way of using the MuPAD engine. On the other hand, with the help of the MuPAD programming language, you can easily add functionality to the system by implementing your own algorithms as MuPAD procedures. This is useful for special purpose applications if no appropriate system functions exist. Chapters 15 through 17 are an introduction to MuPAD programming. You can read this book in the standard way “linearly” from the first to the last page. However, there are reasons to proceed otherwise. This may be the case, e.g., if you are interested in a particular problem, or if you already know something about MuPAD. For beginners, we recommend to start reading Chapter 2, which gives a first survey of MuPAD. The description of the online help system in Section 2.2 is probably the most important part of this chapter. The help system provides information about details of system functions, their syntax, their calling parameters, etc. It is available online whenever the MuPAD notebook interface is running. In the beginning, requesting a help page is probably your most frequent query to the system. After you have grown familiar with the help system, you may start to experiment with MuPAD. Chapter 2 demonstrates some of the most important system functions “at work.” You will find further details about these functions in later parts of the book or in the help pages. For a deeper Preface understanding of the data structures involved, you may consult the corresponding sections in Chapter 4. Chapter 3 discusses the MuPAD libraries and their use. They contain many functions and algorithms for particular mathematical topics. The basic data types and the most important system functions for their manipulation are introduced in Chapter 4. It is not necessary to study all of them in the same depth. Depending on your intended application, you may selectively read only the passages about the relevant topics. Chapter 5 explains how MuPAD evaluates objects; we strongly recommend to read this chapter. Chapters 6 through 11 discuss the use of some particularly important system functions: substitution, differentiation, symbolic integration, equation solving, random number generation, and graphic commands. Several useful features such as the history mechanism, input and output routines, or the definition of user preferences are described in Chapters 13.2 through 13. Preferences can be used to configure the system’s interactive behavior after the user’s fancy to a certain extent. Chapters 15 through 17 give an introduction to the basic concepts of the MuPAD programming language. MuPAD provides algorithms that can handle a large class of mathematical objects and computational tasks related to them. Upon reading this introduction, it is possible that you encounter unknown mathematical notions such as rings or fields. This introduction is not intended to explain the mathematical background for such objects. Basic mathematical knowledge is helpful but not mandatory to understand the text. Sometimes you may ask what algorithm MuPAD uses to solve a particular problem. The internal mode of operation of the MuPAD procedures is not addressed here: we do not intend to give a general introduction to computer algebra and its algorithms. The interested reader may consult text books such as, e.g., [GCL 92] or [GG 99]. This book gives an elementary introduction to MuPAD. Somewhat more abstract mathematical objects such as, e.g., field extensions, are easy to describe and to handle in MuPAD. However, such advanced aspects of the system are not discussed here. The mathematical applications that are mentioned in the text are ii Preface intentionally kept on a rather elementary level. This is to keep this text plain for readers with little mathematical background and to make it applicable at school level. We cannot explain the complete functionality of MuPAD in this introduction. Some parts of the system are mentioned only briefly. It is beyond the scope of this tutorial to go into the details of the full power of the MuPAD programming language. You find these in the MuPAD help system, available online during a MuPAD session. This tutorial refers to MuPAD version 5 and later. Since the development of the system advances continuously, some of the details described may change in the future. Future versions will definitely provide additional functionality through new system functions and application packages. In this tutorial, we mainly present the basic tools and their use, which will probably remain essentially unchanged. We try to word all statements in the text in such a way that they stay basically valid for future MuPAD versions. iii Contents Preface i Introduction 1 Numerical Computations .......................... 1-2 Computer Algebra .............................. 1-3 Characteristics of Computer Algebra Systems ............... 1-5 MuPAD® Software .............................. 1-6 First Steps in MuPAD® 2 Notebook interface .............................. 2-2 Explanations and Help ........................... 2-4 Computing with Numbers .......................... 2-5 Exact Computations ......................... 2-6 Numerical Approximations ..................... 2-7 Complex Numbers .......................... 2-9 Symbolic Computation ........................... 2-11 Introductory Examples ........................ 2-11 Curve Sketching ............................ 2-21 Elementary Number Theory ..................... 2-24 Contents The MuPAD® Libraries 3 Information About a Particular Library .................. 3-2 Exporting Libraries ............................. 3-4 The Standard Library ............................ 3-6 MuPAD® Objects 4 Operands: the Functions op and nops ................... 4-3 Numbers ................................... 4-6 Identifiers ................................... 4-8 Symbolic Expressions ............................ 4-12 Operators ............................... 4-12 Expression Trees ........................... 4-19 Operands ............................... 4-21 Sequences ................................... 4-24 Lists ...................................... 4-28