Table Of ContentSymbolic Math
Toolbox
For Use with MATLAB®
Computation
Visualization
Programming
User’s Guide
Version 2
How to Contact The MathWorks:
508-647-7000 Phone
508-647-7001 Fax
TheMathWorks,Inc. Mail
24PrimeParkWay
Natick,MA01760-1500
http://www.mathworks.com Web
ftp.mathworks.com AnonymousFTPserver
comp.soft-sys.matlab Newsgroup
[email protected] Technicalsupport
[email protected] Productenhancementsuggestions
[email protected] Bugreports
[email protected] Documentationerrorreports
[email protected] Subscribinguserregistration
[email protected] Orderstatus,licenserenewals,passcodes
[email protected] Sales,pricing,andgeneralinformation
SymbolicMathToolboxUser’sGuide
(cid:211) COPYRIGHT1993-1998byTheMathWorks,Inc.
Thesoftwaredescribedinthisdocumentisfurnishedunderalicenseagreement. Thesoftwaremaybeused
orcopiedonlyunderthetermsofthelicenseagreement.Nopartofthismanualmaybephotocopiedorrepro-
ducedinanyformwithoutpriorwrittenconsentfromTheMathWorks,Inc.
U.S.GOVERNMENT: IfLicenseeisacquiringtheProgramsonbehalfofanyunitoragencyoftheU.S.
Government,thefollowingshallapply: (a)ForunitsoftheDepartmentofDefense: theGovernmentshall
haveonlytherightsspecifiedinthelicenseunderwhichthecommercialcomputersoftwareorcommercial
softwaredocumentationwasobtained,assetforthinsubparagraph(a)oftheRightsinCommercial
ComputerSoftwareorCommercialSoftwareDocumentationClauseatDFARS227.7202-3,thereforethe
rightssetforthhereinshallapply;and(b)Foranyotherunitoragency: NOTICE:Notwithstandingany
otherleaseorlicenseagreementthatmaypertainto,oraccompanythedeliveryof,thecomputersoftware
andaccompanyingdocumentation,therightsoftheGovernmentregardingitsuse,reproduction,anddisclo-
sureareassetforthinClause52.227-19(c)(2)oftheFAR.
MATLAB,Simulink,Stateflow,HandleGraphics,andReal-TimeWorkshopareregisteredtrademarks,and
TargetLanguageCompilerisatrademarkofTheMathWorks,Inc.
Otherproductorbrandnamesaretrademarksorregisteredtrademarksoftheirrespectiveholders.
PrintingHistory: August1993 Firstprinting
October1994 Secondprinting
May1997 ThirdprintingforSymbolicMathToolbox2.0
September1998 UpdatedforRelease11(onlineonly)
Contents
Tutorial
1
Introduction ......................................... 1-2
GettingHelp ......................................... 1-4
GettingStarted ....................................... 1-5
SymbolicObjects ..................................... 1-5
CreatingSymbolicVariablesandExpressions ............. 1-6
SymbolicandNumericConversions ...................... 1-7
ConstructingRealandComplexVariables .............. 1-9
CreatingAbstractFunctions ........................ 1-10
UsingsymtoAccessMapleFunctions ................. 1-11
Example:CreatingaSymbolicMatrix ................. 1-11
TheDefaultSymbolicVariable ...................... 1-13
CreatingSymbolicMathFunctions ..................... 1-15
UsingSymbolicExpressions ......................... 1-15
CreatinganM-File ................................ 1-16
Calculus ............................................ 1-17
Differentiation ...................................... 1-17
Limits ............................................. 1-21
Integration ......................................... 1-23
IntegrationwithRealConstants ..................... 1-26
RealVariablesviasym ............................. 1-28
SymbolicSummation................................. 1-30
TaylorSeries ....................................... 1-31
ExtendedCalculusExample ........................... 1-33
PlottingSymbolicFunctions ......................... 1-33
i
SimplificationsandSubstitutions ..................... 1-47
Simplifications ...................................... 1-47
collect ........................................... 1-48
expand .......................................... 1-49
horner ........................................... 1-49
factor ............................................ 1-50
simplify .......................................... 1-52
simple ........................................... 1-52
Substitutions ....................................... 1-56
subexpr .......................................... 1-56
subs ............................................. 1-59
Variable-PrecisionArithmetic ......................... 1-64
Overview ........................................... 1-64
Example:UsingtheDifferentKindsofArithmetic ......... 1-65
RationalArithmetic ................................ 1-65
Variable-PrecisionNumbers ......................... 1-66
ConvertingtoFloating-Point ........................ 1-67
AnotherExample .................................... 1-67
LinearAlgebra ....................................... 1-69
BasicAlgebraicOperations ............................ 1-69
LinearAlgebraicOperations ........................... 1-70
Eigenvalues ........................................ 1-74
JordanCanonicalForm ............................... 1-81
SingularValueDecomposition ......................... 1-82
EigenvalueTrajectories ............................... 1-86
SolvingEquations .................................... 1-96
SolvingAlgebraicEquations ........................... 1-96
SeveralAlgebraicEquations .......................... 1-104
SingleDifferentialEquation .......................... 1-107
Example1....................................... 1-108
Example2....................................... 1-108
Example3....................................... 1-109
SeveralDifferentialEquations ........................ 1-109
IntegralTransforms ................................. 1-112
TheFourierandInverseFourierTransforms ............ 1-112
TheLaplaceandInverseLaplaceTransforms ............ 1-120
ii
TheZ–andInverseZ–transforms ...................... 1-126
References ...................................... 1-128
SpecialMathematicalFunctions ...................... 1-130
Diffraction......................................... 1-132
UsingMapleFunctions .............................. 1-136
SimpleExample .................................... 1-136
VectorizedExample ................................. 1-139
Debugging ......................................... 1-141
TraceMode ...................................... 1-141
StatusOutputArgument .......................... 1-141
ExtendedSymbolicMathToolbox .................... 1-143
PackagesofLibraryFunctions ........................ 1-143
ProcedureExample ................................. 1-145
PrecompiledMapleProcedures ........................ 1-148
Reference
2
Compatibility Guide
A
CompatibilitywithEarlierVersions .................... A-2
ObsoleteFunctions .................................... A-3
iii
iv Contents
1
Tutorial
Introduction . . . . . . . . . . . . . . . . . . . . 1-2
GettingHelp . . . . . . . . . . . . . . . . . . . . 1-4
GettingStarted . . . . . . . . . . . . . . . . . . 1-5
Calculus . . . . . . . . . . . . . . . . . . . . . . 1-17
SimplificationsandSubstitutions . . . . . . . . . . 1-47
Variable-PrecisionArithmetic . . . . . . . . . . . 1-64
LinearAlgebra . . . . . . . . . . . . . . . . . . . 1-69
SolvingEquations . . . . . . . . . . . . . . . . . 1-96
IntegralTransforms . . . . . . . . . . . . . . . 1-112
SpecialMathematicalFunctions . . . . . . . . . . 1-130
UsingMapleFunctions . . . . . . . . . . . . . . 1-136
ExtendedSymbolicMathToolbox . . . . . . . . . 1-143
1
Tutorial
Introduction
TheSymbolicMathToolboxesincorporatesymboliccomputationinto
MATLAB®’snumericenvironment.ThesetoolboxessupplementMATLAB’s
numericandgraphicalfacilitieswithseveralothertypesofmathematical
computation:
Facility Covers
Calculus Differentiation,integration,limits,summation,
andTaylorseries
LinearAlgebra Inverses,determinants,eigenvalues,singular
valuedecomposition,andcanonicalformsof
symbolicmatrices
Simplification Methodsofsimplifyingalgebraicexpressions
Solutionof Symbolicandnumericalsolutionstoalgebraicand
Equations differentialequations
Variable-Precision Numericalevaluationofmathematicalexpressions
Arithmetic toanyspecifiedaccuracy
Transforms Fourier,Laplace,z-transform,andcorresponding
inversetransforms
Special Specialfunctionsofclassicalappliedmathematics
Mathematical
Functions
(cid:210)
ThecomputationalengineunderlyingthetoolboxesisthekernelofMaple ,a
systemdevelopedprimarilyattheUniversityofWaterloo,Canada,and,more
recently,attheEidgenössicheTechnischeHochschule,Zürich,Switzerland.
MapleismarketedandsupportedbyWaterlooMaple,Inc.
TheseversionsoftheSymbolicMathToolboxesaredesignedtoworkwith
MATLAB5andMapleVRelease4.
Therearetwotoolboxes.ThebasicSymbolicMathToolboxisacollectionof
morethanone-hundredMATLABfunctionsthatprovideaccesstotheMaple
1-2
Introduction
kernelusingasyntaxandstylethatisanaturalextensionoftheMATLAB
language.ThebasictoolboxalsoallowsyoutoaccessfunctionsinMaple’s
linearalgebrapackage.TheExtendedSymbolicMathToolboxaugmentsthis
functionalitytoincludeaccesstoallnongraphicsMaplepackages,Maple
programmingfeatures,anduser-definedprocedures.Withbothtoolboxes,you
canwriteyourownM-filestoaccessMaplefunctionsandtheMapleworkspace.
ThefollowingsectionsofthisTutorialprovideexplanationandexampleson
howtousethetoolboxes.
Section Covers
“GettingHelp” HowtogetonlinehelpforSymbolicMath
Toolboxfunctions
“GettingStarted” Basicsymbolicmathoperations
“Calculus” Howtodifferentiateandintegratesymbolic
expressions
“Simplificationsand Howtosimplifyandsubstitutevaluesinto
Substitutions” expressions
“Variable-Precision Howtocontroltheprecisionof
Arithmetic” computations
“LinearAlgebra” Examplesusingthetoolboxfunctions
“SolvingEquations” Howtosolvesymbolicequations
“IntegralTransforms” Fourier,Laplace,andz-transforms
“SpecialMathematical HowtoaccessMaple’sspecialmath
Functions” functions
“UsingMapleFunctions” HowtouseMaple’shelp,debugging,and
user-definedprocedurefunctions
“ExtendedSymbolicMath FeaturesoftheExtendedSymbolicMath
Toolbox” Toolbox
Chapter2, “Reference,”providesdetaileddescriptionsofeachofthefunctions
inthetoolboxes.
1-3
1
Tutorial
Getting Help
TherearetwowaystofindinformationonusingSymbolicMathToolbox
functions.One,ofcourse,istoreadthismanual!TheotheristouseMATLAB’s
commandlinehelpsystem.Generally,youcanobtainhelponMATLAB
functionssimplybytyping
help function
wherefunctionisthenameoftheMATLABfunctionforwhichyouneedhelp.
Thisisnotsufficient,however,forsomeSymbolicMathToolboxfunctions.The
reason?TheSymbolicMathToolbox“overloads”manyofMATLAB’snumeric
functions.Thatis,itprovidessymbolic-specificimplementationsofthe
functions,usingthesamefunctionname.Toobtainhelpforthesymbolic
versionofanoverloadedfunction,type
help sym/function
wherefunctionistheoverloadedfunction’sname.Forexample,toobtainhelp
onthesymbolicversionoftheoverloadedfunction,diff,type
help sym/diff
Toobtaininformationonthenumericversion,ontheotherhand,simplytype
help diff
Howcanyoutellwhetherafunctionisoverloaded?Thehelpforthenumeric
versiontellsyouso.Forexample,thehelpforthedifffunctioncontainsthe
section
Overloaded methods
help char/diff.m
help sym/diff.m
Thistellsyouthattherearetwootherdiffcommandsthatoperateon
expressionsofclasscharandclasssym,respectively.Seethenextsectionfor
informationonclasssym.Formoreinformationonoverloadedcommands,see
Chapter14oftheUsingMATLABguide.
YoucanusethemhelpcommandtoobtainhelponMaplecommands.For
example,toobtainhelpontheMaplediffcommand,typemhelp diff.This
returnsthehelppagefortheMapledifffunction.Formoreinformationonthe
1-4