Symbolic Math Toolbox - MATLAB

Download Symbolic Math Toolbox - MATLAB

Post on 28-Oct-2015

86 views

Category:

Documents

7 download

TRANSCRIPT

  • Symbolic Math Toolbox 5Users Guide

  • How to Contact MathWorks

    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

    508-647-7000 (Phone)

    508-647-7001 (Fax)

    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 19932010 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.

    Trademarks

    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

    MathWorks products are protected by one or more U.S. patents. Please seewww.mathworks.com/patents for more information.

  • 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)November 2008 Online only Revised for Version 4.9 (Release 2007b+)March 2009 Online only Revised for Version 5.2 (Release 2009a)September 2009 Online only Revised for Version 5.3 (Release 2009b)March 2010 Online only Revised for Version 5.4 (Release 2010a)September 2010 Online only Revised for Version 5.5 (Release 2010b)

  • Contents

    Introduction1

    Product Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

    Accessing Symbolic Math Toolbox Functionality . . . . . 1-3Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3Working from MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3Working from MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

    Getting Started

    2Symbolic Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2Symbolic Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2Symbolic Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3

    Creating Symbolic Variables and Expressions . . . . . . . . 2-6Creating Symbolic Variables . . . . . . . . . . . . . . . . . . . . . . . . 2-6Creating Symbolic Expressions . . . . . . . . . . . . . . . . . . . . . . 2-7Creating Symbolic Objects with Identical Names . . . . . . . . 2-8Creating a Matrix of Symbolic Variables . . . . . . . . . . . . . . . 2-9Creating a Matrix of Symbolic Numbers . . . . . . . . . . . . . . . 2-10Finding Symbolic Variables in Expressions andMatrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11

    Performing Symbolic Computations . . . . . . . . . . . . . . . . . 2-13Simplifying Symbolic Expressions . . . . . . . . . . . . . . . . . . . . 2-13Substituting in Symbolic Expressions . . . . . . . . . . . . . . . . . 2-15Estimating the Precision of Numeric to SymbolicConversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18

    Differentiating Symbolic Expressions . . . . . . . . . . . . . . . . . 2-20Integrating Symbolic Expressions . . . . . . . . . . . . . . . . . . . . 2-22

    v

  • Solving Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24Finding a Default Symbolic Variable . . . . . . . . . . . . . . . . . . 2-26Creating Plots of Symbolic Functions . . . . . . . . . . . . . . . . . 2-26

    Assumptions for Symbolic Objects . . . . . . . . . . . . . . . . . . 2-31Default Assumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31Setting Assumptions for Symbolic Variables . . . . . . . . . . . 2-31Deleting Symbolic Objects and Their Assumptions . . . . . . 2-32

    Using Symbolic Math Toolbox Software

    3Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12Symbolic Summation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19Taylor Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20Calculus Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22Extended Calculus Example . . . . . . . . . . . . . . . . . . . . . . . . . 3-30

    Simplifications and Substitutions . . . . . . . . . . . . . . . . . . . 3-42Simplifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42Substitutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-53

    Variable-Precision Arithmetic . . . . . . . . . . . . . . . . . . . . . . 3-60Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-60Example: Using the Different Kinds of Arithmetic . . . . . . 3-61Another Example Using Different Kinds of Arithmetic . . . 3-64

    Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-66Basic Algebraic Operations . . . . . . . . . . . . . . . . . . . . . . . . . 3-66Linear Algebraic Operations . . . . . . . . . . . . . . . . . . . . . . . . 3-67Eigenvalues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72Jordan Canonical Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-77Singular Value Decomposition . . . . . . . . . . . . . . . . . . . . . . . 3-79Eigenvalue Trajectories . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-82

    vi Contents

  • Solving Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-93Solving Algebraic Equations . . . . . . . . . . . . . . . . . . . . . . . . . 3-93Several Algebraic Equations . . . . . . . . . . . . . . . . . . . . . . . . 3-94Single Differential Equation . . . . . . . . . . . . . . . . . . . . . . . . . 3-97Several Differential Equations . . . . . . . . . . . . . . . . . . . . . . . 3-100

    Integral Transforms and Z-Transforms . . . . . . . . . . . . . . 3-103The Fourier and Inverse Fourier Transforms . . . . . . . . . . . 3-103The Laplace and Inverse Laplace Transforms . . . . . . . . . . 3-110The Z and Inverse Ztransforms . . . . . . . . . . . . . . . . . . . . 3-116

    Special Functions of Applied Mathematics . . . . . . . . . . . 3-120Numerical Evaluation of Special Functions Using mfun . . 3-120Syntax and Definitions of mfun Special Functions . . . . . . . 3-121Diffraction Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-126

    Using Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-129Creating Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-129Exploring Function Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-140Editing Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142Saving Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143

    Generating Code from Symbolic Expressions . . . . . . . . . 3-145Generating C or Fortran Code . . . . . . . . . . . . . . . . . . . . . . . 3-145Generating MATLAB Functions . . . . . . . . . . . . . . . . . . . . . 3-146Generating Embedded MATLAB Function Blocks . . . . . . . 3-151Generating Simscape Equations . . . . . . . . . . . . . . . . . . . . . 3-155

    MuPAD in Symbolic Math Toolbox

    4Understanding MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2Introduction to MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2The MATLAB Workspace and MuPAD Engines . . . . . . . . . 4-2Introductory Example Using a MuPAD Notebook fromMATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3

    MuPAD for MATLAB Users . . . . . . . . . . . . . . . . . . . . . . . . . 4-10

    vii

  • Getting Help for MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10Launching, Opening, and Saving MuPAD Notebooks . . . . 4-12Opening Recent Files and Other MuPAD Interfaces . . . . . 4-13Calculating in a MuPAD Notebook . . . . . . . . . . . . . . . . . . . 4-15Differences Between MATLAB and MuPAD Syntax . . . . . 4-21

    Integration of MuPAD and MATLAB . . . . . . . . . . . . . . . . 4-25Copying Variables and Expressions Between the MATLABWorkspace and MuPAD Notebooks . . . . . . . . . . . . . . . . . 4-25

    Calling MuPAD Functions at the MATLAB CommandLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28

    Clearing Assumptions and Resetting the SymbolicEngine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33

    Function Reference5

    Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

    Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

    Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3

    Solution of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4

    Variable Precision Arithmetic . . . . . . . . . . . . . . . . . . . . . . 5-4

    Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4

    Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5

    MuPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5

    Pedagogical and Graphical Applications . . . . . . . . . . . . . 5-6

    Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7

    viii Contents

  • Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8

    Integral and Z-Transforms . . . . . . . . . . . . . . . . . . . . . . . . . 5-9

    Functions Alphabetical List

    6

    Index

    ix

  • x Contents

  • 1Introduction

    Product Overview on page 1-2 Accessing Symbolic Math Toolbox Functionality on page 1-3

  • 1 Introduction

    Product OverviewSymbolic Math Toolbox software lets you to perform symbolic computationswithin the MATLAB numeric environment. It provides tools for solving andmanipulating symbolic math expressions and performing variable-precisionarithmetic. The toolbox contains hundreds of symbolic functions that leveragethe MuPAD engine for a broad range of mathematical tasks such as:

    Differentiation Integration Linear algebraic operations Simplification Transforms Variable-precision arithmetic Equation solving

    Symbolic Math Toolbox software also includes the MuPAD language, whichis optimized for handling and operating on symbolic math expressions. Inaddition to covering common mathematical tasks, the libraries of MuPADfunctions cover specialized areas such as number theory and combinatorics.You can extend the built-in functionality by writing custom symbolic functionsand libraries in the MuPAD language.

    1-2

  • Accessing Symbolic Math Toolbox Functionality

    Accessing Symbolic Math Toolbox Functionality

    Key FeaturesSymbolic Math Toolbox software provides a complete set of tools for symboliccomputing that augments the numeric capabilities of MATLAB. The toolboxincludes extensive symbolic functionality that you can access directly fromthe MATLAB command line or from the MuPAD Notebook Interface. You canextend the functionality available in the toolbox by writing custom symbolicfunctions or libraries in the MuPAD language.

    Working from MATLABYou can access the Symbolic Math Toolbox functionality directly from theMATLAB Command Window. This environment lets you call functions usingfamiliar MATLAB syntax.

    The MATLAB Help browser presents the documentation that covers workingfrom the MATLAB Command Window. To access the MATLAB Help browser,you can:

    Select Help > Product Help , and then select Symbolic Math Toolboxin the left pane

    Enter doc at the MATLAB command line

    If you are a new user, begin with Chapter 2, Getting Started

    Working from MuPADAlso you can access the Symbolic Math Toolbox functionality from the MuPADNotebook Interface using the MuPAD language. The MuPAD NotebookInterface includes a symbol palette for accessing common MuPAD functions.All results are displayed in typeset math. You also can convert the resultsinto MathML and TeX. You can embed graphics, animations, and descriptivetext within your notebook.

    An editor, debugger, and other programming utilities provide tools forauthoring custom symbolic functions and libraries in the MuPAD language.The MuPAD language supports multiple programming styles including

    1-3

  • 1 Introduction

    imperative, functional, and object-...

Recommended

View more >