Symbolic Math Toolbox™ 5 User’s Guide - Calvin tmk5/research/symbolic_tb.pdfSymbolic Math Toolbox™ 5 User’s Guide. How to Contact The MathWorks Web ... Generating MATLAB Function Handles and M-Files ...

Download Symbolic Math Toolbox™ 5 User’s Guide - Calvin  tmk5/research/symbolic_tb.pdfSymbolic Math Toolbox™ 5 User’s Guide. How to Contact The MathWorks   Web ... Generating MATLAB Function Handles and M-Files ...

Post on 18-Mar-2018

216 views

Category:

Documents

3 download

Embed Size (px)

TRANSCRIPT

<ul><li><p>Symbolic Math Toolbox 5Users Guide</p></li><li><p>How to Contact The MathWorks</p><p>www.mathworks.com Webcomp.soft-sys.matlab Newsgroupwww.mathworks.com/contact_TS.html Technical Supportsuggest@mathworks.com Product enhancement suggestionsbugs@mathworks.com Bug reportsdoc@mathworks.com Documentation error reportsservice@mathworks.com Order status, license renewals, passcodesinfo@mathworks.com Sales, pricing, and general information</p><p>508-647-7000 (Phone)</p><p>508-647-7001 (Fax)</p><p>The MathWorks, Inc.3 Apple Hill DriveNatick, MA 01760-2098For contact information about worldwide offices, see the MathWorks Web site.Symbolic Math Toolbox Users Guide COPYRIGHT 19932008 by The MathWorks, Inc.The software described in this document is furnished under a license agreement. The software may be usedor copied only under the terms of the license agreement. No part of this manual may be photocopied orreproduced in any form without prior written consent from The MathWorks, Inc.FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentationby, for, or through the federal government of the United States. By accepting delivery of the Programor Documentation, the government hereby agrees that this software or documentation qualifies ascommercial computer software or commercial computer software documentation as such terms are usedor defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms andconditions of this Agreement and only those rights specified in this Agreement, shall pertain to and governthe use, modification, reproduction, release, performance, display, and disclosure of the Program andDocumentation 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 thegovernments needs or is inconsistent in any respect with federal procurement law, the government agreesto return the Program and Documentation, unused, to The MathWorks, Inc.</p><p>Trademarks</p><p>MATLAB and Simulink are registered trademarks of The MathWorks, Inc. Seewww.mathworks.com/trademarks for a list of additional trademarks. Other product or brandnames may be trademarks or registered trademarks of their respective holders.Patents</p><p>The MathWorks products are protected by one or more U.S. patents. Please seewww.mathworks.com/patents for more information.</p><p>http://www.mathworks.com/trademarkshttp://www.mathworks.com/patents</p></li><li><p>Revision HistoryAugust 1993 First printingOctober 1994 Second printingMay 1997 Third printing Revised for Version 2May 2000 Fourth printing Minor changesJune 2001 Fifth printing Minor changesJuly 2002 Online only Revised for Version 2.1.3 (Release 13)October 2002 Online only Revised for Version 3.0.1December 2002 Sixth printingJune 2004 Seventh printing Revised for Version 3.1 (Release 14)October 2004 Online only Revised for Version 3.1.1 (Release 14SP1)March 2005 Online only Revised for Version 3.1.2 (Release 14SP2)September 2005 Online only Revised for Version 3.1.3 (Release 14SP3)March 2006 Online only Revised for Version 3.1.4 (Release 2006a)September 2006 Online only Revised for Version 3.1.5 (Release 2006b)March 2007 Online only Revised for Version 3.2 (Release 2007a)September 2007 Online only Revised for Version 3.2.2 (Release 2007b)March 2008 Online only Revised for Version 3.2.3 (Release 2008a)October 2008 Online only Revised for Version 5.0 (Release 2008a+)October 2008 Online only Revised for Version 5.1 (Release 2008b)</p></li><li><p>Contents</p><p>Getting Started</p><p>1Product Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2</p><p>Symbolic Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4</p><p>Creating Symbolic Variables and Expressions . . . . . . . . 1-6sym and syms Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6findsym Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8</p><p>Substituting for Symbolic Variables . . . . . . . . . . . . . . . . . 1-10subs Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10Default Symbolic Variable . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11</p><p>Symbolic and Numeric Conversions . . . . . . . . . . . . . . . . . 1-12Floating-Point Symbolic Expressions . . . . . . . . . . . . . . . . . 1-12Rational Symbolic Expressions . . . . . . . . . . . . . . . . . . . . . . 1-12Decimal Symbolic Expressions . . . . . . . . . . . . . . . . . . . . . . . 1-13Converting Numeric Matrices to Symbolic Form . . . . . . . . 1-13Constructing Real and Complex Variables . . . . . . . . . . . . . 1-14Creating Abstract Functions . . . . . . . . . . . . . . . . . . . . . . . . 1-15</p><p>Creating Symbolic Math Functions . . . . . . . . . . . . . . . . . . 1-18Using Symbolic Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 1-18Creating an M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18</p><p>Using Symbolic Math Toolbox Software</p><p>2Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8</p><p>v</p></li><li><p>Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11Symbolic Summation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17Taylor Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18Calculus Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20Extended Calculus Example . . . . . . . . . . . . . . . . . . . . . . . . . 2-28</p><p>Simplifications and Substitutions . . . . . . . . . . . . . . . . . . . 2-41Simplifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-50</p><p>Variable-Precision Arithmetic . . . . . . . . . . . . . . . . . . . . . . 2-56Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-56Example: Using the Different Kinds of Arithmetic . . . . . . 2-57Another Example Using Different Kinds of Arithmetic . . . 2-59</p><p>Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-61Basic Algebraic Operations . . . . . . . . . . . . . . . . . . . . . . . . . 2-61Linear Algebraic Operations . . . . . . . . . . . . . . . . . . . . . . . . 2-62Eigenvalues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-67Jordan Canonical Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-72Singular Value Decomposition . . . . . . . . . . . . . . . . . . . . . . . 2-74Eigenvalue Trajectories . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-76</p><p>Solving Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-86Solving Algebraic Equations . . . . . . . . . . . . . . . . . . . . . . . . . 2-86Several Algebraic Equations . . . . . . . . . . . . . . . . . . . . . . . . 2-87Single Differential Equation . . . . . . . . . . . . . . . . . . . . . . . . . 2-90Several Differential Equations . . . . . . . . . . . . . . . . . . . . . . . 2-93</p><p>Integral Transforms and Z-Transforms . . . . . . . . . . . . . . 2-95The Fourier and Inverse Fourier Transforms . . . . . . . . . . . 2-95The Laplace and Inverse Laplace Transforms . . . . . . . . . . 2-102The Z and Inverse Ztransforms . . . . . . . . . . . . . . . . . . . . 2-108</p><p>Special Functions of Applied Mathematics . . . . . . . . . . . 2-113Numerical Evaluation of Special Functions Using mfun . . 2-113Syntax and Definitions of mfun Special Functions . . . . . . . 2-114Diffraction Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-119</p><p>Generating Code from Symbolic Expressions . . . . . . . . . 2-122Generating C or Fortran Code . . . . . . . . . . . . . . . . . . . . . . . 2-122</p><p>vi Contents</p></li><li><p>Generating MATLAB Function Handles and M-Files . . . . 2-123</p><p>MuPAD in Symbolic Math Toolbox</p><p>3Understanding MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2Introduction to MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2The MATLAB Workspace and MuPAD Engines . . . . . . . . . 3-2Introductory Example Using a MuPAD Notebook fromMATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3</p><p>MuPAD for MATLAB Users . . . . . . . . . . . . . . . . . . . . . . . . . 3-10Getting Help for MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10Launching, Opening, and Saving MuPAD Notebooks . . . . 3-12Opening Recent Files and Other MuPAD Interfaces . . . . . 3-13Calculating in a MuPAD Notebook . . . . . . . . . . . . . . . . . . . 3-15Differences Between MATLAB and MuPAD Syntax . . . . . 3-20</p><p>Integration of MuPAD and MATLAB . . . . . . . . . . . . . . . . 3-25Copying Variables and Expressions Between the MATLABWorkspace and MuPAD Notebooks . . . . . . . . . . . . . . . . . 3-25</p><p>Calling MuPAD Functions at the MATLAB CommandLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28</p><p>Clearing Assumptions and Resetting the SymbolicEngine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30</p><p>Using Maple and MuPAD Engines . . . . . . . . . . . . . . . . . . . 3-35Choosing a Maple or MuPAD Engine . . . . . . . . . . . . . . . . . 3-35Differences in Maple and MuPAD Syntax . . . . . . . . . . . . . . 3-36</p><p>Function Reference4</p><p>Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2</p><p>Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2</p><p>vii</p></li><li><p>Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3</p><p>Solution of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3</p><p>Variable Precision Arithmetic . . . . . . . . . . . . . . . . . . . . . . 4-4</p><p>Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4</p><p>Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4</p><p>MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5</p><p>Pedagogical and Graphical Applications . . . . . . . . . . . . . 4-5</p><p>Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6</p><p>Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7</p><p>Integral and Z-Transforms . . . . . . . . . . . . . . . . . . . . . . . . . 4-8</p><p>Functions Alphabetical List</p><p>5</p><p>Index</p><p>viii Contents</p></li><li><p>1</p><p>Getting Started</p><p>This section introduces you to Symbolic Math Toolbox software anddescribes how to create and use symbolic objects. The section covers thefollowing topics:</p><p> Product Overview on page 1-2</p><p> Symbolic Objects on page 1-4</p><p> Creating Symbolic Variables and Expressions on page 1-6</p><p> Substituting for Symbolic Variables on page 1-10</p><p> Symbolic and Numeric Conversions on page 1-12</p><p> Creating Symbolic Math Functions on page 1-18</p></li><li><p>1 Getting Started</p><p>Product OverviewSymbolic Math Toolbox software incorporates symbolic computation intothe numeric environment of MATLAB software. It supplements MATLABnumeric and graphical capabilities with several other types of mathematicalcomputation, summarized in following table.</p><p>Facility Covers</p><p>Calculus Differentiation, integration, limits,summation, and Taylor series</p><p>Linear Algebra Inverses, determinants, eigenvalues,singular value decomposition, andcanonical forms of symbolic matrices</p><p>Simplification Methods of simplifying algebraicexpressions</p><p>Solution of Equations Symbolic and numerical solutions toalgebraic and differential equations</p><p>Special Mathematical Functions Special functions of classical appliedmathematics</p><p>Variable-Precision Arithmetic Numerical evaluation of mathematicalexpressions to any specified accuracy</p><p>Transforms Fourier, Laplace, z-transform, andcorresponding inverse transforms</p><p>The computational engine underlying the toolbox is the kernel of MuPADsoftware.</p><p>There are two ways to interact with the MuPAD symbolic math engine:</p><p> The Symbolic Math Toolbox software is a collection of more than 100MATLAB functions that provide access to the MuPAD kernel using asyntax and style that is a natural extension of the MATLAB language.</p><p> The MuPAD notebook interface is a Graphical User Interface (GUI) forperforming computations in the MuPAD language. For more information</p><p>1-2</p></li><li><p>Product Overview</p><p>about this interface and language see Chapter 3, MuPAD in SymbolicMath Toolbox.</p><p>If you have a version of Maple software consistent with the version ofSymbolic Math Toolbox software that you are using, you can use that insteadof MuPAD software. See Choosing a Maple or MuPAD Engine on page 3-35.</p><p>1-3</p></li><li><p>1 Getting Started</p><p>Symbolic ObjectsSymbolic Math Toolbox software defines a new MATLAB data type called asymbolic object. (See Classes (Data Types) in the MATLAB ProgrammingFundamentals documentation for an introduction to MATLAB classes andobjects.) Symbolic Math Toolbox software uses symbolic objects to representsymbolic variables, expressions, and matrices. The actual computationsinvolving symbolic objects are performed primarily by the MuPAD symbolicmath engine.</p><p>MATLAB Data Types and the Corresponding Symbolic Objects</p><p>The following example illustrates the difference between a standard MATLABdata type, such as double, and the corresponding symbolic object. TheMATLAB command</p><p>sqrt(2)</p><p>returns a floating-point decimal number:</p><p>ans =1.4142</p><p>On the other hand, if you convert 2 to a symbolic object using the symcommand, and then take its square root by entering</p><p>a = sqrt(sym(2))</p><p>the result is</p><p>a =2^(1/2)</p><p>MATLAB gives the result 2^(1/2), which means 21/2, using symbolic notationfor the square root operation, without actually calculating a numerical value.MATLAB records this symbolic expression in the string that represents2^(1/2). You can always obtain the numerical value of a symbolic objectwith the double command:</p><p>double(a)ans =</p><p>1.4142</p><p>1-4</p></li><li><p>Symbolic Objects</p><p>Notice that the result is indented, which tells you it has data type double.Symbolic results are not indented.</p><p>When you create a fraction involving symbolic objects, MATLAB records thenumerator and denominator. For example:</p><p>sym(2)/sym(5)ans =2/5</p><p>MATLAB performs arithmetic on symbolic objects differently than it does onstandard data types. If you add two fractions that are of data type double,MATLAB gives the answer as a decimal fraction. For example:</p><p>2/5 + 1/3ans =0.7333</p><p>If you add the same fractions as symbolic objects, MATLAB finds theircommon denominator and combines them by the usual procedure for addingrational numbers:</p><p>sym(2)/sym(5) + sym(1)/sym(3)ans =11/15</p><p>Symbolic Math Toolbox software enables you to perform a variety of symboliccalculations that arise in mathematics and science. These are described indetail in Chapter 2, Using Symbolic Math Toolbox Software.</p><p>1-5</p></li><li><p>1 Getting Started</p><p>Creating Symb...</p></li></ul>

Recommended

View more >