Home

MuPAD User's Guide

image

Contents

1. leeren 5 165 Private Methods lt 2 9 2 91 Ub LdeY Aes eee RBA AGE 5 167 Calls by Reference and Calls by Value 5 169 Cals Di Value one doeet etatis doo sober e dicet 5 169 Calls by Reference 0 0000 cee eee 5 170 Integrate Custom Functions into MuPAD 5 176 xviii Contents Graphics and Animations Gallery oa cee as f ox aes es EA 2D Function and Curve Plots lessen Other 7D examples edu 2 2b ate Suo EE PSP qp 3D Functions Surfaces and Curves Easy Plotting Graphs of Functions 2D Function Graphs plotfunc2d 3D Function Graphs plotfunc3d Attributes for plotfunc2d and plotfunc3d Advanced Plotting Principles and First Examples General Principles eee Dome Examples sura RO Sedce c Basal ados e e eas Pow The Full Picture Graphical Trees Viewer Browser and Inspector Interactive Manipulation Primitive S outer orae ue oh era OR T o IU qu P ob hA 00 Se HT A AIDATES o ouai Ve dr Debe und e oe ap eh oe dated a Perna Valeo dace dot dnce mand ior edi dois eti xax Inheritance of Attributes ccce Primitives Requesting Special Scene Attributes Hints The Help Pages of Attributes 00 Layout of Canvas and Scenes eesn Layout of the Canvas eee Layout ol SCENES a doe ERREUR ec C e RR CERRO dee ANIMATIONS 2
2. 0000000 5 19 Operate on Dels as uq obere Seta ede du ck he Rcs duce ddr S LA 5 20 Add Replace or Remove Set Elements 5 22 XV Xvi Contents Tables uuu hs beeen eae es A Create Tables Access Table Elements Operate on Tables Replace or Remove Table Entries AEEFAYS 42 3X RE ee bene wes Create Arrays Access Array Entries Operate on Arrays Replace or Remove Array Entries 0004 Arrays with Hardware Floating Point Numbers Vectors and Matrices Create Matrices Create Vectors Combine Vectors into a Matrix 0000008 Matrices Versus Arrays Convert Matrices and Arrays Choose Appropriate Data Structures Convert Data Types Use the coerce Function Use the expr Function Use Constructors Define Your Own Data Types Access Arguments of a Procedure Test Arguments Check Types of Arguments Check Arguments of Individual Procedures Verify Options Debug MuPAD Code Using the Debugger Overview ceres Open the Debugger Debug Step by Step set and Remove Breakpoints 9 290 9 290 9 26 5 27 5 28 5 30 5 30 5 31 5 32 5 34 5 34 5 36 5 36 5 37 5 37 9 38 9 38 9
3. 00000 3 328 Modular Square Roots leen 3 329 General Solver for Congruences 00 3 332 Sequences of Numbers 0 000000 cee eee 3 334 Fibonacci Numbers eene 3 334 Mersenne Primes 0 00 0 eee ee eee 3 334 Continued Fractions 0 00000 eee eee 3 335 Programming Basics 4 Conditional Control 0 0 0000 cee eee 4 2 Use if Statements oes 4 xoa sea Aca d eee be ee EA 4 2 Apply Multiple Conditions 004 4 3 Use Nested Conditional Statements 4 4 Use case and otherwise Statements lees 4 5 Exit a Conditional Statement leen 4 5 Return Value of a Conditional Statement 4 6 Display Intermediate Results leen 4 7 LOOS acento etaed are Ce arcs Se dba ee ete 4 8 Use Loops with a Fixed Number of Iterations for Loops 4 8 Use Loops with Conditions while and repeat Loops 4 10 Use Nested Loops eeeeeee Re 4 13 gras aM oo RETTULIT PT 4 14 Skip Part of Iteration 245 0406 8 o5 ERES SEES RA 4 15 Return Value of a Loop y Sx Vu eae va OPE 4 16 Display Intermediate Results 000 4 17 Proced r s 2e rns ea Pc n dol eg ue ede x do 4 18 Create a Procedlf6 u 5 aoc oi duet dct rh ACER rib AS 4 18 Calla Procedure La uui uuu MEAG acd E Ses beg MC e s 4 18 Xiv Contents Control R turg Values 3 6 oso 235 eee eee ee
4. 3 47 Systems of Ordinary Differential Equations 3 49 Plot Solutions of Differential Equations 3 51 West Results C adio E h ees RE SON d aU ee ats 3 56 Solutions Given in the Form of Equations 3 56 vii Solutions Given as Memberships 3 58 Solutions Obtained with IgnoreAnalyticConstraints 3 59 If Results Look Too Complicated 3 62 Use Options to Narrow Results 0004 3 62 Use Assumptions to Narrow Results les 3 64 Simplify Sol tions 440225 40h40 eee EEEdODRR XE IS TELS 3 65 If Results Differ from Expected 3 67 Verify Equivalence of Expected and Obtained Solutions 3 67 Verify Equivalence of Solutions Containing Arbitrary CONSTA asd OURS aue b impu ud ius 3 68 Completeness of Expected and Obtained Solutions 3 71 Solve Equations Numerically 04 3 73 Get Numeric Results llle 3 73 Solve Polynomial Equations and Systems 3 75 Solve Arbitrary Algebraic Equations and Systems 3 76 Isolate Numeric Roots 000 cece ee ee ee eee 3 82 Solve Differential Equations and Systems 3 82 Use General Simplification Functions 3 89 When to Use General Simplifiers 3 89 Choose simplify or Simplify 0000048 3 90 Use Options to Control Simplification Algorithms 3
5. 2 E a F i J T fs 5 f 5 J i To verify the correctness of the returned solutions substitute the solutions into the original equation To substitute the results given in the form of equations evaluate the original equations at the solution points Use evalAt or the vertical bar as a shortcut For the first solution the command returns the identity equation solution 1 0 0 To check that the left side of the equation 1s equal to the right side use the testeq command testeq equation solution 1 TRUE Test Results For the second solution evalAt returns an equation with an unsimplified left side In many cases MuPAD does not automatically simplify expressions for example equation solution 2 E testeq simplifies the expressions on both sides of the equation testeq equation solution 2 TRUE As an alternative to evaluating at a point use the subs command to substitute the solution into the original equation equation x 3 4 0 solution solve equation testeq subs equation solution 1 testeq subs equation solution 2 testeq subs equation solution 3 f 25 25 1 33 x 25 21 23 TRUE TRUE TRUE To verify the solutions of a system of equations test each equation separately equations x 2 2 y 8 4 x 2 5 y 6 solutions solve equations x y testeq equations solutions 1 1 testeq equations solutions 1 2
6. Enabling and Disabling Toolbars and Panes on page 2 8 Move Toolbars and Panes on page 2 9 Enabling and Disabling Toolbars and Panes To enable or disable the Command Bar Find and Replace Bar toolbars or Status Bar select View from the main menu The following illustration shows the View menu for a notebook and a Debugger window Notebook Debugger View Wrap To Window Output Refresh F5 v Call Stack Highlight Link Targets v Watch Breakpoints Command Bar Find and Replace Bar v Toolbar Toolbars F Standard v Status Bar Stat nd V Format P Configure Configure To use context menu right click any bar The following illustration shows the context menu for the Notebook and Debugger windows Arrange Toolbars and Panes Notebook Debugger Object Browser Output Camera Control Watch Find and Replace f Call Stack Command Bar Breakpoints Toolbar Move Toolbars and Panes To move a toolbar grab the toolbar anchor and drag the toolbar to a different location For example line the toolbars one below the other iG W Ed d Aey odom too mip Serre Monospace e Toolbar anchor File Edit View Navigation Insert Format Notebook Window Help Standard toolbar E dg EJ amp AP o F E Qo Ts t 2 8 XY Format toolbar Generic Monospace u B 1j J x3 x3 4 AW To move the Command Bar or Find and Replace Bar grab the pane title and drag the pane to a differ
7. Set and Remove Breakpoints Set Standard Breakpoints Set breakpoints to pause execution of your code so you can examine values where you think the problem is To set a breakpoint inside a procedure 9 69 5 Programming Fundamentals 1 Select a line where you want to set a breakpoint 2 Select Breakpoints gt Toggle Breakpoint from the main menu or right click to use the context menu Also you can click the Toggle Breakpoint button on the toolbar File Edit View step Breakpoints Watches Help e DOO avy Aner ds ico gt zog z am Pagle Breakpoint ga 01 0 ther error solve called without arguments end if egs egr vars var to avoid warnings userinfo 1 solving exprztext eqs for exprzZtext vars else egs egr userinfo l Solving exprztext eg3 end if if type eqs equal then if domtype opi egs 1 DOM LIST and domtype opieqs 2 DOM LIST then eqs ziplopleqs 1 opleqs 2 equal 0 else eqs ap eqs 1 opleqs zi 58 if ega undefined then return procname args 100 end if 101 end if 102 end if 103 4 n Toggle breakpoint at current source line on or off Mem 3 MB TO s Set Conditional Breakpoints To set a conditional breakpoint 5 70 Debug MuPAD Code Using the Debugger 1 Select a line where you want to set a breakpoint 2 Select Breakpoints gt Set Breakpoint from the main menu cme Fri A Gan Nekiacder Hah coler LI IWIL
8. eH 3 arctan v2 d F Differentiation Derivatives of Single Variable Expressions To compute the derivative of a mathematical expression use the diff command For example f i 4 x 6 xX 2 4 x 83 x 4 diff f X 4x 1242 Partial Derivatives You also can compute a partial derivative of a multivariable expression 1 23 l Getting Started 1 24 f i y 2 4 x 6 x 2 4 x 3 x 4 diff f y 2 y Second and Higher Order Derivatives To find higher order derivatives use a nested call of the diff command diff diff diff sin x x x x cos x or more efficiently diff sin x X x x cos x You can use the sequence operator to compute second or higher order derivatives diff sin x x 3 cos x Mixed Derivatives diff f x1 x2 is equivalent to diff diff diff f x1 x2 The system first differentiates f with respect to X1 and then differentiates the result with respect to X2 and so on For example diff diff x 2 y 2 4 x 2 y 6 x y 2 y X S8x lly 4xy 1s equivalent to diff X 2 y 2 4 x 2 y 6 x y 2 y x Sx 12y 4xy Perform Computations Note To improve performance MuPAD assumes that all mixed derivatives commute For example 2 2 f x y 2 2 f x y dy ax x Gy 077 This assumption suffices for most of engineering and scientific problems For further computations delete f delete f Derivatives of a F
9. 0 1353780559 0 8366380364 1 0 1353780559 0 8366380364 1 3 75 3 Mathematics To limit the solution set to the real solutions only use the option AllRealRoots numeric solve 4 x 4 3 x 3 2 x 2 x 1 0 x AllRealRoots T 0 8763850965 0 3971412051 Using numeric solve you also can solve a system of polynomial equations numeric solve x 3 2 x y y 2 x x yl I x 0 2812406534 1 234872424 i y 0 7018735689 0 8796971979 i x 02365742943 y 0 48638903591 x 0 1629535062 1 615154465 i y 0 9450680868 0 8545175144 i x 0 1629535062 1 615154465 i y 0 9450680868 0 8545175144 i x 2 0 y 0 x 0 2812406534 1 234872424 i y 0 7018735689 0 8796971979 i To solve linear systems numerically use the numeric linsolve command For example solve the following system symbolically and numerically X yl linsolve x y 1 x y 5 2 x y 5 2 Ix yl numeric linsolve x y 1 Ted wf ae tear Solve Arbitrary Algebraic Equations and Systems For nonpolynomial equations there is no general method of finding all the solutions numerically When you solve a nonpolynomial equation or a system numerically and the solutions exist the solver returns only one solution numeric solve sin 1 x x x 1 0 00884125012 Solve Equations Numerically This equation obviously has more than one solution plot sin 1 x
10. 9 131 5 Programming Fundamentals 9 132 By default prog test tests the strict equality between actual and expected results Testing equality of floating point values can be confusing when the display precision differs from the internal precision In this case different floating point numbers can look identical Thus with the default values of DIGITS and Pref outputDigits the floating point approximation of 1 3 and the number 0 3333333333 look identical prog test float 1 3 0 3333333333 Error in test 5 Input float 1 3 Expected 0 3333333333 Got 0 3333333333 Near line 1 Internally MuPAD uses more than 10 digits to approximate 1 3 with the floating point number The system adds guard digits for increased precision To see how many guard digits the system uses increase the number of output digits using the Pref outputDigits function Then test the equality of the numbers again Pref outputDigits 20 prog test float 1 3 0 3333333333 Error in test 6 Input float 1 3 Expected 0 3333333333 Got 0 33333333333333333304 Near line 2 When you test equality of floating point numbers it can be helpful to test the approximate equality The approximate equality operator in MuPAD is The corresponding function is approx The prog test function lets you choose the method for comparing actual and expected results For example 1 3 1s approximately equal to 0 3333333333 within the default 10 digits p
11. Compute Rank of a Matrix eee Compute Bases for Null Spaces of Matrices Find Eigenvalues and Eigenvectors Find Jordan Canonical Form of a Matrix Compute Matrix Exponentials Compute Cholesky Factorization Compute LU Factorization een Compute QR Factorization eese Compute Determinant Numerically Compute Eigenvalues and Eigenvectors Numerically Compute Factorizations Numerically Cholesky Decomposition 0 0 0000000 eee LU Decomposition QR Decomposition Singular Value Decomposition 00000 ee Mathematical Constants Available in MuPAD Special Real Numbers eee Infimties Boolean Constants 3 188 3 189 3 190 3 191 3 193 3 194 3 195 3 196 3 197 3 200 3 202 3 203 3 206 3 208 3 210 3 214 3 219 3 219 3 220 3 222 3 224 3 227 3 227 3 228 3 228 Xi Xii Contents Special ValS ernas e Geese ee ete eee ate PPCClAl Sess d uua Wea a Sie ee as BAG RO She Special Functions Available in MuPAD Dirac and Heaviside Functions Gamma Functions 00 00 cee eee ees Zeta Function and Polylogarithms Airy and Bessel Functions 004 Exponential and Trigonometric Integrals Error Functio
12. op ex 2 11 op ex 2 1 2 1 Modify Subexpressions a Now you can use Subsop to replace the parameter a with some value For example replace it with the value 3 subsop ex 2 1 2 1 3 sinb 3 x cos 5 ax prog find helps you find all occurrences of a specific value in the expression For example find all sums in this expression ex x 1 x 2 2 x 2 1 x 1 x 1 pos prog find ex hold plus map pos p gt op ex p map pos p gt op ex p 1 21 OL 1 1 OL 2 1 OL 2 2 1 OT m plus plus plus plus Lg TT l vei esis aix 3 x l x 2x 2 Recursive Substitution You also can find all subexpressions of a particular type for example all Bessel functions or all branches not containing X execute some code for these subexressions and replace them with the return value of that code For this task use the misc maprec function Suppose you want to rewrite all terms that contain the sine and tangent functions in terms of cosine functions In this example do not use sin x 1 cos x and similar identities First create the functions sin2cos and tan2cos that rewrite expressions in terms of the cosine function These functions access the operands of the sine and tangent functions using Oop ex sin2cos ex gt cos op ex PI 2 9 155 5 Programming Fundamentals 9 156 tan2cos ex gt cos op ex PI 2 cos op ex
13. plot Reflect2d x1 y1 x2 y2 Primitivel reflects all 2D primitives about the line through the points X1 y1 and x2 y2 plot Reflect3d x y z nx ny nz Primitivel reflects all 3D primitives about the plane through the point X y z with the normal nx ny nz plot Rotate2d angle c1 c2 Primitivel rotates all points of 2D primitives counter clockwise by the given angle about the pivot point C1 c2 plot Rotate3d angle c c2 c3 d1 d2 d3 Primitivel rotates all points of 3D primitives by the given angle around the rotation axis specified by the pivot point C1 c2 c3 and the direction d1 d2 d3 plot Scale2d s1 s2 Primitive applies the diagonal scaling matrix diag s1 s2 to all points of 2D primitives plot Scale3d s1 s2 s3 Primitivel applies the diagonal scaling matrix diag s1 s2 3 to all points of 3D primitives plot Transform2d b1 b2 A Primitivel applies the general affine linear transformation x A x with a 2X2 matrix A and a vector b b1 b2 to all points of 2D primitives plot Transform3d b1 b2 b3 A Primitivel applies the general affine linear transformation x A x b with a 3x3 matrix A and a vector b b1 b2 b3 to all points of 3D primitives 6 159 6 Graphics and Animations The ellipses plot Ellipse2d provided by the plot library have axes parallel to the coordinate axes We use a
14. 1 408318927 0 1223270659 0 002687340356 When computing eigenvalues and eigenvectors numerically you can use the HardwareFloats and SoftwareFloats options to employ hardware or software 3 217 3 Mathematics float arithmetic respectively For information about these options see the Numeric Determinant section For more details see the numeric eigenvectors and numeric eigenvalues help pages 3 218 Compute Factorizations Numerically Compute Factorizations Numerically Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Cholesky Decomposition on page 3 219 LU Decomposition on page 3 220 QR Decomposition on page 3 222 Singular Value Decomposition on page 3 224 For numeric factorization functions you can use the HardwareFloats SoftwareFloats and Symbolic options For information about these options see the Numeric Determinant section For more details see the help pages of the numeric functions provided for each particular factorization function Cholesky Decomposition The Cholesky decomposition of a Hermitian self adjoint positive definite matrix 1s a product of a lower triangular matrix L and its Hermitian transpose LP A L L The Hermitian transpose of a matrix is the complex conjugate of its transpose For real symmetric positive definite matrices A L L where L is the transpose of L You can perform the Cholesky factoriza
15. 3 Use hold to suppress evaluation of the variable z Now the procedure returns an object of type DOM VAR f re proc x y Variables Inside Procedures local Z begin Z i X y return hold z end Til 2 DOM _VAR 0 2 Objects of type DOM VAR represent local variables and can only be used inside procedures An object of type DOM VAR returned as a result of a procedure call 1s useless because it does not have any connection to the procedure You can access local variables of a procedure if you either declare them in that procedure or declare them in a lexically enclosing procedure For example in the following code the procedure g can access and modify the variable x of the enclosing procedure f T 5 proc x local g begin g proc begin X i Sal end Q end f 2 Instead of returning the result of the procedure call g you can return g itself In this case the returned value retains a link to the variable x of the procedure call For reasons of memory management f must declare that it will return something holding a reference to a local variable To declare it use option escape f i proc x local dj option escape begin g proc 9 159 5 Programming Fundamentals 5 160 begin X 35 X13 end 9 end h f 2 i f 17 h h 16 AC 4 18 Lh This programming construct 1s called a closure It is supported in many programming languages Static Variables Alternative
16. 3 Mathematics 3 98 By default factor searches for polynomial factors with rational numbers The function does not factor the expression into a product containing 4 2 factor x 2 2 To add the constant 4 2 to the numbers used in factoring use the option Adj oin factor x 2 2 Adjoin sqrt 2 RM ni x 2 x 2 F j a Compute Normal Forms of Expressions The normal function represents the original rational expression as a single rational term with expanded numerator and denominator The greatest common divisor of the numerator and denominator of the returned expression is 1 f X 3 3 y 2 x 2 y 2 3 f normal f 3 2 3 x 423r 1 C3 3 2 2 X X F m 3 2 7 x 3 normal cancels common factors that appear in numerator and denominator f i 4 2 X V y 2 x y f normal f The normal function also handles expressions other than polynomials and rational functions Internally MuPAD converts such expressions into polynomials or rational functions by substituting subexpressions with identifiers After normalizing the expression with temporary identifiers MuPAD restores the original subexpressions T r exp 2 x exp 2 y exp 3 x exp 3 y Choose Simplification Functions f normal f Compute Partial Fraction Decompositions of Expressions The partfrac function returns a rational expression in the form of a sum of a polynomial and rationa
17. Abbreviations 2 48 2 48 2 51 2 53 2 54 2 56 2 57 2 58 2 59 2 61 2 61 2 64 2 65 2 66 2 71 2 71 2 73 2 74 2 75 2 75 2 77 2 77 2 77 2 79 2 79 2 81 2 82 2 82 2 84 2 84 2 84 2 86 2 87 2 87 vi Contents Typeset Math MOOUB oscar ca 4 ob AOI b a a X RR Pretty Print Mode Mathematical Notations Used in Typeset Mode Set Line Length in Plain Text Outputs Delete Outputs eeeee RR RR RI Greek Letters in Text Special Characters in Regions in MuPAD OQUEDUUS oque EGO Se Sos es Non Greek Characters in Text Regions Use Keyboard Shortcuts 000000 Use Mnemonics Wrap Long Lines Wrap Text Wrap Expressions in Input Regions Wrap Output Expressions 0 0000 ee eee Hide Code Lines Change Font Size Quickly Scale Graphics Use Print Preview ce eee eee eens View Documents Before Printing Print Documents from Print Preview Save Documents to PDE F rmat 2 wvwi Ru oe ees Get More Out of Print Preview een Change Page Settings Print Wide Notebooks lor Printing ax area 2 88 2 90 2 92 2 94 2 95 2 96 2 97 2 98 2 99 2 101 2 102 2 102 2 104 2 106 2 110 2 113 2 116 2 118 2 118 2 118 2 11
18. Compute Generalized Series When computing series expansions MuPAD returns only those results that are valid for all complex values of the expansion variable in some neighborhood of the expansion point If you need the expansion to be valid only for real numbers use the option Real For example when you compute the series expansion of the following expression for complex numbers series returns series sign x 2 sin x x 0 sign x sin x O x When you compute the series expansion for real numbers series returns a simplified result series sign x 2 sin x x 0 Real sign x Ol x Along the real axis compute series expansions for this expression when X approaches the value 0 from the left and from the right sides series sign x 2 sin x x 0 Left series sign x 2 sin x x 0 Right O x 1 O x 3 165 3 Mathematics Compute Bidirectional Limits 3 166 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Suppose you have a function f x The value C is a limit of the function f X at x xg C hm f x x Xp MuPAD provides the 1imit command for computing limits When computing a limit for a variable approaching 0 you can omit specifying xo By default the Limit command assumes x Q limit sin x x x 0 limit 1 cos x x x l Note Avoid computing limits for floating point arguments If you use floating point numb
19. Inside the coordinate systems an arbitrary number of primitives of the appropriate dimension can be displayed Thus we always have a canvas containing one or more scenes with each scene containing one or more coordinate systems The graphical primitives or groups of such primitives are contained in the coordinate systems Hence any MuPAD plot has the following general structure Canvas 6 95 6 Graphics and Animations 6 96 CoordinateSystem Primitive Scene 1 CoordinateSystem 1 Primitive 1 Primitive 2 CoordinateSystem 2 Primitive TT Scene 2 This is the graphical tree that is displayed by the object browser of the MuPAD graphics tool see section Viewer Browser and Inspector Interactive Manipulation Shortcuts For simple plots containing primitives inside one coordinate system only that resides in a single scene of the canvas it would be rather cumbersome to generate the picture by a command such as plot plot Canvas plot Scene2d plot CoordinateSystem2d Primitivel Primitive2 In fact the command plot Primitivel Primitive2 suffices It 1s a shortcut of the above command It generates automatically a coordinate system that contains the primitives embedded it in a scene which is automatically placed inside a canvas object Thus this command implicitly creat
20. T 1 E 2 fa 7 The system compares the type of the formal parameter k and the type of an argument passed to the procedure If the first argument that you pass to the procedure f is not an integer MuPAD issues an error f 2 3 Error The object 2 3 is incorrect The type of argument number 1 must be DOM_INT 5 59 5 Programming Fundamentals 9 56 Evaluating f During a typical procedure call for example a call to the solve or int function MuPAD internally calls many other procedures Testing argument types for each internal procedure call is computationally expensive To provide better performance MuPAD reduces the amount of type checks in the running code By default the system checks the types of arguments only in those procedures that you call interactively If one procedure internally calls another procedure MuPAD does not check types of the arguments of the internally called procedure For example create the following procedure g as a wrapper for the procedure f g proc n Type Numeric begin f n end proc MuPAD performs type checks only for the arguments of the procedure g which you call interactively It does not perform type checks for the arguments of the procedure f g 2 3 I2 m The Pref typeCheck function enables you to control type checking of procedure arguments This function affects all procedures It does not allow you to control type checking for individual procedures The
21. These settings take effect only when a new engine is started Running engines are not affected Package Path User Init Path iata Roaming MathWorks MATL AB symbolic i Library Path a de i Arguments 3 Usethe right pane to change the following settings Engine Path to the MuPAD engine that you want to use Leaving this field empty indicates that you want to use the default engine 2 83 2 Notebook Interface 2 84 Library Path Path to the standard set of the MuPAD libraries that you want to use Leaving this field empty indicates that you want to use the default library Package Path Path to additional libraries packages you that want to use Leaving this field empty indicates that you want to use the default packages User Init Path Path to the folder containing initialization file userinit mu This file contains startup commands for MuPAD notebooks You can add your own commands to the initialization file Arguments Options you want to use when starting MuPAD engine See the list of Options Available When Starting Engine Restore Default Global Settings To restore the default global settings Select View Configure 2 Inthe left pane of the Configure MuPAD dialog box click Engine 3 Inthe right pane click Reset To Defaults button Clicking this button clears all fields except for User Init Path Add Hidden Startup Commands to All N
22. assign This error message does not mention incr because the error occurs in the assignment which is performed in a different evaluation context The incr procedure behaves essentially ike a dynamic macro 9 175 5 Programming Fundamentals Integrate Custom Functions into MuPAD 5 176 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD provides a variety of tools for handling built in mathematical functions such as Sin COS exp and so on These tools implement the mathematical properties of these functions Typical examples are the float conversion routine the diff differentiation function or the expand function which you use to manipulate expressions float sin 1 1 diff sin x X X X x expand sin 134 0 8414709848 cos x cos 1 sin x sin 1 cos x You can say that the mathematical knowledge about the built in functions is distributed over several system functions f loat knows how to compute numerical approximations of the sine function diff knows the derivative of the sine function and expand knows the addition theorems of the trigonometric functions When you implement your own function you can integrate it into the MuPAD system making other functions aware how to work with this new function correctly If the new function consists only of built in MuPAD functions then you do not need to take extra steps All MuPAD functions interact corre
23. expand sin 3 x 1 cos 2 x 1 sin 3 x o urs e E Fm FO Z 2 cos x 2 sm 3 x 2 sm 3 x cos x 2 Choose Simplification Functions To prevent the expansion of all trigonometric subexpressions in this example use the option ArithmeticOnly expand sin 3 x 1 cos 2 x 1 ArithmeticOnly cos 2 x sin 3 x cos x sin 3 x 1 Factor Expressions To present an expression as a product of sums try the factor function The factored form of the following polynomial 1s visibly shorter than the original one The factored form also shows that this polynomial has only one root X 5 Tactor x 10 50 x 9 1125 X B8 159000 X 7 131250 x 5 787500 x 5 3281250 x 4 9375000 x 3 17578125 x 2 19531250 x 9765625 x 5 For sums of rational expressions factor first computes a common denominator and then factors both the numerator and denominator f ie X O 3 y 2 x2 y 2 3 f factor f 3 1 a 2 y _ By x 34 232 x x3 y n x y x y e The function also can factor expressions other than polynomials and rational functions Internally MuPAD converts such expressions into polynomials or rational function by substituting subexpressions with identifiers After factoring the expression with temporary identifiers MuPAD restores the original subexpressions factor ln x 2 1 cos x 2 sin x 2 I x 1 n x 1 cos x sin x cos x sin x 3 97
24. testeq equations solutions 2 1 9 9 4 3 Mathematics 3 98 testeq equations solutions 2 2 ix iyry 2L x iy 2 TRUE TRUE TRUE TRUE Solutions Given as Memberships Suppose you want to verify the solutions of this trigonometric equation equation sin x x O solution solve equation x ink ke 0 To verify the results evaluate the original equation at the solution points Evaluating at a point requires a solution to be in the form of an equation If you have a solution in the form of membership evalAt returns an error equation op solution Error An equation is expected You cannot use the expression X solution directly because solution is represented by a set This set contains the solution for the variable x the independent variable k and the condition on the variable k op solution m k k Z 10 Test Results Extract the solution for x the variable k and the conditions on the variable k from the set MuPAD returns the variable k and its conditions as lists Use the additional square brackets to extract k and the conditions from the lists op solution 1 op solution 2 1 op solution 3 1 Z X 10j Now evaluate the original equation at the solution points x 1k under the conditions for K testeq equation x op solution 1 assuming op solution 2 1 in op solution 3 1 TRUE Alternatively use the subs command to substitute the solut
25. 1 0 1 036411196 c L0 0 8435174328 a 0 1223270659 0 1 0 0 8139981738 o 1 0 where c 5 421010862 10 4 P 19 ca 8 67361738 10 i c 4 33680869 10 i If you need simple though approximate eigenvalues and eigenvectors of the Hilbert matrix 1n further computations use numeric methods from the beginning To approximate eigenvalues and eigenvectors of a matrix numerically use the numeric eigenvectors function The function returns eigenvalues eigenvectors and residues estimated errors for the numerical eigenvalues 3 216 Compute Eigenvalues and Eigenvectors Numerically eigenvalues eigenvectors residues numeric eigenvectors H 1 408318927 0 1223270659 0 002687340356 0 827044927 0 5474484307 0 1276593297 O 4598039044 0 5282902351 0 7137408858 0 3232984352 0 6490066589 0 6886715317 4 317754261 10715 3213231541 10 15 771731031 10727 Small residue values indicate that roundoff errors do not significantly affect the results To suppress the computation of the residues use the NoResidues option numeric eigenvectors H NoResidues 1 408318927 0 1223270659 0 002687340356 0827044927 0 5474484307 0 1276593297 0 4598639044 0 5282902351 0 7137468858 NIL 0 3232984352 0 6490066589 0 6886715317 If you want to compute only eigenvalues of a matrix use the numeric eigenvalues function numeric eigenvalues H
26. 1 658312395 il x 0 0 y 0 0 1 Approximating symbolic solutions numerically you get the complete set of solutions For example solve the following equation symbolically S solve sin x 2 1 2 x keZ u o keZj oi e keZjoic kezZj L5 where Solve Equations Numerically Suppose you want to get numeric results instead of expressions containing PI The float command returns the infinite solution set float S 0 7236012546 V 12 0 k 1 0 ke z 0 7236012546 V 12 0 k 5 0 ke z U 0 7236012546 4 12 0 k 1 0 ke z U 0 7236012546 V 120k450 kez Solve Equations Numerically To avoid getting symbolic solutions and to proceed with numeric methods use the numeric solve command If an equation is not polynomial the numeric solver returns only one solution numeric solve sin x 2 1 2 x 1 226 94447241 Solve Polynomial Equations and Systems For polynomial equations the numeric solver returns all solutions numeric solve 4 x 4 3 x 3 2 x 2 x 57 0 x 1 0 8801137713 0 7633158339 1 0 5051137713 0 8159896507 1 0 5051137713 0 8159896507 1 0 8801137713 0 7633158339 1 When called with the option AllRealRoots the solver omits all complex roots For example when you symbolically solve the polynomial equation and approximate the solutions you get all solutions numeric solve 4 x 4 3 x 3 2 x 2 x 1 0 x 4 0 8763850947 0 3971412064
27. 2 t y2 t 2 8 yi t ms y1 t ys t sqrt x1 t xs t 2 yi t ys t 2 3 m2 y1 t y2 t sqrt x1 t x2 t 2 y1 t y2 t 2 8 x2 t ms x2 t xs t sqrt x2 t xs t 2 y2 t ys t 2 8 m1 x2 t x1 t sqrt x2 t x1 t 2 y2 t y1 t 2 8 ye D ms y2 t ys t sqrt x2 t xs t 2 y2 t ys t 2 8 m1 y2 t yi t oe X1 t 2 y2 t y1 t 2 3 xs 0 mi1 i x1 0 ms x2 0 0 ys 0 O 7 m2 y1 0 20 y2 0 0 7 ms xs 0 1 01 m2 x1 0 O x2 0 1 01 ms ys 0 0 9 m1 yr 0 9 ms y2 0 0 xs t xs t ys t ys t X1 t x1 t yi t yl t t x2 t y2 t y2 t The positions x t ys IYCt 11 YCt I3 xi 0 y400 IY CC 5 Y t 71 xo t vo Y t 9 Y t 11 are computed on an equidistant time mesh with dt 0 05 The animation 1s built up frame by frame by defining static points with suitable values of VisibleFromTo and static line segments with suitable values of VisibleAfter Setting VisibleFromTo t t 0 99 dt each solution point is visible only for a short time the factor 0 99 makes sure that not two points can be visible simultaneously on each orbit The orbits of the points are realized as line segments from the positions at time t dt to the positions at time t The line segments become visible at time t and stay visible for the rest of the animation VisibleAfter t thus leaving a trail
28. 3 70 If Results Differ from Expected Now if you want to verify that the two forms of the solution are equivalent substitute the constant in Riccati solution with this expression For more information on testing mathematical equivalence of the solutions see Testing Results Completeness of Expected and Obtained Solutions Special Cases The returned results can differ from what you expected due to incompleteness of the expected or the returned solution set Complete sets of solutions account for all the special cases for all symbolic parameters and variables included in an equation Complete solutions can be very large and complicated Often you need only one practical solution from a long or infinite solution set Some solvers are designed to return incomplete but practical solutions For example consider the equation ax b y When solving this equation in the MATLAB Command Window the toolbox ignores special cases gt gt solve a x b y ans b y a MuPAD returns the complete set of solutions accounting for all possible values of the symbolic parameters a b and y solve a x b y x Solving the equation in MuPAD with the IgnoreSpecialCases option you get the same short result as in the MATLAB Command Window solve a x b y x IgnoreSpecialCases 3 71 3 Mathematics 3 72 Infinite Solution Sets Some equations have an infinite number of solutions When solving the same equation in
29. 3450 2345 1234 0123 Use the numeric factorLU function to compute the LU decomposition of the matrix T numerically L U p numeric factorLU T 1 0 0 0 1 0 0 0 3333333333 06666666667 1 0 0 66666066007 0 33333333313 0 1 0 0 0 Instead of returning the permutation matrix P MuPAD returns the list p with numbers corresponding to row exchanges in a matrix T For an nXn matrix the list p represents the following permutation matrix with indices i and j ranging from 1 to n jsp Rcs LT Using this expression restore the permutation matrix P from the list p P matrix 4 4 for i from 1 to 4 do P i p i 1 end for P oreo um More efficiently compute the result of applying the permutation matrix to A without restoring the permutation matrix itself 3 221 3 Mathematics 3 222 PT matrix 4 4 for i from 1 to 4 do PT i 1 4 T p i 1 4 end for PT 3450 01231 L234 2345 Within floating point precision the product of the lower triangular matrix L and the upper triangular matrix U is the original matrix A with the rows interchanged according to the permutation matrix P float PT L U 3 0 0 3 0 4 0 0 10 2 0 3 0 nd nd ami um ouo ba 6A coogo L duo L0 5 0 0 2 0 0 30 0 4 0 Lr hi hats RU 1 0 i0 2 0 The symbolic LU factorization function uses a different pivoting strategy than the numeric LU facto
30. 48 g 2 arctan You can also approximate the exact symbolic solution numerically float f 1110212402 l 0 9134005193 f If solve cannot compute explicit solutions for a system use numeric methods to approximate the solutions For nonlinear systems MuPAD offers the following special solvers Fora system of polynomial equations use numeric polysysroots For an arbitrary system of equations use numeric fsolve System of Polynomial Equations Suppose you want to solve the following system of polynomial equations eqni x 3 x 2 y 1 eqn2 x 2 y 2 1 2 The general symbolic solver produces the result in terms of the RootOf object solve eqni eqn2 x y l a4 2 zle RootOf z 4 Paz 422 z D 1 E To approximate the solutions of the system of polynomial equations numerically use the special solver numeric polysysroots Solve Algebraic Systems numeric polysysroots eqn1 eqn2 x y I x 0 4142135624 0 6435942529 i y 0 2928932188 0 9101797211 i x 0 8604395883 y 0 4902614457 x 3 967987536 y 3904475008 x 0 4142135624 0 6435942529 i y 0 2928932188 0 9101797211 i System of Arbitrary Nonlinear Equations Suppose you want to solve the following system of equations eqn1 eqn2 Sin a cos b a b sin a cos b 3 The general solver cannot find a symbolic solution
31. Access the History Table 0000 Specify Maximum Number of Entries Clear the History Table 9 19 5 77 5 78 5 79 5 81 5 85 5 88 5 90 5 92 5 95 5 96 5 96 5 99 5 100 5 109 5 111 5 111 5 112 5 113 5 115 5 115 5 117 5 118 5 119 5 121 5 123 5 123 5 126 5 127 xvii Why Test Your Code 12 2 424644 bwAe4 Rw 2s Ya ERAS 5 128 Write Single Tests 0 0 0 0 0 00 5 130 Write Test Seripts 4 14 dasererat diced ese estas dt 5 134 Code Verification llle 5 138 Protect Function and Option Names 5 140 Data COMection 2x ERR oreda dsn euE GERA AE EE 5 142 Parallel Colection 2 a2 m 43 E ee ADHERE ed 5 142 Fixed Length Collection eere 5 144 Known Maximum Length Collection 5 145 Unknown Maximum Length Collection 5 146 Visualize Expression Trees eese 5 149 Modify Subexpressions elles 5 152 Find and Replace Subexpressions LL 5 152 Recursive Substitution llle 5 155 Variables Inside Procedures 5 158 IUDICARE ETTNLTTTTILTTIILETITTII TII 5 158 Static Variables clle 5 160 Utility Functions 5 aux m aono voi aet eleg Roe eret 5 163 Utility Functions Inside Procedures 5 163 Utility Functions Outside Procedures 5 164 Utility Functions in Closures
32. Creating Animated 2 D Plots To create an animated plot use an additional changing parameter for the function you want to plot Specify the range for this parameter The following example presents an animated plot of a function with the parameter a that gradually changes value from 2 to 6 plot exp x sin a 2 x x 1 2 a 2 6 Create Animated 3 D Plots To create an animated 3 D plot use an additional changing parameter for the function you want to plot Specify the range for this parameter and the option 3D The following example presents an animated plot of a function with the parameter a that gradually changes value from 0 1 to 2 plot sin a x 2 a y 2 x 2 2 y 2 2 a 0 1 2 43D 1 59 l Getting Started Play Animations MuPAD displays the first frame of an animation as static picture To play the animation click the picture When MuPAD plays an animation the Animation toolbar with the player controls appears play stop last frame speed bp rewind seek and repeating progress bar options 1 60 Use Graphics Count Backwards To play an animation forward and then backward click the Repetition button g and select the option Back and Forth You also can specify the range for a parameter so that the initial value is greater than the final value The following example creates an animated plot of the function using the parameter a that gradually changes value from 2 to 0 1 plot si
33. IgnoreAnalyticConstraints testeq subs equation x solutions 2 IgnoreAnalyticConstraints TRUE FALSE The testeg command did not verify both solutions When trying to prove the equivalence of two expressions testeq runs random tests before applying IgnoreAnalyticConstraints If tests for random values of identifiers show that expressions are not equivalent testeq disregards the IgnoreAnalyticConstraints Test Results option and returns FALSE To suppress running random tests set the number of these tests to zero testeq subs equation x solutions 2 NumberOfRandomTests O IgnoreAnalyticConstraints TRUE Verifying numeric results returned by the solver using IgnoreAnalyticConstraints does not require using the same option Substitute numeric results into the original equations and call testeq to prove equivalence of the expressions on both sides of the equations equation x 11 2 1 solution solve equation IgnoreAnalyticConstraints testeq equation solution 1 3 61 3 Mathematics If Results Look Too Complicated Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Use Options to Narrow Results on page 3 62 Use Assumptions to Narrow Results on page 3 64 Simplify Solutions on page 3 65 Use Options to Narrow Results By default the MuPAD solvers return all possible solutions regardless of their length Also by default the solvers assum
34. Now you can use these functions when replacing all occurrences of sine and tangent functions in an expression To replace subexpressions of the original expression use misc maprec The misc maprec function uses the syntax misc maprec expression selector replacement where expression is the original expression subexpressions of which you want to replace Selector is the selection criterion for example a set of types of subexpressions that you want to replace replacement is the procedure that you want to use to replace subexpressions of the original expression MuPAD applies misc maprec recursively to all subexpressions of the original expression For example in this call misc maprec replaces all occurrences of sin and tan including the sine function in tan sin x misc maprec sin x tan x 2 tan sin x sin sin2cos tan tan2cos i T auf x M cos x x cos cos x gt MESS Do NN dU i j 2X cos x cos cos x z V 7 e So o8 iaa Besides data types or types of expressions such as sin or tan you can use procedures to represent selection criteria in misc maprec In this example the selection criterion of misc maprec is the procedure ex gt bool freeIndets ex that excludes free identifiers and selects all constants of an expression Using the procedure f as a replacement misc maprec replaces all nonrational constants of an expression with new
35. Write Single Tests on page 5 130 Write Test Scripts on page 5 134 Code Verification on page 5 138 Protect Function and Option Names on page 5 140 Data Collection on page 5 142 Visualize Expression Trees on page 5 149 Modify Subexpressions on page 5 152 Variables Inside Procedures on page 5 158 Utility Functions on page 5 163 Private Methods on page 5 167 Calls by Reference and Calls by Value on page 5 169 Integrate Custom Functions into MuPAD on page 5 176 Data Type Definition Data Type Definition Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Domain Types on page 5 3 Expression Types on page 5 3 Domain Types MuPAD stores all objects as elements of particular domains There are two types of domains in MuPAD basic domains and library domains The system includes the basic domains written in C The names of the basic domains start with DOM_ For example the domain of integers DOM INT the domain of rational numbers DOM RAT and the domain of identifiers DOM IDENT are basic domains Most of the basic domains available in MuPAD are listed in Basic Domains The system also includes library domains such as the domain Dom Matrix of matrices the domain Dom ArithmeticalExpression of arithmetical expressions the domain Dom Interval of floating point intervals and the domain stats sample of statistical samples Many librar
36. a b c Sequences sequence sequence d e abcde To concatenate sequences list the sequences separating them with commas sequencel B D b sequence2 t 3 t 0 3 sequence3 sequencei sequence2 a b c 0 1 8 27 To replace an entry of a sequence by a MuPAD object access the entry by its index and assign the new value to the entry sequence a b c d sequence 1 NewEntry sequence 2 1 2 3 sequence 1 matrix 1 2 3 5 6 7 sequence j 7 j To remove an entry from a sequence use the delete command I NewEntry 1 2 3 c Lg m C ba sequence a b c d delete sequence 2 sequence a c d 5 Programming Fundamentals Lists 9 10 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Lists on page 5 10 Access List Entries on page 5 11 Operate on Lists on page 5 12 Add Replace or Remove List Entries on page 5 16 Create Lists Lists represent ordered data structures Lists can contain arbitrary MuPAD objects For example numbers symbols strings or functions can be entries of a list To create a list separate MuPAD objects with commas and enclose the structure 1n brackets list a D C d a 5 c d Also you can create a sequence and convert it to a list To convert a sequence to a list enclose the sequence in brackets As a shortcut for creating a sequence use the seq
37. freeze int exp a x cos I x b x J e cos 5 x1 dx 3 143 3 Mathematics 3 144 Call intlib byparts and specify the part of an expression you want to integrate For example specify w x e f int intlib byparts f exp a x J b e sn bx i j d e cos b x 1 L La X b a a e To evaluate the resulting integral use the eval command eval f int i i bx bx i br m 2 poaxzt fe i e i opl e e cos bxi a 2 2 b IU F3 20 a ala b If the resulting expression is too long try using the Simplify or Simplify function Simplify Change of Variable Change of variable is also one of the common methods for computing integrals For explicit use of this method MuPAD provides the intlib changevar function When changing an integration variable you need to keep the integral unevaluated By default int returns evaluated integrals Use the hold or freeze commands to prevent evaluation of the integral f intlib changevar hold int sin exp x x t exp x t f sin J ct dt ia Apply Standard Integration Methods Directly To evaluate the resulting integral use the eval command eval f Sif The change of variable method also works for computing definite integrals f intlib changevar hold int x sqrt 1 x 2 x7 a b t x 2 t T 1 2 ds a i 3 145 3 Mathematics Get Simpler Results 3 146 Note Use onl
38. p a Stack To handle the stack it must be assigned to an identifier The depth number of elements and the top of the stack S depth S top 3 ic Abstract Data Types Library Push an element control the depth and then revert the stack You can see that S 1s changed e g when the method push is called push d S depth S top 4 d The stack 1s now reverted although this 1s not a standard operation for abstract stacks it comes in handy in many uses After that we pop all elements until the stack 1s empty S reverse while not S empty do print S pop end while S depth S top b d 0 FAIL 8 More Information About Some of the MuPAD Libraries Axioms Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB In MuPAD an algebraic structure may be represented by a domain Parameterized domains may be defined by domain constructors Many domain constructors are defined in the library package Dom Domains which have a similar mathematical structure may be members of a category A category adds a level of abstraction because it postulates conditions which must hold for a domain in order to become a valid member of the category Operations may be defined for all members of a category based on the assumptions and basic operations of that category as long as they make no assumptions about the representation of the elements of
39. ss 3 153 Approximate Sums Numerically 3 154 Compute Taylor Series for Univariate Expressions 3 156 Compute Taylor Series for Multivariate Expressions 3 159 Control Number of Terms in Series Expansions 3 160 O term The Landau Symbol 3 163 Compute Generalized Series 00005 3 164 Compute Bidirectional Limits 3 166 Compute Right and Left Limits 3 167 If Limits Do Not EXISU 2 2d oou der APER det eaetaaua 3 170 Create Matrices con duisi dar lid ds teta a Dueb 3 172 Create Vectors zv bum RREO IUE keene sees ce mA 3 174 Create Special Matrices 0004 3 175 Access and Modify Matrix Elements 3 177 Use Loops to Modify Matrix Elements 3 177 Use Functions to Modify Matrix Elements 3 178 Create Matrices over Particular Rings 3 179 Use Sparse and Dense Matrices 3 181 Compute with Matrices eee 3 183 Basic Arithmetic Operations 0 00000 eee 3 183 More Operations Available for Matrices 3 184 x Contents Compute Determinants and Traces of Square Matrices Invert Matrices Transpose Matrices Swap and Delete Rows and Columns Compute Dimensions of a Matrix Compute Reduced Row Echelon Form
40. x PI EvalChanges 4 x sin x 4 x sin x evalAt and subs return different results for the expressions that contain dependent variables The subs function does not distinguish between free and dependent variables The function replaces both free and dependent variables with the new value for example 3 23 3 Mathematics subs x int f x x O infinity x 1 ou J f d1 1 n The evalAt function replaces only free variables x int f x x O infinity x 1 4 8 feo x i 3 24 Choose a Solver Choose a Solver Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The general solvers solve for symbolic solutions and numeric solve for numeric approximations handle a wide variety of equations inequalities and systems When you use the general solver MuPAD identifies the equation or the system as one of the types listed in the table that follows Then the system calls the appropriate solver for that type If you know the type of the equation or system you want to solve directly calling the special solver is more efficient When you call special solvers MuPAD skips trying other solvers Direct calls to the special solvers can help you to Improve performance of your code Sometimes get a result where the general solver fails The following table lists the types of equations and systems for which MuPAD offers special solvers The solve and numeric so
41. 0 1 0 0 0 0 0 2 0 4 0 6 0 8 1 0 Primitives Requesting Special Scene Attributes Hints The default values for the attributes are chosen in such a way that they produce reasonable pictures in typical plot commands For example the default axes type in 3D scenes is Axes Boxed because this is the most appropriate axes type in the majority of 3D plots plot getDefault plot CoordinateSystem3d Axes Boxed However there are exceptions E g a plot containing a 3D pie chart should probably have no axes at all Since it is not desirable to use Axes None as the default setting for all plots exceptional primitives such as plot Piechart3d are given a chance to override the default axes automatically In a pie chart plot no axes are used by default plot plot Piechart3d 20 30 10 7 20 13 Titles 1 20 2 30 3 10 6 117 6 Graphics and Animations 6 118 f 174 5 20 B 43 amp 3 1 2D Note that Axes is a scene attribute that cannot be processed by pie chart objects directly Hence a separate mechanism for requesting special scene attributes by primitives 1s implemented so called hints A hint is an attribute of one of the superordinate nodes in the graphical tree for example an attribute of a coordinate system a scene or the canvas The help pages of the primitives give information on what hints are sent by the primitive If several primitives sen
42. 1 x S2 solve x 3 8 x S3 solve x 3 3 x 2 1 3 x x Assign individual solutions to variables by indexing into the result sol S1 3 3 28 Solve Algebraic Equations and Inequalities es baj ba Specify Equation Variables Specifying the variable that you want to solve an equation for is optional If you specify a variable the solve command returns solutions as a set of numbers Otherwise the command returns a set of lists as a solution solve x 2 3 x 2 0 x solve x 2 3 x 2 0 ake b k a If your equation contains symbolic parameters specify the variable for which you want to solve the equation solve a x 2 b x Cc x f b c b a po tl faso ia ia J lt ifa 0Absz0 C if a 0A b OAc 0 if a 0Ab 0acz 0 where G Wo 4ac If you solve an equation with symbolic parameters and do not specify the variable solve uses all parameters as variables and returns a set of all possible solutions For example 3 29 3 Mathematics 3 30 solving the following equation the solver assumes that both x and y are free variables when returning all possible solutions for this equation the solver uses an arbitrary parameter Z solve x 3 y 3 S fy zhdx eYMLt y zl x zy zl To specify more than one variable provide a list of variables as a second argument a L2 solve a x 2 b x c a b c daz b zLe u ifx 0 ae E3h5
43. 17 5 quadraticMeanL 40 83503398 Large outliers affect the geometric mean and the harmonic mean less than they affect the simple arithmetic average Nevertheless both geometric and harmonic means are also not completely resistant to outliers geometricMeanL stats geometricMean L harmonicMeanL stats harmonicMean L geometricMeanL 2 15443469 Compute Measures of Central Tendency harmonicMeanL 1 19760479 If the value of the outlier is small the impact on the mean of a data set is less noticeable Quadratic mean can effectively mitigate the impact of a few small outliers meanS stats mean S quadraticMeanS stats quadraticMean S means 515 quadraticMeanS 91 28800578 The small outlier significantly affects the geometric and harmonic means computed for the list S geometricMeanS stats geometricMean S harmonicMeanS stats harmonicMean S geometricMeanS 46 41588834 harmonicMeanS 5 714285714 The median 1s usually resistant to both large and small outliers medianL stats median L medianS stats median S medianL 1 medians 100 For data samples that contain an even number of elements MuPAD can use two definitions of the median By default stats median returns the n 2 th element of a sorted data sample z 1 1 1 100 100 100 medianZ stats median z 3 269 3 Mathematics medianz 1 When you use the Averaged option stats median returns the a
44. 2 Ch e la Me a uS 1 213 3 16 To delete a row or a column use Linalg delRow or linalg delCol respectively OriginalMatrix linalg pascal 3 DeleteRows linalg delRow OriginalMatrix 3 DeleteColumns linalg delCol OriginalMatrix 3 1 1 2 3 36 Qm b jp jl snnt E E bha Lag E ca 3 191 3 Mathematics 1 2 1 37 To delete a block of rows or columns simultaneously use the same functions as for one row or column Specify the range of rows or columns that you want to delete OriginalMatrix linalg pascal 3 DeleteRows linalg delRow OriginalMatrix 2 3 DeleteColumns linalg delCol OriginalMatrix 2 3 1 11 123 136 P 111 3 192 Compute Dimensions of a Matrix Compute Dimensions of a Matrix Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To find the dimensions of a matrix use the Linalg matdim command For example concatenate the following matrices and compute the dimensions of the resulting matrix A matrix a b c d B matrix 1 2 3 4 5 6 linalg matdim A B A A B 3 193 3 Mathematics Compute Reduced Row Echelon Form 3 194 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For the reduced row echelon form of a matrix the following conditions are valid The rows with all zero elements are at the bottom T
45. 25 579 seconds When measuring code performance using rtime avoid running other processes in the background Also ensure that enough memory is available The rtime function counts the total time including idle time during which some other process uses the CPU or your computer swaps data between different types of memory 9 99 5 Programming Fundamentals Profile Your Code 5 100 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Profiling is a way to measure where a program spends time MuPAD provides the prog profile function to help you identify performance bottlenecks in your code Use this function to analyze performance of complicated nested procedure calls For simpler code snippets measuring execution times 1s more convenient and can give you enough information to identify performance bottlenecks The prog profile function evaluates the code that you want to profile and returns the profiling report The report contains A table showing the time your code spent on each function total and averaged per one call number of calls to that function children of that function and so on Information for the most heavily used functions appear on the top of the table The first row in this table represents the total execution time A dependence graph showing a function itself the functions it calls children and the functions that call this function The graph also shows the timing
46. 5 xXx 2 3 y 2 3 Submesh 3 3 ViewingBoxZRange 0 0 1 Easy Plotting Graphs of Functions The values of the following function have a lower bound but no upper bound We use the attribute ViewingBoxZRange Automatic 20 to let plotfunc2d find a lower bound for the viewing box by itself whilst requesting a specific value of 20 for the upper bound plotfunc3d 1 x 2 y 2 exp x sin PI y x 2 2 y 2 2 ViewingBoxZRange Automatic 20 6 55 6 Graphics and Animations 6 56 Attributes for plotfunc2d and plotfunc3d The function plotters plotfunc2d and plotfunc3d accept a large number of attributes options In this section we give an overview over the most important attributes There is a help page for each attribute that provides more detailed information and examples Attributes are passed as equations AttributeName AttributeValue to plotfunc2d and plotfunc3d Several attributes can be passed simultaneously as a sequence of such equations The attributes can be changed interactively 1n the property inspector Click on the plot to make subwindows appear for the object browser and the property inspector see section Viewer Browser and Inspector Interactive Manipulation The functions plotted by plotfunc2d and plotfunc3d appear as plot objects of type plot Function2d and plot Function3d respectively They are embedded in a coordinate system inside a graphical scene The scene is
47. 5 6 L U p linalg factorLU B 12 0 0 Ka cc The permutation matrix for this LU factorization shows that the order of the rows does not change Therefore the product of the lower triangular matrix L and the upper triangular matrix U gives the original matrix A testeq B L U TRUE 3 207 3 Mathematics Compute QR Factorization 3 208 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The QR factorization expresses an mxn matrix A as follows A Q R Here Q is an mxm unitary matrix and R is an mXn upper triangular matrix If the components of A are real numbers Q is an orthogonal matrix To compute the QR decomposition of a matrix use the linalg factorQR function For example compute the QR decomposition of the 3X3 Pascal matrix P linalg pascal 3 Q R linalg factorQR P The product of Q and R gives the original 3x3 Pascal matrix testeq P Q R TRUE Also you can perform the QR factorization for matrices that contain complex values In this case the matrix Q 1s unitary B matrix I 1 1 I Q R linalg factorQR B Compute QR Factorization Again the product of Q and R gives the original matrix B testeq B Q R TRUE 3 209 3 Mathematics Compute Determinant Numerically 3 210 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To compute
48. A iioc m To remove entries from an array use the delete command When you remove an entry of an array the dimensions of an array do not change MuPAD changes the entry value you remove to NIL A 1 array 0 1 0 2 1 2 3 a Dy C IJ delete A O 2 A a Arrays with Hardware Floating Point Numbers a i To create an array of hardware floating point numbers use the hfarray command An array can contain complex floating point numbers A hfarray 0 1 0 2 1 2 3 I 3 I exp 1 PI Arrays 1 0 0 6666666667 0 33333333331 10i 2 718281828 3141592654 Arrays of hardware floating point numbers use less memory than regular arrays and matrices You can use basic arithmetical operations on these arrays A 2 A 3 0 2 0 1 01 te 8 154845485 9 474777961 9 39 5 Programming Fundamentals Vectors and Matrices Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Matrices on page 5 36 Create Vectors on page 5 37 Combine Vectors into a Matrix on page 5 37 Matrices Versus Arrays on page 5 38 Convert Matrices and Arrays on page 5 38 Create Matrices The simplest way to create a matrix in MuPAD is to use the matrix command A matrix a b cl 1 2 3 725 If you declare matrix dimensions and enter rows or columns shorter than the declared dimensions MuPAD pads the matrix with zero elements
49. Attributes such as DiscontinuitySearch TRUE or FillPattern Solid that can assume only finitely many values from a fixed discrete set cannot be animated 6 139 6 Graphics and Animations 6 140 Nearly all attributes not falling into one of these categories can be animated You will find detailed information on this issue on the corresponding help pages of primitives and attributes Advanced Animations The Synchronization Model As already explained in section The Number of Frames and the Time Range there is a real time clock running in the background that synchronizes the animation of different animated objects Each animated object has its own separate real time life span set by the attributes TimeBegin tO TimeEnd t1 or equivalently TimeRange t0 t1 The values tO t1 represent seconds measured by the real time clock In most cases there is no need to bother about specifying the life span If TimeBegin and TimeEnd are not specified the default values TimeBegin O and TimeEnd 10 are used 1 e the animation will last about 10 seconds These values only need to be modified ifa shorter or longer real time period for the animation is desired or if the animation contains several animated objects where some of the animated objects are to remain static while others change Here is an example for the second situation The plot consists of 3 jumping points For the first 5 seconds the left point j
50. B 1j u s o x x Color Li Background LI Generic Sans Serif Scalable Format for Copying Graphics By default MuPAD copies graphics to the clipboard using bitmap formats On Windows platforms you can choose to copy graphics using scalable Windows Metafile WMF format To enable scalable WMF format for copying graphics use the following steps 1 Select View Configure 2 Inthe left pane of the Configure MuPAD dialog box click Notebook 3 Inthe right pane of the dialog box select Embed scalable graphics for plots in clipboard RTF Set Preferences for Dialogs Toolbars and Graphics Set Preferences for Dialogs Toolbars and Graphics Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Preferences Available for Dialogs Toolbars and Graphics on page 2 75 Preferences for Toolbars on page 2 77 Preferences for Graphics on page 2 77 Preferences for Dialog Boxes on page 2 77 Preferences Available for Dialogs Toolbars and Graphics To specify the default settings for MuPAD toolbars dialog boxes and graphics 1 Select View gt Configure 2 Inthe left pane of the Configure MuPAD dialog box click User Interface 2 75 2 Notebook Interface Notebook C Show Labels User Interface Dialogs Units of measurement displayed Hide Help buttons cc o gt 3 Use the right pane of the dialog box to specify the setting you want
51. For example series expansions matrices piecewise defined objects etc are domains implemented in the MuPAD language The documentation refers to domain element domain type flattening Glossary such data types as library domains In particular the library Dom provides a variety of predefined data types such as matrices residue classes intervals etc See DOM DOMAIN for general explanations on data types Here you also find some simple examples demonstrating how the user can implement her own domains The phrase x is an element of the domain d is synonymous with x is of domain type d 1 e domtype x d In many cases the help pages refer to domain elements as objects of library domains 1 e the corresponding domain is implemented in the MuPAD language The domain type of an object is the data type of the object It may be queried via domtype Sequences suchasa X y or b U V consist of objects separated by commas Several sequences may be combined to a longer sequence a b is flattened to the sequence X y u v consisting of 4 elements Most functions flatten their arguments 1 e the call f a b is interpreted as the call F X y u V with 4 arguments Note however that some functions e g the operand function Op do not flatten their arguments op a 1 is a call with 2 arguments The concept of flattening also applies to some functions such as max w
52. For more information see the help pages for these commands Globally by using the environment variable ORDER When you change this variable all series expansions use the new truncation order To change the truncation order for a particular series expansion pass the new order as a third parameter to taylor taylor exp x x 10 5 7 B x 4 A 4 x 1 x 1 x oxi d 30 720 3040 40320 362880 T T i 3 i5 6 IK p To change the default truncation order for all series expansions modify the environment variable ORDER ORDER 7 taylor exp x x l ex 4 pz Pe id 3 3X a P 6 24 120 720 I Lo olx a The following computations use the new value of ORDER taylor sqrt 1 x x ix xbox 5x 7x Ox An 2 8 16 D 256 104 J To restore the default value of ORDER use the delete command delete ORDER taylor sqrt 1 x x 2 8 amp 16 128 256 i EEG xr 5x _ 7x O x O term The Landau Symbol O term The Landau Symbol Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When computing the series expansions you get expressions with one of the terms represented as the Landau symbol O This term shows the truncation order error order of the computed series expansion MuPAD automatically simplifies the O term 0 10 x 7 20 x 8 O x 2 x 1 ix 3 y 2 X 2 y 2 olx O 1 O x y When evaluating expressi
53. Frames integer gt 0 number of frames of the animation ParameterName symbolic name name of the animation parameter ParameterRang amin amax range of the animation parameter ParameterBegilamin real value lowest value of the animation parameter ParameterEnd amax real value highest value of the animation parameter TimeRange physical time range for the animation TimeBegin Start real physical time value when the animation TimeEnd end real value _ physical time when the animation ends VisibleBefore real value physical time when the object becomes invisible VisibleAfter real value physical time when the object becomes visible Function2d 3d Function2d 3d Function2d 3d Function2d 3d Function2d 3d Function2d 3d Function2d 3d Function2d 3d Function2d 3d Function2d 3d Easy Plotting Graphs of Functions attribute name __ possible values browser entry example VisibleFromTo range of real physical time Function2d 3d range when the object is visible VisibleBeforel TRUE FALSE visible before Function2d 3d animation begins VisibleAfterE TRUE FALSE visible after TRUE Function2d 3d animation ends Functions are plotted as polygons consisting of straight line segments between points of the numerical mesh The number of points in this numerical mesh are set by various mesh attributes Attributes for Numerical Mesh attribute name __ possible values browser en
54. Laplace and Inverse Laplace Transforms The Laplace transform is defined as follows F s J f t ettdt The inverse Laplace transform is defined by a contour integral in the complex plane f 1 J F s amp ds Ini l ce 1iu where c is a real value To compute the Laplace transform of an arithmetical expression use the laplace function For example compute the Laplace transform of the following expression tsine laplace t sin a t t s bu la E La a s 3 245 3 Mathematics 3 246 To compute the original expression from its Laplace transform perform the inverse Laplace transform To compute the inverse Laplace transform use the ilaplace function For example compute the inverse Laplace transform of the resulting expression tsine ilaplace tsine s t t sin a f Suppose you compute the Laplace transform of an expression and then compute the inverse Laplace transform of the result In this case MuPAD can return an expression that is mathematically equivalent to the original one but presented in a different form For example compute the Laplace transforms of the following expression L laplace t ln t t s _In s EULER 1 E Now compute the inverse Laplace transform of the resulting expression L The result differs from the original expression invL ilaplace L s t t EULER In r 1 t EULER 1 Simplifying the expression invL gives the original expression sim
55. MB TOs 3 Inthe Table Format dialog box select your settings 2 42 Use Tables i Table Format Position Z Border 1 50 Position Text wrapping Margins Cell margins all margins have the same size Padding Distance between the text and the border of a cell Border Width of the line used to draw cell borders Spacing Space between the cells Background Background color of the cells If you want to experiment with different settings and see how the formatted table looks in your notebook click the Apply button This button applies formatting to the selected table and leaves the Table Format dialog box open You can change settings several times without having to open this dialog box for each change When you finish formatting click OK to close the Table Format dialog box 2 43 2 Notebook Interface File Edit View Navigation Insert Format Notebook Window Help Bowes Aarv DF OCOn1L00 OF L En dE faz fp mf rag lt if a20A b5b20 Jf ax Eu IIIJ C Urol fr fu Eu a 6 if a20 4b5b20 c 20 el if a O0rAb 0ace0 Mem 8 MB TOs 2 44 Embed Graphics Embed Graphics Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To insert a picture into a text region 1 Select the place in a text region where you want to insert a picture 2 Select Insert gt Image from the main menu and browse the image you want to insert in a notebook 2 45 2 Notebook Interf
56. Splines Color RGB Red Gyz Style Splines Color RGB LightGrey Gxz Style Splines Color RGB LightGrey Gxy Style Splines Color RGB LightGrey We define an animated camera moving around the scene Camera plot Camera 1 100 cos a 6 100 Sin a 120 1 6 25 PI 6 0 2 PI Frames 120 The following plot call also takes about half a minute on a 1 GHz computer plot object camera Axes Boxed TicksNumber Low Cameras in 3D Next we wish to fly along the Lorenz attractor We cannot use plot Ode3d because we need access to the numerical data of the attractor to build a suitable animated camera object We use the numerical ODE solver numeric odesolve2 and compute a list of numerical sample points on the Lorenz attractor This takes about half a minute on a 1 GHz computer Y numeric odesolve2 f 0 YO RememberLast timemesh i 50 i 0 2000 Y Y t t in timemesh Similar to the picture above we define a box around the attractor with the projections of the solution curve box 15 20 20 26 1 50 Yyz map Y pt box 1 pt 2 pt 3 Yxy map Y pt gt pt 1 pt 2 box 5 Yxz map Y pt gt pt 1 box 3 pt 3 We create an animated camera using an animation parameter a that corresponds to the index of the list of numerical sample points The following procedure returns the i th coordinate i 1 2 3 of the a th p
57. and C recursively myProc proc d begin a i b b ci c isdi a end_proc The procedure evaluates the identifier a up to the first evaluation level 3 13 3 Mathematics 3 14 myProc 10 delete a b c d You can change the evaluation level inside a particular procedure This change does not affect evaluations occurring in other procedures or inside interactive computations myProc proc d begin LEVEL 8 a b b c c d a end proc myProc 10 10 For further computations delete the identifiers and restore the value of LEVEL to its default delete a b c d delete LEVEL Another environment variable MAXLEVEL enables the system to detect and interrupt infinite evaluation loops The default value of this variable is 100 This value is recommended for most computations If your code has recursive evaluations that require more than 99 steps change the value of MAXLEVEL For example the following definition of the identifier x requires 111 evaluation steps MuPAD issues an error because the system cannot evaluate x in 99 steps and assumes that the evaluation loop is infinite X k k 1 x k 1 k 1 110 x 111 9 1 x 1 Error Recursive definition the maximal evaluation level is reached delete x To avoid the error the value of MAXLEVEL must exceed the number of required evaluation steps at least by 1 Changing the value to 112 resolves the error Now Level of Evaluat
58. and c are Jf dx f IIa f symbolic parameters and x is a symbolic variable sy p sy ayok Ir Fi Piecewise objects often occur if an equation contains symbolic parameters in addition to the variable solve a x 2 b x c 0 x hi l 2 hs _ 2 Vb tue Lb yb IS E oeil 2g 2a lt ifa20 4b520 C f a 0 b 0 c 0 General Math if a O0Ab O0acz0 Plot Commands Mem 8 MB TOs You can change the appearance of the frame To format a frame 1 Place cursor inside the frame you want to format 2 Select Format gt Frame from the main menu or right click to use context menu 2 34 Use Frames H Notebookl MuPAD o EA File Edit View Mavigation Insert Notebook Window Help n Ld gh A f a Characters aT 4 f 3 Math Generic Monospace X x z Command Bar x Piecewise solution Paragraph Dnm E yal Calculation ax I gt a The solution of the quadratic eque Table 5 pi ise Here a b and c an f x f gt Ia f symbolic parameters and x is a ame sy parameters isas Framen N mp M Page p 1 si a a b alb Piecewise objects often occur if amie I i ti the variable A Decrease Size ath T n x fax w Defaults sina e Un ife solve a x 2 b x c d btyb hac EXPE aud ri a lt if a 0 b5b20 bJ C if a 0 4b 0A c 0 General Math e if a O0ab 0acez0 w Plot Commands Change frame format Mem 8 MB T0
59. bigwedge And Rightarrow Implies rArr DoubleRightArrow minus times dot coprod Coproduct amalg lowast cdot middot CenterDot centerdot deg otimes CircleTimes bigotimes xotime dagger Del Backslash setminus setmn bsol or vee Vee bigvee xvee cap U cup xcup bigcup Union bigsqcup xsqcup SquareUnion Comparison Operators e li Iv l ILI Other Symbols false Nil ap approx asymp TildeTilde TildeFullEqual cong Congruent equiv ge geq GreaterEqual le leq lt H subseteq sube SubsetEqual SupersetEqual supe supseteq NotSubset nsub g nsubset vnsub brvbar OverBar amp false NIL Intersection bigcap xcap biguplus xuplus UnionPlus tilde Tilde sim bot bottom UpTee perp equals Equal ot NotEqual ne Subset sub subset Superset sup supset NotElement notin UnderBar UnderLine lowbar num sharp true UNKNOWN FAIL 8 35 8 More Information About Some of the MuPAD Libraries 8 36 W RR gt b ka Mi hos Braces NULL NaN CapitalDifferentialD amp D DD DifferentialD dd copy reg diam diams diamond diamondsuit spades spadesuit E half frac12 frac34 sup2 para percent percent ApplyFunction InvisibleTimes blank Space NonBreakingSpace nbsp lpar ENG Lr
60. case the system does not store the compound statement itself Specify Maximum Number of Entries By default the history table for interactive computations can contain up to 20 entries When the number of entries reaches 20 the system removes the oldest entry from the history table every time it needs to add a new entry For interactive computations the environment variable HISTORY determines the maximum number of entries in the history table HISTORY 20 To change the maximum number of entries 1n the history table for the current MuPAD session assign the new value to HISTORY HISTORY 2 Now MuPAD stores only the two most recent commands and their results in the history table Error The argument is invalid last Note Within a procedure the maximum number of entries in the local history table of the procedure is always 3 independent of the value of HISTORY For further computations restore the default maximum number entries in the history table History Mechanism delete HISTORY HISTORY 20 Clear the History Table Although MuPAD restricts the number of entries in the history table it does not restrict its size Ifa command returns a large result the system stores that result in the history table While this result remains in the history table MuPAD cannot release the memory needed to store that result One or more large entries in the history table can significantly reduce available memory and slow down
61. i 2 5 Dom Integer hasProp 2 6 DomainConstructor hasProp 9 108 Techniques for Improving Performance Techniques for Improving Performance Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For most symbolic and numeric computation tasks MuPAD implements the fastest and most reliable currently known algorithms Among these algorithms the system always tries to find the best algorithm for your particular computation task Often the system also allows you to choose an algorithm explicitly or implicitly For example you can create a sequence by using the sequence generator or the for loop Also you can choose particular solvers and simplification functions Such choices can affect the performance of computations These techniques can accelerate your computations in MuPAD Use built in MuPAD data types and functions when possible Typically these functions are optimized to handle your computation tasks faster and smoother Set assumptions on parameters when possible Use the assumptions of variables sparingly or avoid them completely For details about how assumptions affect performance see When to Use Assumptions Call special solvers directly instead of using general solvers If you can determine the type of an equation or system that you want to solve calling the special solver for that equation or system type is more efficient See Choosing a Solver Call numeric solvers d
62. land end if Write a sentence by concatenating the following string and the variable terrain print Unquoted Blue color on maps usually shows terrain Blue color on maps usually shows water The following case statement also returns the result of the last assignment palette color case palette Conditional Control of monochrome do color color2 black white break of color do color1 color2 color3 red green blue break end_case red green blue Display Intermediate Results By default MuPAD does not display intermediate results obtained inside a conditional statement even 1f you use semicolons after statements To see intermediate results use the print command inside a conditional statement Omega 2 if Omega PI 2 and Omega PI then signSinOmega 1 signCosOmega 1 print signSinOmega signCosOmega end if l 1 4 7 4 Programming Basics Loops 4 8 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Use Loops with a Fixed Number of Iterations for Loops on page 4 8 Use Loops with Conditions while and repeat Loops on page 4 10 Use Nested Loops on page 4 13 Exit a Loop on page 4 14 Skip Part of Iteration on page 4 15 Return Value of a Loop on page 4 16 Display Intermediate Results on page 4 17 Use Loops with a Fixed Number of Iterations for Loops The for loop repeats a group of
63. on page 3 195 Mathematics Compute Bases for Null Spaces of Matrices on page 3 196 Find Eigenvalues and Eigenvectors on page 3 197 Find Jordan Canonical Form of a Matrix on page 3 200 Compute Matrix Exponentials on page 3 202 Compute Cholesky Factorization on page 8 203 Compute LU Factorization on page 3 206 Compute QR Factorization on page 3 208 Compute Determinant Numerically on page 3 210 Compute Eigenvalues and Eigenvectors Numerically on page 3 214 Compute Factorizations Numerically on page 3 219 Mathematical Constants Available in MuPAD on page 3 227 Special Functions Available in MuPAD on page 3 230 Floating Point Arguments and Function Sensitivity on page 3 234 Integral Transforms on page 3 242 Z Transforms on page 3 249 Discrete Fourier Transforms on page 3 252 Use Custom Patterns for Transforms on page 3 257 Supported Distributions on page 3 260 Import Data on page 3 262 Store Statistical Data on page 3 266 Compute Measures of Central Tendency on page 3 267 Compute Measures of Dispersion on page 3 271 Compute Measures of Shape on page 3 273 Compute Covariance and Correlation on page 3 276 Handle Outliers on page 3 278 Bin Data on page 3 279 Create Scatter and List Plots on page 3 281 Create Bar Charts Histograms and Pie Charts on page 3 285 Create Box Plots on page 3 293 Create Quantile Quantile Plots on p
64. rz WT m Undo d i Redo Bes of f j ea Cut EI e a 2 g amp Copy ab n x f x Paste a Fc Select Contents ce n Eu Select Region e a a_o mks Delete Output EH ay Create link mre ANT zd Insert link interactively General Math Link target Characters EC us Paragraph Calculation Frame Mem 9 MB TO s Cmd L INS Use Help Commands You can get a brief description of a command and a list of acceptable input parameters using info info solve solve solve equations and inequalities try solve for options For more detailed information about the command and its input parameters use the command solve Perform Computations Perform Computations Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Compute with Numbers on page 1 19 Differentiation on page 1 23 Integration on page 1 26 Linear Algebra on page 1 27 Solve Equations on page 1 31 Manipulate Expressions on page 1 33 Use Assumptions in Your Computations on page 1 36 Compute with Numbers Types of Numbers Using MuPAD you can operate on the following types of numbers nteger numbers Rational numbers Floating point numbers Complex numbers By default MuPAD assumes that all variables are complex numbers Compute with Integers and Rationals When computing with integers and rational numbers MuPAD returns integer results 2 2 1
65. scenes to illustrate the meaning of the layout attributes BorderWidth BottomMargin LeftMargin RightMargin TopMargin and Spacing 6 121 6 Graphics and Animations 6 122 Scene 2 TopMargin LeftMargin RightMargin BorderWidth spacing Scene 3 Scene 4 BottomMargin The basic attribute that switches between automatic and user defined layout is Layout With the default setting Layout Tabular a sequence of scenes in a canvas is displayed as a graphical array The number of columns or rows of this array may be chosen via the attributes Columns or Rows respectively If none of these attributes is specified the tabular layout scheme chooses some suitable values automatically The setting Layout Horizontal places the scenes side by side in a single row It is a shortcut for the setting Layout Tabular Rows 1 Layout of Canvas and Scenes The Canvas Header The Canvas Footer The setting Layout Vertical places the scenes one below the other in a single column It is a shortcut for the setting Layout Tabular Columns 1 The Canvas Header The Canvas Footer The settings Layout Absolute and Layout Relative switch the automatic layout mode off and allow to position each scene via the scene attributes Left and Bottom These attributes determine the position of the lower left corner of the scene and can be set separately for each scene With Layout Absolute the values for the lowe
66. symbolic animation parameter and adding an animation range for this parameter Static and animated objects can be mixed and rendered together The static function graph of f x used 1n the previous plot 1s recycled for the animation The graphical point at xo 6 81 6 Graphics and Animations f xo and the tangent through this point shall be animated using the coordinate x0 as the animation parameter Deleting its value set above we can use the same definitions as before now with a symbolic x0 We just have to add the range specification xO 0 2 PI for this parameter delete xO dx 2 sqrt 1 f x0 2 p plot Point2d xO f x0 xO O 2 PI Color RGB Black PointSize 2 0 unit mm t plot Line2d xO dx f xO f x0 dx xO dx f xO f x0O dx xO 0 2 PI Color RGB Red LineWidth 1 0 unit mm plot g p t GridVisible TRUE Details on animations and further examples are provided in section Graphics and Animations We summarize the construction principles for graphics with the MuPAD plot library 6 82 Advanced Plotting Principles and First Examples Note Graphical scenes are built from graphical primitives Section Graphics and Animations provides a survey of the primitives that are available in the plot library Note Primitives generated by the plot library are symbolic objects that are not rendered directly The call plot Primitivei Primitive2 generates the pictu
67. this operation can potentially eliminate the increase in performance that you gain by improving the procedure f itself g proc local M1 begin M1 sort op M f M1 matrixSize 2 i i 1 1000 end proc For these particular matrix size and number of calls to f 1mplementing the bisectional algorithm is still efficient despite the time required to sort the list time g 3840 24 The profiling report shows that the procedure spends most of the time executing the op and g function calls This 1s because 1mplementation of the bisection algorithm added new expensive operations in g conversion of a matrix to a list and then sorting the list The profiling report generated for the procedure call g 1s very long This example shows only the top of the report prog profile g percent usage of all time self per single call 5 105 5 Programming Fundamentals time self time children per single time children calls normal exit calls errors index function name 100 0 3884 2 3884 2 i 1 O procedure entry point 56 1 2180 1 2180 1 1704 1 1704 1 1 a IM d 33 0 1280 1 1280 1 188 0 188 0 1 2 Dom Matrix Dom Integer op 6 1 0 2 236 0 1000 s dol T 3 2 0 1 124 0 1 i 1000 4 p gt coeff p A11 2 1 1 5 0 1 60 0 i 1000 5 1 1 Rzero r nops 1 0 1 2 0 4 0 2 6 Dom Integer hasProp 2 7 DomainC
68. use ithprime to find the first number in the sequence and then use nextprime to find all following numbers n ithprime 3 10 7 n nextprime n 1 i 1 10 573259637 573259651 573259679 To find how many prime numbers do not exceed a particular value use the numlib pi function numlib pi 2 numlib pi 3 numlib pi 20 numlib pi 1000 numlib pi 15 789 1 2 8 168 6 Factorizations You can represent any integer number as a product of primes This process 1s called factoring an integer To factor an integer use the ifactor function For example factor the number 362880 ifactor 362880 954 Prove Primality The function numlib proveprime implements the Atkin Goldwasser Kilian Morain algorithm for proving primality For information about primality proving and this particular algorithm see the following papers Primes and Factorizations Atkin A O and F Morain Elliptic curves and primality proving Mathematics of Computation Vol 61 Number 203 1993 Goldwasser S and J Kilian Almost all primes can be quickly certified Proceedings of the 18th annual ACM symposium on theory of computing Berkeley CA US 1986 pp 316 329 For relatively small prime numbers numlib proveprime returns the value TRUE For composite numbers the function returns FALSE numlib proveprime 541 numlib proveprime 243 TRUE FALSE For larger prime numbers numlib proveprime retu
69. user see TicksAt ticks along the CS3d z axis set by the user 2 unit mm length of the 2 unit mm CS2d tick marks see section font for all axes sans serif 8 CS2d 3d Fonts titles Coordinate grid lines can be drawn in the background of a graphical scene corresponding to the rulings of lined paper They are attached to the tick marks along the axes There are grid lines attached to the major labeled tick marks which are referred to as the Grid There are also grid lines associated with the minor unlabeled tick marks set be the attribute TicksBetween These minor grid lines are referred to as the Subgrid The two kinds of grid lines can be set independently In the interactive object browser you will find the following attributes under CoordinateSystem2d CS2d and CoordinateSystem3d CS3d respectively Attributes for Grid Lines 6 67 6 Graphics and Animations 6 68 attribute name __ possible values browser entry example GridVisible TRUE FALSE visibility of major grid lines 1n all directions SubgridVisibl TRUE FALSE visibility of minor grid lines 1n all directions XGridVisible TRUE FALSE visibility of major grid lines in x direction XSubgridVisib TRUE FALSE visibility of minor erid lines in x direction YGridVisible TRUE FALSE visibility of major grid lines in y direction YSubgridVisib TRUE FALSE visibility of minor grid lines in
70. x 0 infinity JR EULER In 4 int sin x dirac x 2 heaviside x 3 x x 1 4 8 13 8 More Information About Some of the MuPAD Libraries 8 14 In 4 int int int 1 zZ 0 c 1 x a y b y 0 0 1 x a x 0 a abc 6 Integration by parts and by change of variables Typical applications for the rule of integration by parts J ee MEI J u x w x dx are integrals of the form p x cos x dx where p x is polynomial Thereby one has to use the rule 1n the way that the polynomial is differentiated Thus one has to choose w x cos x intlib byparts hold int x 1 cos x x cos x sin x x 1 J sin x dx In particular with the guess w x 1 it is possible to compute a lot of the well known standard integrals like e g farcsin x dx intlib byparts hold int arcsin x x 1 x arcsin x J dx PF j 2 y1 x In order to determine the remaining integral one may use the method change of variable r g x g x dx F g x c Integration Utilities with g x 1 x F intlib changevar hold int x sqrt 1 x 2 x t 1 x 2 f Cap Via backsubstition into the solved integral F one gets the requested result hold int arcsin x x x arcsin x subs eval F tz1 x 2 j uM a 7 arcsin x dx x arcsin x V l r Applying change of variable with the integrator is problematic since it may occur that the integrator will never terminate For that
71. you compute Taylor expansions of the elliptic integrals Integrate Custom Functions into MuPAD taylor ellipK x x 0 6 nx 9nx 25nx 125nx 3969 xx Q6 8 1028 51 32768 3 13102 baja If a derivative of a function contains the function itself the integration routine has a good chance of finding symbolic integrals after you implement the diff attributes For example int now computes the following integrals int ellipE x x n 3 3 2 E x _ 2 E x 2E x 2K 2 3 C int ellipK x x 2 E x 2 K x 2 x K x 9 181 Graphics and Animations Gallery on page 6 2 Easy Plotting Graphs of Functions on page 6 25 Advanced Plotting Principles and First Examples on page 6 78 The Full Picture Graphical Trees on page 6 93 Viewer Browser and Inspector Interactive Manipulation on page 6 98 Primitives on page 6 103 Attributes on page 6 108 Layout of Canvas and Scenes on page 6 120 Animations on page 6 129 Groups of Primitives on page 6 157 Transformations on page 6 159 Legends on page 6 164 Fonts on page 6 168 Colors on page 6 171 Save and Export Pictures on page 6 176 Import Pictures on page 6 179 Cameras in 3D on page 6 181 Possible Strange Effects 1n 3D on page 6 192 6 Graphics and Animations Gallery Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB 2D Function
72. 1 4 x 2 2 ViewingBoxYRange 7 Automatic 10 6 40 Easy Plotting Graphs of Functions Y 40 2 0 1 5 1 0 0 5 0 5 1 0 FO 2 3D Function Graphs plotfunc3d We consider 3D examples 1 e plots of bivariate functions z f x y Here is a plot of the function sin x y plotfunc3d sin x 2 y 2 x 2 2 y 2 2 6 41 6 Graphics and Animations If several functions are to be plotted in the same graphical scene just pass a sequence of function expressions all functions are plotted over the specified common range plotfunc3d x 2 y 2 4 sin x y x y X 2 2 y 2 2 6 42 Easy Plotting Graphs of Functions WR x24 y 2 4 We sin x yVi x y Functions that do not allow a simple symbolic representation by an expression can also be defined by a procedure that produces a numerical value f x y when called with numerical values x y from the plot range In the following example we consider the largest eigenvalue of a symmetric 3X3 matrix that contains two parameters x y We plot this eigenvalue as a function of x and y f X y gt max numeric eigenvalues matrix y X X X y x X y 2 plotfunc3d f x 1 1 y 1 1 6 43 6 Graphics and Animations The names x y used in the specification of the plotting range provide the labels of the corresponding axes Functions can also be defined by piecewise objects x 2 plotfunc
73. 1 s 1 1 s 1 laplace sinh t t s l l 2 s 1 2 s 1 This change is temporary it only affects the current MuPAD session 3 259 3 Mathematics Supported Distributions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD supports standard continuous and discrete distributions The system associates the following routines with each implemented distribution A probability density function PDF for continuous distributions or probability function PF for discrete distributions Acumulative distribution function CDF An inverse cumulative distribution function quantile function Arandom number generator The following continuous distributions are available in MuPAD 3 260 Name PDF CDF Quantile Random Generator f distribution stats betaPDFstats betaCDFstats betaQuastate betaRandom Cauchy stats cauchyPitats cauchyCHtats cauchyOGsrearts LecauchyRandom distribution distribution Stats chisquase amp D chisquase D chisquase amp usntalesquareRandom Erlang stats erlangPStats erlangCStats erlangQGsraattsd1beerlangRandom distribution Exponential stats exponenszt ati DFexponensitiatli DFexponenstiatl GuaexpdieentialRand distribution F distribution Stats fPDF stats fCDF stats fQuantidtats f Random y distribution stats gammaPD tats gammaCD tats gammaQuahatde gammaRandom Logistic Stats logistisbPHts Logistist Es Logist
74. 1 y xl The resulting expression X 1 is the complete evaluation of y The Level function demonstrates each step of this recursive evaluation The zero level of evaluation returns the identifier y itself level y 0 The first level accesses the value of the identifier and returns that value level y 1 Level of Evaluation X When you evaluate y up to the second level the system recognizes that the expression X acontains identifiers which can also have assigned values When searching for these values the system finds that the identifier a has the value 1 and the identifier x does not have an assigned value level y 2 x l In this example MuPAD completely evaluates the identifier y by using just two evaluation steps Evaluating y up to the third and higher levels returns the same expression level y 3 x l delete a x y Incomplete Evaluations MuPAD does not always evaluate identifiers completely For some expressions a complete evaluation requires a huge number of steps To avoid very long or infinite evaluations the system implements two environment variables LEVEL and MAXLEVEL These variables limit evaluation levels If the current evaluation level exceeds the limitation set by one these variables MuPAD stops the evaluation process before the system can replace all identifiers by their assigned values The environment variable LEVEL limits evaluation levels to a specified value It does not try to
75. 141 6 Graphics and Animations 6 142 We summarize the synchronization model of animations Note The total real time span of an animated plot is the physical real time given by the minimum of the TimeBegin values of all animated objects in the plot to the maximum of the TimeEnd values of all the animated objects When a plot containing animated objects 1s created the real time clock is set to the minimum of the TimeBegin values of all animated objects in the plot The real time clock is started when pushing the play button for animations 1n the graphical user interface Before the real time reaches the TimeBegin value tO of an animated object this object is static in the state corresponding to the begin of its animation Depending on the attribute VisibleBeforeBegin it may be visible or invisible before tO During the time from tO to t1 the object changes from its original to its final state After the real time reaches the TimeEnd value t1 the object stays static in the state corresponding to the end of its animation Depending on the value of the attribute VisibleAfterEnd it may stay visible or become invisible after t1 Animations The animation of the entire plot ends with the physical time given by the maximum of the TimeEnd values of all animated objects in the plot Frame by Frame Animations There are some special attributes such as VisibleAfter that are very useful to build animations from purely stati
76. 19 l Getting Started 1 20 or rational results 1 5 2 3 1 7 779 2 67473 6728 If MuPAD cannot find a representation of an expression in an integer or rational form it returns a symbolic expression 56 1 2 56 i T Compute with Special Mathematical Constants You can perform exact computations that include the constants e exp 1 2 718 and n 3 1415 2 exp 2 PI 7 For more information on the mathematical constants implemented in MuPAD see Constants Approximate Numerically By default MuPAD performs all computations in an exact form To obtain a floating point approximation to an expression use the float command For example float sqrt 56 7483314774 The accuracy of the approximation depends on the value of the global variable DIGITS The variable DIGITS can assume any integer value between 1 and 2 1 For example DIGITS 20 float sqrt 56 Perform Computations 7 483314773547882 1712 The default value of the variable DIGITS 1s 10 To restore the default value enter delete DIGITS When MuPAD performs arithmetic operations on numbers involving at least one floating point number it automatically switches to approximate numeric computations 1 0 5 2 3 1 7 7 9 2 10 028680609 If an expression includes exact values such as e or sin 2 and floating point numbers MuPAD approximates only numbers 1 0 3 exp 1 sin 2 0 3333333313 e s
77. 196 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB All vectors x such that A x form the null space of the matrix A The basis of a null space is a list B of linearly independent vectors such that the equation 4 X 0 is valid if and only if x is a linear combination of the vectors in B To find a basis for the null space of a matrix use the linalg nullspace function For example compute the basis for the null space of the square matrix A A matrix 1 2 3 4 5 6 7 8 9 10 11 12 13 5 14 15 16 linalg nullspace A Now compute the basis for the null space of the following 3 X4 matrix B matrix 1 2 3 5 6 7 9 10 11 19 14 15 linalg nullspace B 3 Find Eigenvalues and Eigenvectors Find Eigenvalues and Eigenvectors Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Linear transformations are operations that matrices perform on vectors An eigenvalue and eigenvector of a square matrix A are respectively a scalar and a nonzero vector v such that A n gt v Typically if a matrix changes the length of a vector but does not change its direction the vector is called an eigenvector of the matrix The scaling factor is the eigenvalue associated with this eigenvector MuPAD provides the functions for computing eigenvalues and eigenvectors For example crea
78. 2 For more information see Properties and Assumptions Simplify Solutions While solving equations MuPAD automatically simplifies many objects such as some function calls and arithmetical expressions with numbers Automatic simplifications reduce the complexity of expressions used in intermediate steps which improves performance of the solvers MuPAD solvers do not call the simplification functions for final results When you call the solve command you can get a long and complicated solution 3 65 3 Mathematics S solve exp x I I 2 exp x I I 2 exp x I 2 exp x I 2 To simplify such results use Simplify or Simplify The simplify function is faster Simplify S s p Inf cos 1 bani 1 1 kez Simplify is slower but more powerful Simplify S Ink L kezi For more information see Simplification 3 66 tan 1 2 x If Results Differ from Expected If Results Differ from Expected Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Verify Equivalence of Expected and Obtained Solutions on page 3 67 Verify Equivalence of Solutions Containing Arbitrary Constants on page 3 68 Completeness of Expected and Obtained Solutions on page 3 71 Verify Equivalence of Expected and Obtained Solutions Symbolic solutions can be returned in different but mathematically equivalent forms MuPAD continuously improves its functionalit
79. 200 300 400 500 Find the local extrema of F on the interval 10 lt x lt 10 If the point is a local extremum either minimum or maximum the first derivative of the function at that point equals 0 Therefore to find the local extrema of F solve the equation F X O Use the AllRealRoots option to return more than one solution extrema numeric solve F x 0 x 10 10 AllRealRoots 4 8 204531363 5 232938454 2 455643863 0 0 2 455643863 5 232938454 204531363 Now compute the corresponding values of F For example compute F for the third element 2 455643863 in the solution set F extrema 3 3 131 3 Mathematics 9 379492487 To compute the values of F for all local minima and maxima use the following command Here 1s used to evaluate F for every element of the extrema set points x F x x in extrema 1 8 204531363 518 6949936 5 232938454 124 3166806 2 455643863 9 379492487 0 0 0 0 2 455643863 9 379492487 5 232938454 124 3166806 8 204531363 518 6949936 L L Plot function F with extrema points plot F points x 10 10 500 400 300 200 100 100 200 300 400 500 To compute a derivative of a multivariable function specify the differentiation variable The operator D does not accept the variable names Instead of providing a variable name provide its index For example integrate the followin
80. 3 y 2 exp 2 x 3 3 79 3 Mathematics YA 3 2 RT nm SU GUA V DH VU 2 FE Hw rrr Y A 3 4 5 Specify the interval where you want to search for the solutions For example consider the interval x 0 1 that contains two solutions plot x sin 10 x y 3 y 2 exp 2 x 3 x 0 1 y O 1 3 80 Solve Equations Numerically Y 10 0 9 0 8 0 7 0 8 0 5 0 4 0 3 0 2 0 1 0 0 Call the numeric solve or numeric fsolve command with the MultiSolutions option Both solvers return one solution that belongs to the specified interval and one solution outside of the interval numeric fsolve eqs x 0 1 y 0 1 MultiSolutions numeric solve eqs x 0 1 y 0 1 MultiSolutions x 0 705791548 y 0 7903622856 x 1 278589279 y 0 6529880654 4 oc 1 278589279 y 0 6529880654 x 0 705791548 y 0 7903622856 Specifying the interval that does not contain any solutions can help you find more approximations In this case the solver cannot find the solution inside the interval and continues searching Before the solver quits it can find many solutions outside the specified interval numeric fsolve eqs x 10 0 y 0 1 MultiSolutions 3 81 3 Mathematics 3 82 1 876790003 y ee x 0 8950751882 y 0 7420353495 x 2 2 194032234 y 0 4812617019 x 1 58378888 y 0 5898248642 x 20 705791548 y 0 7903622856 n 1 27858927
81. 3429495709 0 5113552882 0 02089004809 0 03700165982 0 0226531849 0 004897297126 0 03063832565 0 03469956571 0 01391540741 sampleZ 0 2755344332 0 272077192 0 2682296712 0 2915713541 0 2737466882 0 3060314064 0 7624231851 0 8013891042 0 7755723041 0 7631156115 0 7816602999 0 7807856826 0 9679031724 0 9661527172 0 9632260164 0 986479402 0 9554368723 0 9768285979 Suppose you want to find the surface that fits these points Start with plotting the data The plot PointList3d function which plots a finite number of discrete points requires the coordinates of each point to be grouped together The following commands create separate lists for the coordinates of each point x Yi zi and put these lists into one nested list points sampleX i sampleY i sampleZ i i 1 nops sampleX Now use the plot PointList3d function to visualize the data ploti plot PointList3d points PointSize 2 5 Multivariate Regression plot plot1 _ Hg o neu YR lu M col i a z 56 y 6 os 4 J _ lt H3S NC di e ate e a Et y e Ot pg ST iis x 10 Rotating the plot can help you guess which surface can possibly fit the data This plot shows that the data can belong to the upper half of a sphere Thus try to fit the data to a sphere with an unknown radius r The stats reg function searches for the best fitting value for the parameter r fit stats
82. 4 assuming x gt 2 1 37 l Getting Started 4x You can pass assumptions to the following functions expand simplify limit solve and int The Simplify function does not allow assumptions on variables 1 38 Use Graphics Use Graphics Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Graphic Options Available in MuPAD on page 1 39 Basic Plotting on page 1 40 Format Plots on page 1 49 Present Graphics on page 1 56 Create Animated Graphics on page 1 59 Graphic Options Available in MuPAD Basic Plotting Options MuPAD presents many options for creating and working with graphics and animations The simplest way to create a plot in MuPAD is to use the plot command Using this command you can Create 2 D and 3 D function plots Specify plotting range Create plots for piecewise functions Create multiple function plots in one graph Create animated 2 D and 3 D function plots You can format the plot interactively Advanced Plotting Options The plot command provides a basic way to create function plots For example you can Create a 2 D function plot using plot Function2d e Create a 3 D function plot using plot Function3d Create animated plots 1 39 l Getting Started 1 40 Create function plots in polar or spherical coordinates Create turtle graphics and Lindenmayer systems Choose colors fonts legends a
83. 4 4 E If you want a simpler and more practical solution try the IgnoreAnalyticConstraints option With this option the solver uses a set of simplified mathematical rules that are not generally correct The returned solutions tend to be most useful for many problems in engineering and physics Note that with this option the solver does not guarantee the correctness and completeness of the result solve x 5 2 1 x 5 2 1 x IgnoreAnalyticConstraints See the list of the options accepted by the general solver solve Use Assumptions to Narrow Results If you want to limit the number of solutions but the list of options available for solve does not have an appropriate option try using assumptions Suppose for the following polynomial expression you need only positive solutions Use the aSSuming command If Results Look Too Complicated to temporarily assume that X is a positive number Under this assumption the solver returns four positive solutions solve x 7 2 x 6 59 x 5 106 x 4 478 x 8 284 x 2 1400 x 800 x assuming x gt 0 3 Without the assumption the solver returns all seven solutions solve x 7 2 x 6 59 x 5 106 x 4 478 x 3 284 x 2 1400 x 800 x La f y5 1 XP 1 VITL syLsymy 1l J To make several assumptions combine them with and solve a x b y c h x g y f xX yl assuming f c and a h and a lt gt 0 0 f x y 0 if b tg lt 0 h
84. 78125000 yod SSS SS ss eee 205747883139404449 v3 6 y 19981847311692446154965867495 24587 i 488281250000 E 3599999619633 a 6 g lg 174 90000000000 _ 4 1 3 30533531 Ts y j 9 sqt aaa m lonssaTs8A 30404440 vA 4 6 4 1998184731169244615496586740324587 i Mem 15 MB TOs Wrap Output Expressions By default MuPAD wraps results displayed 1n the output regions to a notebook window size The system also wraps long lines 1n outputs when printing them When wrapping breaks a number an identifier or a strings MuPAD inserts the line break symbol V For example the following result cannot be wrapped to the default notebook window size without inserting a line break inside the number 2 106 Wrap Long Lines x 100 x 9332621544394415268 1699238856266 7004907 1596826438 16214685929638952 1759999322991 560894146397615651 828625369792082 722375825 118521091 6864000000000000000000000000 The line break symbol does not affect the result of computation If you copy the result to an input region the line break symbol does not appear in the copy When you resize a notebook MuPAD automatically adjusts output lines to a new window size If a new window is large enough to accommodate the output in one line the line break symbols disappear They also disappear when you disable wrapping and reevaluate the corresponding input region To disable wrapping Select Format gt Defaults In the resulting dialog box
85. 90 Choose Simplification Functions 3 93 Collect Terms with Same Powers een 3 94 Combine Terms of Same Algebraic Structures 3 95 Expand BxpresstOllS e 2 ser dh eae eie be e Shots eoe 3 96 IactorIoxpDEOSSIOBS caulas iouceu d a dedu ed xe cuit d aret 3 97 Compute Normal Forms of Expressions 3 98 Compute Partial Fraction Decompositions of Expressions 3 99 Simplify Radicals in Arithmetic Expressions 3 99 Extract Real and Imaginary Parts of Complex Expressions 3 100 Rewrite Expressions in Terms of Other Functions 3 100 If You Want to Simplify Results Further 3 103 Increase the Number of Simplification Steps 3 103 Apply Several Simplification Functions 3 104 Use ODUOBS 3 29 5 due a dae bala ics EA oe 3 105 Use ASSURNIDLTOLHS 2 aen utto d ara b 0 Aa Week eG vp SiS 3 106 vili Contents Convert Expressions Involving Special Functions 3 108 Simplify Special Functions Automatically 3 108 Use General Simplifiers to Reduce Special Functions 3 109 Expand Expressions Involving Special Functions 3 110 Verify Solutions Involving Special Functions 3 110 When to Use Assumptions 000000 3 114 Use Permanent Assumptions lees 3 116 Set Permanent Assumptions 0 000000 00s 3 116 Add Permanent Assumptions 000000005 3 118
86. Apply Several Simplification Functions To transform a very complicated expression or an expression that should appear in a particular form you might need to apply several simplification functions When you transform an expression to a particular form by using a special transformation function the function can return can return results that are not fully simplified Suppose you want to rewrite the trigonometric expression in terms of exponential functions The rewrite command replaces the sin and cos functions by exponential functions but does not simplify the result f rewrite sin x cos x exp X1 xi 1 3 B 1 2 2 UE o GE To simplify the resulting expression call the simplify command simplify f The more powerful Simplify function converts this expression back to its trigonometric form If You Want to Simplify Results Further Simplify fF Use Options When transforming expressions the MuPAD simplifiers apply the rules valid for the entire complex plane For example try to simplify this expression containing logarithms h ln x 1 2 1n 1 1 x 2 1n 1 x 2 In 1 x 1 2 in x 1 1 7 1 _ In 1 x p In 2 1 2 2 2 By default the simplifier does not combine logarithms because this operation is only valid for particular real numbers For complex numbers combining logarithms is not generally valid Simplify h Infx 1 _ In 1 i 1 lIn 1 x h L 1 If you solve a pr
87. Cl ID A O 2 index A 1 1 a5 c Cu ho b Create an array of random numbers A array 1 3 1 4 frandom i 1 12 domtype A 0 2662 29071 01801642277 0 452083055 0 6787819503 0 2703581656 0 8310371787 0153156516 0 9948 19563 0 3549849 761 0 6818588132 0 7219186551 0 4738297742 DOM ARRAY To access a range of array entries first convert the array to a matrix B matrix A domtype B 0 2703381656 0 8310371787 0 153156516 0 9948127808 0 2662729021 0 1801642277 0452083055 0 67878 19563 0 3549849761 0 68183588132 0 7219186551 0 4738297742 Dom Matrix Use the ranges of indices to access the entries of the matrix The result is also a matrix b B 1 2 1 3 9 91 5 Programming Fundamentals 9 32 domtype b bes 0 8310371787 0 153156516 0 26602 729021 0 1801042277 0 452083055 Dom Matrix To convert matrix b to an array use the coerce function a coerce b DOM ARRAY domtype a ph 0 8310371787 0 153156516 0 2602729021 0 1801642277 0 452083055 DOM ARRAY Alternatively you can index into an array by using this command array 1 2 1 3 A i j j 1 3 i 1 2 re 0 8310371787 0 1531565 0 26002729021 0 1801642277 0 452083055 For further computations delete A B b and a delete A B b a Operate on Arrays MuPAD arrays support the following operations Assigning values to the entries of arrays Comparing arrays
88. Clear Permanent Assumptions 000008 3 120 Use Temporary Assumptions 004 3 122 Create Temporary Assumptions eese 3 122 Assign Temporary Values to Parameters 3 124 Interactions Between Temporary and Permanent ASSUmpLoDSs 322 9 VERI Puer ed bie oS ie na 3 125 Use Temporary Assumptions on Top of Permanent ASSUMPLIONS oed sopa e OR abs o RES wah ee ete 3 126 Choose Differentiation Function 3 127 Differentiate Expressions 0 000000 eee 3 128 Differentiate Functions 0 0 0 0 0 cee 3 130 Compute Indefinite Integrals 3 135 Compute Definite Integrals 3 138 Compute Multiple Integrals 3 141 Apply Standard Integration Methods Directly 3 143 Intesration Dy Parts 4 15 a dc rx dod RR aedes 3 143 Change OF Variable a nor a he Nr e Eo ra S rd 3 144 Get Simpler Results 00 8 3 146 If an Integral Is Undefined 3 147 If MuPAD Cannot Compute an Integral 3 148 Approximate Indefinite Integrals Ls 3 148 1X Approximate Definite Integrals 3 149 Compute Symbolic Sums 20000005 3 151 dennie Sum us o Arie oad a ae Rr RCN el oot a 3 151 Dermite Jus ac 923243 5 543 8 x aub ROLE db era US rait 3 152 Sums Over Roots of a Polynomial
89. Create Bar Charts Histograms and Pie Charts Bar Charts Histograms Pie Charts Create Box Plots Create Quantile Quantile Plots Univariate Linear Regression Univariate Nonlinear Regression Multivariate Regression 0 000 eee eee Principles of Hypothesis Testing Perform chi square Test leeren Perform Kolmogorov Smirnov Test Perform Shapiro Wilk Test eese Perform t Test Divisors Compute Divisors and Number of Divisors Compute Greatest Common Divisors Compute Least Common Multiples LL Primes and Factorizations 0 000 eee Operate on Primes llle Factorizations Prove Primality 3 276 3 278 3 279 3 281 3 285 3 285 3 287 3 288 3 293 3 296 3 299 3 303 3 306 3 309 3 310 3 312 3 313 3 314 3 315 3 315 3 316 3 317 3 318 3 318 3 320 3 320 xiii Modular Arithmetic lee 3 322 Quotients and Remainders 0 000000 3 322 Common Modular Arithmetic Operations 3 324 Residue Class Rings and Fields 3 325 CONSE UCT COS 555s 5 625 e as oA RC a eS 0 BAA He BBE tn 3 327 Linear Congruences 0 000 cece eee ee eee 3 327 Systems of Linear Congruences
90. Edit Existing Delete Links ul S ecu cotes rius deu Lad ep Ier e etek UNE Delete Link Targets 0 00 00 0 000 eee Export Notebooks to HTML PDF and Plain Text Formats Save and Export Export Static GEADBIGCS ut pc o o GC lo aee IC 24 6 60 25 08 oes Ae eee ee Choose the Export Format eee PAVE AMMAN S ooo s qe PE Sia phd ee ewe Is TP Export Sequence of Static Images less Set Preferences for Notebooks sess Preferences Available for Notebooks Change Default Formatting eee Scalable Format for Copying Graphics Set Preferences for Dialogs Toolbars and Graphics Preferences Available for Dialogs Toolbars and Graphics Preferences for Toolbars 0 000000 00 eee Preferences for Graphics 0 0 0 0 cece eee eee Preferences for Dialog Boxes llle Set Font Preferences eee een nes select Generic Fonts cre Default Generic Fonts for Microsoft Windows Macintosh and Linux Set Engine Preferences eee Change Global Settings 0 0 0000 eee Restore Default Global Settings Add Hidden Startup Commands to All Notebooks Options Available for MuPAD Engine Startup Get Version Information een Use Different Output Modes less
91. HeaderFont see section font for the sans serif 12 Scene2d 3d Fonts header Apart from footers and or headers of scenes and canvas there are titles associated with the functions In contrast to footer and header function titles can be placed anywhere in the coordinate system via the attribute TitlePosition Typically titles are associated 6 58 Easy Plotting Graphs of Functions with individual objects rather than with entire scenes Thus when using plotfunc2d or plotfunc3d a title attribute will usually only be used when a single function is displayed However several titles with separate positions can be set interactively in the property inspector for each of the functions Attributes for Titles attribute name possible values browser entry example Function2d Function3d the lower left corner of the title TitlePosition real value real coordinates of value real the lower left value corner of the title Function2d 3d TitlePositionY real value y coordinate of the lower left corner of the title TitlePositionireal value z coordinate of the lower left corner of the title TitleFont Fo us for the titles Function2d 3d Fonts If several functions are drawn simultaneously in one picture it is useful to display a legend indicating which color is used for which function See section Legends for further details on legends Here is a table of the most important attributes determining the form of the legend The
92. I I I I I I I I I I I I I I I I I I I I I I I I I I I I 29 sqrt 31 sqrt 108 1 3 Use Different Output Modes 1 1 54 108 ey were ee eee eee Os E ee ee a NA d aux a s OE 3 29 sqrt 31 sqrt 108 1 3 2 18 V 54 108 1 1 sqrt 3 3 29 sqrt 31 sqrt 108 1 3 9 mon M A A 54 108 29 sqrt 31 sqrt 108 1 3 V A ejm eee dri gue 54 108 29 sqrt 31 sqrt 108 1 3 o mH MM 1 V 54 108 1 P M a eee 29 sqrt 31 sqrt 108 1 3 2 3 18 54 108 1 sqrt 3 29 sart 31 sqrt 108 1 3 9 MM A A 54 108 i 29 sqrt 31 sqrt 108 1 3 V ejm eee p r2 54 108 3 2 To disable the pretty print mode clear Notebook gt Pretty Print solve x 3 x 2 1 0 x MaxDegree 3 2 91 2 Notebook Interface 2 92 1 9 29 54 1 108 31 1 2 108 1 2 1 3 29 54 1 108 31 1 2 108 1 2 1 3 1 3 1 18 29 54 1 108 31 1 2 108 1 2 V 1 3 1 2 29 54 1 108 31 1 2 108 1 2 1 3 1 3 3 E 1 9 29 54 1 108 31 1 2 108 1 2 1 3 29 54 1 108 31 1 2 108 1 2 1 3 1 2 I 1 18 29 54 1 108 31 1 2 108 1 2 1 3 1 2 29 54
93. If the engine 1s not connected to your notebook the status bar displays Not Connected Not Connected Cmd L INS The status bar indicates the type of the region where you position the cursor The indicator displays Cmd if the cursor is in an input region Text if the cursor is in a text region Outp if the cursor is in an output region The status bar also indicates if the cursor is in a read only part of a notebook for example in an output region Mem 12 MB T9 s Outp A amp INS For text and input regions MuPAD notebook supports overwrite mode Press the Insert key to enter text 1n overwrite mode Press the Insert key again to return to entering text in insert mode View the current state at the far right of the status bar 2 13 2 Notebook Interface Save Custom Arrangements 2 14 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB You can change a notebook or a Debugger window arrangement to meet your needs including resizing moving and closing toolbars and panes When you end a session MuPAD saves the arrangement The next time you start MuPAD and open a notebook or a Debugger window it appears the same way you left it Format Text Format Text Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Choose Font Style Size and Colors on page 2 15 Choose Indention Spacing and Alignment on page 2 18 Choos
94. If your code relies on the assumption that an object belongs to a particular domain type or expression type verify that assumption before executing the code To test whether a MuPAD object belongs to a particular type use the testtype function Use this function to test both domain types and expression types testtype a b DOM EXPR testtype a b plus TRUE TRUE 5 5 5 Programming Fundamentals Sequences Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Sequences on page 5 6 Access Sequence Entries on page 5 7 Add Replace or Remove Sequence Entries on page 5 8 Create Sequences Sequences represent one of the basic data structures Sequences can contain arbitrary MuPAD objects For example numbers symbols strings or functions can be entries of a sequence There are two methods for creating sequences in MuPAD Separating MuPAD objects with commas Using the sequence generator Separating MuPAD objects with commas creates a sequence of these objects sequence a b c d a b cd As a shortcut for creating a sequence use the sequence generator x 2 x 5 5 25 16 9 4 1 0 1 4 9 16 25 or the functional form of the sequence generator _seqgen x 2 x 5 5 25 16 9 4 1 0 1 4 9 16 25 Sequences To create a sequence of identical objects use the sequence generator x 2 7 x x Au lob zu Qu a
95. IntegerMod n However MuPAD operates differently on the polynomials created over IntMod n and the polynomials created over Dom IntegerMod n In particular MuPAD performs arithmetic operations for polynomials over the IntMod ring faster Also if you use IntMod n MuPAD uses the symmetric modulo function mods poly 9 3 13 11 x IntMod 11 poly 2x 2 x x IntMod 11 The domain Dom GaloisField enables you to create the residue class field 7 X E P which is a finite field with p elements If you do not specify f MuPAD randomly chooses f from all irreducible polynomials of the degree n For more information see the Dom GaloisField help page Congruences Congruences Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Linear Congruences on page 3 327 Systems of Linear Congruences on page 3 328 Modular Square Roots on page 3 329 General Solver for Congruences on page 3 332 Linear Congruences If a b and m are integers and a b mis also an integer then the numbers a and b are congruent modulo m The remainder of the division a m 1s equal to the remainder of the division of b m For example 11 2 5 mod 3 5 mod 3 11 mod 3 bn il a For known integers a and m all integers b such thata b mod m form a residue class Thus the numbers 5 and 11 belong to the same residue class modulo 3 The numbers 5 3n where n is an in
96. MATLAB The matrix command creates a matrix over Dom ExpressionField The components of such matrices can be arbitrary arithmetical expressions Alternatively you can create your own matrix constructor and use it to create matrices with elements in a particular ring When operating on such matrices most of the MuPAD functions perform computations over the specified ring One exception is the numeric library functions The call Dom Matrix R creates the constructor for matrices of arbitrary dimensions with the elements in the ring R To specify the ring R you can use the predefined rings and fields such as Dom Integer or Dom IntegerMod n or others from the Dom library For example define the constructor that creates matrices over the ring of integer numbers constructor Dom Matrix Dom Integer Dom Matrix Dom Integer Use that constructor to produce matrices with integer elements A f constructor 3 3 I1 2 3 25 34 115 34 1 211 123 231 312 When you use the constructor to create a matrix you must ensure that all matrix elements belong to the ring or can be converted to the elements in that ring Otherwise the constructor 1ssues an error and does not create a matrix constructor 3 3 I1 3 2 Sle 2 3 T1 Sx 1 211 Error Cannot define a matrix over Dom Integer Dom Matrix Dom Integer new If you use a constructor to create a matrix over a particular ring you cannot use that matrix in ope
97. MuPAD does not support arithmetical operations on arrays You can assign values to the entries of an array A t array 0 1 0 2 Arrays A O 0 1 A O 1 2 A O 2 3 A 1 0 a A 1 1 b A 1 2 c A er You also can provide the values of the entries while creating an array eom b A array 0 1 0 2 1 2 3 8 b 1 D i HIPBUT aZ Ieee Ts 5y TIT lig 24 Kl EK 1 55 j 1 3 i 1 2 B 2 3 4 123 i2 2 3 4 MuPAD accepts nested and flat lists as array entries array 1 2 3 a b c array 1 2 1 3 I1 2 3 a b 61 33 D 4 Ed QU e om Cu pa QUU gt om Cu pa When comparing arrays MuPAD compares both indices and values of the entries By default indices start with 1 A1 array 1 2 3 a b c A2 array 0 1 0 2 1 2 3 a b c Ad 29 SPPSVIT 2 Tests 14 2 3 By D CDI bool A1 A2 bool A1 A3 FALSE 9 33 5 Programming Fundamentals 9 34 TRUE You cannot use arithmetical operations on arrays A1 A2 Error The operand is invalid plus To use arithmetical operations convert arrays to matrices For numeric data you also can use Arrays with Hardware Floating Point Numbers Replace or Remove Array Entries To replace an entry of an array access the entry by its index and assign the new value to the entry A fe array 0 1 Oreck LIT 2 Bla ay D CJl A O 2 NewValue
98. TempF new O TempF 32 new TempF 0 new TempF 32 The TempF new method also ensures that all new elements represent valid temperatures TempF 500 Error Temperature is below absolute zero TempF new The TempF new method requires new elements to be real numbers TempF x 2 Error Expecting a real number above absolute zero TempF new TempF 1 2 I Error Expecting a real number above absolute zero TempF new As a next step improve the output format for the elements of your new domain To change the format that MuPAD uses for displaying the elements of a domain redefine the print method for that domain For example when displaying elements of the Define Your Own Data Types domain TempF new show temperature measurements followed by the units of measurements degrees Fahrenheit TempF print proc TempF begin expr2text extop TempF 1 Symbol deg F end proc Now MuPAD displays the elements of the domain TempF new as follows TempF 32 TempF 72 TempF 90 TempF 104 8 32 amp degF 72 amp deg F 90 amp deg F 104 8 amp deg F Suppose you want to perform additions for the elements of the new domain By default arithmetical operations treat the elements of a new domain as identifiers TempF 75 TempF 10 l amp deg F 75 amp deg F You can implement arithmetical operations for your domain For example define addition for the domain TempF The result of addition
99. This functionality does not run in MATLAB To clear a particular output region in your notebook 1 Click the output region you want to delete or click the adjacent input region 2 Select Edit gt Delete Output To clear all the outputs in your current notebook select Edit gt Delete All Outputs 2 95 2 Notebook Interface Greek Letters in Text Regions in MuPAD 2 96 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB In a MuPAD notebook you can convert characters in the text region to Greek letters one ata time 1 Select the character you want to convert or place the cursor to the right of the character 2 Select Edit Toggle Greek J Forexample display the Greek letter 5 by typing d and then placing your cursor to the right of d and selecting Edit gt Toggle Greek To get the original font style use the same steps To use Greek letters in string input enter them in a text region and copy them into the string To use Greek letters in code see Symbol new Special Characters in Outputs Special Characters in Outputs Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To produce special characters including greek letters in the output regions of a MuPAD notebook use the Symbol command Symbol Omega Symbol subScript Symbol omega 0 Symbol omega t Symbol subScript M Symbol bigodot Symbol alpha Symb
100. Tho NotANumber PartialD part commat trade die uml hearts heartsuit clubs fracl4 sup l sup3 permil sect InvisibleComma Tab MediumSpace ThickSpace rpar Ibrack lsqb brace lcub Iceil LeftCeiling lfloor LeftFloor EU m A me 0 3 lang langle LeftAngleBracket LeftDoubleBracket LM i verbar vert Punctuation Marks Colon comma period Dot DoubleDot cdots m hyphen ndash r prime Isquor sbquo Idquor bdquo i rsquor CloseCurlyQuote s rdquor amp CloseCurlyDoubleQuote raquo lexcl 2 1quest Typeset Symbols in MuPAD rbrack rsqb rbrace rcub rceil RightCeiling rfloor RightFloor rang rangle RightAngleBracket RightDoubleBracket Verbar Vert colon semi sdot hellip tdot dots horbar mdash apos quot rsquo backprime bprime Isquo OpenCurlyQuote Idquo OpenCurly DoubleQuote Prime rdquo laquo excl quest 8 37 8 More Information About Some of the MuPAD Libraries 8 38 Umlauts co a amp Currency rit Math Symbols auml ouml uuml szlig cent euro yen nabla welerp wp aleph alefsym Sart radic int Integral cauchypv pvint Qu h 2 f Principal ValueInte gral l exist Exists infin ang angle real ee Exponential E V e Ke 4 i Auml Ouml Uuml dollar pound Vprop varpropto Vprop not loz lozenge Sum sum conint
101. To prevent the conversion of input data to floating point numbers while using the numeric det function use the Symbolic option This option allows you to compute the determinant exactly without roundoff errors For matrices over particular rings and fields the determinant computed by numeric det with the Symbolic option can differ from the determinant computed by det The reason is that det performs computations over the component domain of the input matrix The numeric det function with the Symbolic option always performs computations over the field of arbitrary MuPAD expressions For example create the following matrix over the domain Dom IntegerMod 5 A Dom Matrix Dom IntegerMod 5 1 2 3 4 mod 5 2 mod 3 mod 5 4 mod 5 The det function computes the determinant over the component domain Dom IntegerMod 5 det A 3 mod 5 The numeric det function with the Symbolic option computes the determinant of the following matrix instead of the original matrix A expr A n The determinant of this matrix 1s an integer number Jb Compute Determinant Numerically numeric det A Symbolic 2 The numeric det function switches to the Symbolic option under one or more of the following conditions You use the Symbolic option explicitly The input data contains symbolic objects 3 213 3 Mathematics Compute Eigenvalues and Eigenvectors Numerically Note Use only in the MuPAD
102. TrapError 1202 prog test error f x x TrapError 1202 prog testexit f Info 11 tests O errors runtime factor 0 0 nothing expected Info CPU time 12 7 S Info Memory allocation 20452460 bytes prog testexit If you change the original procedure f run the test script to catch any unexpected results f proc a Type Numeric b Type Numeric begin if a gt b then return a else return b end if end proc You do not need to copy the test script to the notebook Instead you can execute the test script that you saved to a file without opening the file To execute a test script 1 Select Notebook gt Read Commands to open the Read Commands dialog box 2 Change the file filter to show MuPAD test files or all files 9 135 5 Programming Fundamentals 5 136 MuPAD Test File tst All Files 3 Navigate to the test file that contains the script and click OK Alternatively use the READPATH variable to specify the path to the folder that contains the file Then use the read function to find and execute the test file For example if you saved the test file test f tst in the folder C MuPADfiles TestScripts use the following commands READPATH C MuPADfiles TestScripts read test f tst Error in test function f that compares two numbers 7 Input f 2 I 2 I Expected Z I Got TrapError 1003 Error Can t evaluate to boolean leequal r n Evaluating f Near line 9
103. When you call a procedure MuPAD does not allocate new memory blocks right away Instead it links local variables to memory blocks where the arguments of the procedure are stored The system always counts how many objects are linked to the same memory block When a procedure modifies the value of a local variable MuPAD checks if there are other objects linked to the same memory block and creates a copy only if necessary For example when you call f x MuPAD points both global variable x DOM IDENT and local DOM VAR variable x to the same memory block Only when the local variable x changes its value MuPAD allocates a new memory block for it Calls by Reference Typically when you call MuPAD procedure with some arguments the system uses the calling by value approach and creates copies of the values of these arguments This approach prevents procedures from modifying objects passed to a procedure as arguments For some functions such as assignment MuPAD uses the calling by reference approach In a call by reference the system does not copy the values of arguments to new memory blocks Instead 1t copies references pointers to these arguments Some programming languages let you specify which approach to use for each particular function MuPAD does not offer specific language constructs for calling by reference Nevertheless you can still call by reference in MuPAD Note For experienced MuPAD users objects with reference sem
104. Windows documentation for details 2 101 2 Notebook Interface Wrap Long Lines 2 102 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Wrap Text on page 2 102 Wrap Expressions in Input Regions on page 2 104 Wrap Output Expressions on page 2 106 Wrap Text To wrap text to a notebook window size select View Wrap To Window If you use text wrapping and resize your notebook MuPAD automatically adjusts text lines to a new window size This option affects text regions only Wrap Long Lines File Edit View Navigation Insert Format Notebook Window Help 2g de wo x u39072 Q09 e The vertical dashed gray line shows the right margin of the printed page When you print this notebook MuPAD offers you to scale it down to fit the printer setting for a page size If you use the actual page size only the part of the notebook to the left of the vertical line appears on printed pages Generic Sans Serif solve S00000 x 4 123456 x 3 x 2 1000 x 123456789 0 x MaxDegree 4 35284995497 E y 5080195408992451661 V3 v 6 v 8467460273477442205913016404294527174057 i sqrt 2700000000000000 562500000000000 976562500000 444444070032001 T T i eos uu 90000000000 5 4 150801954 45165 3 4 6 8467460273477442205913016404294527174057 1 r 35284995497 6 2080195408952451661 VIVI 1 3 TP 5 3 v TD600ODDDODDDOD SEGSDDOOODDODOS 5
105. Zeta function numeric solve zeta 1000000001 2000000000 I y y 14 15 414 13472514 Floating Point Arguments and Function Sensitivity Increasing the numbers of digits shows that the result is incorrect The Zeta function Se lt y lt 15 DIGITS 15 numeric solve zeta 1000000001 2000000000 I y y 14 15 i delete DIGITS Approximate Parameters and Approximate Results Bessel functions with half integer indices return exact symbolic expressions Approximating these expressions by floating point numbers you can get very unstable results For example the exact symbolic expression for the following Bessel function is B besselJ 53 2 PI P 1 1 T T T 3514 2 119403075 20300 _ 315241547000 445475704038 730 _ 366812794263 762000 4 182947881139051297500 _ 55720697512636766610000 10174148683095239020903175 I iE IL 1060253389 1429775400 73002500 2130069568311 773 0050949028125 z 7 7 m B IL x oof 1331871030107000331 702088875000 842700 778169325090140040415 78175 21i Use the f loat command to approximate this expression numerically float B 3 237 3 Mathematics 3 238 Now call the Bessel function with the floating point parameter Significant difference in these two approximations indicates that one or both results are incorrect besselJ 53 2 float PI 6 900145607 10 7 Increase the numeric working precision to obtain more accurate approxi
106. a special mode of executing your code the system evaluates assertions during run time If an assertion does not evaluate to TRUE the system stops code execution and throws an error For example this procedure solves the equation sin x cos x a Suppose you get the parameter a as a result of some computations and you expect the condition a lt 4 2 to be always valid Relying on this condition you expect the solutions to be real Specify this condition as an assertion by using assert f proc a begin assert a 2 lt sqrt 2 S solve sin x cos x a 2 end Assertions are checked only when you run your code in a special mode called the argument checking mode Otherwise the system ignores all assertions For example in this procedure call MuPAD skips the assertion and returns the following complex result f 4 3 Use Assertions 1 1 4 yay 5 To switch to the argument checking mode set the value of testargs to TRUE testargs TRUE Now when you call the procedure f MuPAD checks the assertion Fora 4 3 the assertion evaluates to FALSE and the procedure execution stops with the error f 4 3 Error Assertion a 2 lt sqrt 2 has failed f Fora 1 the assertion evaluates to TRUE The procedure call runs to completion and returns the following set of real solutions T 1 x 22k keZyol 2nk kez a The argument checking mode can slow down your computation
107. 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 amp 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 MathWorks products are protected by one or more U S patents Please see www mathworks com patents for more information Revision History September 2012 Online only New for Version 5 9 Release 2012b March 2013 Online only Revised for Version 5 10 Release 2013a September 2013 Online only Revised for Version 5 11 Release 2013b March 2014 Online only Revised for Version 6 0 Release 20142 October 2014 Online only Revised for Version 6 1 Release 2014b March 2015 Online only Revised for Version 6 2 Release 20152 September 2015 Online only Revised for Version 6 3 Release 2015b Contents Getting Started Desktop Overview eeeee eh 1 2 Evaluate Mathematical Expressions and Commands 1 4 Working in a Single Input Region lees 1 4 Wor
108. all the procedure calls in the Call Stack pane The Debugger marks the name of the current procedure with a blue triangle and highlights the currently executed code line Call Stack mx Procedure 9 18 Debug MuPAD Code Using the Debugger To switch between procedures click the name of a procedure you want to switch to Also you can select Step gt Stack Up or Step gt Stack Down from the main menu or use the toolbar As an alternative you can press u and d The Call Stack pane helps you navigate within nested calls of various procedures Correct Errors The Debugger displays procedures and helps you find errors in the code but you cannot correct the errors in the Debugger window To edit your code use the MATLAB Editor a MuPAD notebook or any text editor To open a new MATLAB Editor window select File gt New Editor with Source from the main menu or select Open in Editor from the context menu The MATLAB Editor window contains the source that you see in the Debugger and lets you modify and save it Changes made in the Editor window do not automatically appear in the Debugger window The Debugger presents the code that is already in the kernel To run the Debugger on the corrected file Close the Debugger window if it is open In the Editor window select File gt Save from the main menu to save changes Open a notebook mh O N Select Notebook gt Read Commands from the main menu 5 79 5 Programming Fundamentals Fil
109. and Curve Plots on page 6 2 Other 2D examples on page 6 7 3D Functions Surfaces and Curves on page 6 17 We present a collection of pictures illustrating the capabilities of the present MuPAD graphics system These pictures are created at various places in this document where they are used to demonstrate certain features of the graphics system A reference to the location of detailed documentation is provided along with each picture in this gallery There further details including the MuPAD commands for generating the picture can be found 2D Function and Curve Plots The following picture shows a plot of several functions Singularities are highlighted by vertical asymptotes See 2D Function Graphs plotfunc2d for details 6 2 Gallery The following picture shows a function plot together with a spline interpolation through a set of sample points See section Some Examples for details 6 3 6 Graphics and Animations 0 3 SLE AM CEREALES o HEEE 25 28 30 X Wm x sin 5 x exp x aW spline interpolant The following picture shows a hatched area between functions See the examples on the help page of plot Hatch for details 6 4 6 Graphics and Animations trigonometric functions the sine function the cosine function the cot function 1 2 The following picture demonstrates the construction of cycloids via points fixed to a rolling wheel See section Some Examples for an
110. and number of calls for each function Note By default prog profile does not measure performance of single calls to kernel functions However when prog profile measures the performance of library functions it also prints the accumulated time the system spends in kernel functions To measure the performance of a single call to a kernel function use prog trace to trace that kernel function Suppose you want to write a procedure that checks whether each integer from 1 to 1000 appears in a 1000x1000 matrix of random integers The direct approach is to write a procedure that checks every element of a matrix proceeding row by row and column by column f proc M n x begin Profile Your Code for j from 1 to n do for k from 1 to n do if M j k x then return TRUE end if end for end for return FALSE end proc Use the linalg randomMatrix to create a 1000x1000 matrix of random integers matrixSize 1000 M linalg randomMatrix matrixSize matrixSize Dom Integer Then call the procedure f 1000 times to check if each number from 1 to 1000 appears in that matrix g proc begin f M matrixSize i i 1 1000 end proc Measuring the time needed to run the procedure g shows that the procedure requires optimization Although the performance bottleneck in this procedure is obvious it 1s not always easy to identify performance bottlenecks in more complicated procedures The time function does not
111. angle y changes its value from 0 to 2 n int int R 2 sin phi phi O PI chi 0 2 PI Compute the expression for the volume of a sphere The angles accept the same values but the distance from the center of any point inside the sphere ranges from 0 to R To find the volume compute the following triple integral 3 141 3 Mathematics int int int r 2 sin phi r O R phi O PI chi O 2 PI 3 142 Apply Standard Integration Methods Directly Apply Standard Integration Methods Directly Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Integration by Parts on page 3 143 Change of Variable on page 3 144 Integration by Parts Integration by parts is one of the common methods for computing integrals Using this method you rewrite the original integral in terms of an expression containing a simpler integral Integration by parts for indefinite integrals uses the definition For definite integrals integration by parts is defined as follows b b J w x v x dx u b v b u a v a J u x w x dx Internally MuPAD uses integration by parts along with other integration methods To use this method explicitly call the intlib byparts function If you want to integrate an expression by parts keep the original integral unevaluated By default int returns evaluated integrals Use the hold or freeze commands to prevent evaluation of the integral f
112. assigns that value to the local variable x uses 1t to compute the result and then destroys the local variable x freeing allocated memory Although the value of the local variable x changes to 1 inside the procedure and then gets destroyed the value of the global variable X remains the same Therefore you can conclude that the procedure does not access the actual memory block that contains the value of x When you call this procedure MuPAD allocates a new memory block and copies the value of X to that block While the procedure executes the system associates the local variable x with this new memory block At the end of the procedure call it frees this memory block The memory block that contains the value of the global variable x does not change 5 169 5 Programming Fundamentals 5 170 The strategy of copying values of procedure arguments to new memory blocks and referring to these blocks during the procedure calls is known as calling by value Most MuPAD functions use this strategy Since calling by value creates extra copies of data it can be inefficient 1n terms of memory management Creating extra copies of large data sets especially when your procedure calls are recursive or nested can significantly reduce free memory on your computer In many programming languages calling by value always means copying data even when a procedure does not change that data MuPAD uses lazy copying to avoid creating unnecessary copies of data
113. attributes LegendEntry LegendText and LegendVisible TRUE are set automatically by plotfunc2d plotfunc3d if more than one function is plotted Function3d TitlePositionjreal value x coordinate of Function2d 3d the lower left corner of the title 6 59 6 Graphics and Animations The property inspector Viewer Browser and Inspector Interactive Manipulation allows to reset the legend entry for each function Attributes for Legend attribute name __ possible values browser entry example LegendEntry TRUE FALSE add this Function2d 3d function to the legend LegendVisible TRUE FALSE legend on off TRUE Scene2d 3d LegendPlacemer Top Bottom vertical ups placement LegendAlignmeiLeft Center horizontal Center Scene2d 3d Right alignment LegendFont see section font for the sans serif 8 Scene2d 3d Fonts legend text When singular functions are plotted 1t 1s often useful to request a specific viewing range Here 1s a table of the most important attributes for setting viewing ranges In the interactive object browser you will find them under CoordinateSystem2d CS2d and CoordinateSystem3d CS3d respectively Attributes for Viewing Ranges attribute name possible values browser entry example ViewingBox xmin xmax viewing range in Automatic ymin ymax x and y direction Automatic Automatic Automatic ViewingBox xmin xmax viewing range in Automatic ymin ymax x y z direction Aut
114. axioms of the categories are not stated explicitly Only axioms which are not implied by the definition of a category are stated explicitly The category of groups for example has no axiom stating that the multiplication is invertible because that 1s implied by the definition of a group Bibliography J H Davenport and B M Trager Scratchpad s View of Algebra I Basic Commutative Algebra DISCO 90 Springer LNCS 429 ed A Miola 40 54 1990 K Drescher Axioms Categories and Domains Automath Technical Report No 1 Univ GH Paderborn 1995 R D Jenks and R S Sutor AXIOM The Scientific Computation System Springer 1992 Combinatorics Combinatorics Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The combinat library provides combinatorial functions The library functions are called using the library name combinat and the name of the function E g use combinat bell 5 to compute the 5 th Bell number This mechanism avoids naming conflicts with other library functions If this is found to be inconvenient then the routines of the combinat library may be exported via use E g after calling use combinat bell the function combinat bell may be called directly bell 5 All routines of the combinat library are exported simultaneously by use combinat The functions available in the combinat library can be listed using info combinat 8 7 8 More Informat
115. bitmap graphics formats PNG GIF BMP JPEG Save Animations You can export an animation created in MuPAD into an animated GIF file If you use a Windows systems you can export an animation created in MuPAD into the special 2 65 2 Notebook Interface format AVI To save an animation in this format select a compressor from the list of compressors available for your animation and operating system Export Graphics Raster Image Options Resolution Auto DPI Quality Frames per second 15 resultsin 151 images MIICcTOSOTL video 1 Microsoft Video 1 Uncompressed Q ther A compressor defines the size of the exported animation and the quality of images in the animation Viewing the exported animation requires the installation of an appropriate compressor Export Sequence of Static Images You can export an animation as a sequence of static images For example the following calculations result in an animated plot plot plot Function2d sin x plot Point2d x sin x x 5 5 plot Line2d x 1 x 1 x 5 5 LineStyle Dashed plot Line2d 5 sin x 5 sin x 5 5 LineStyle Dashed 2 66 Save and Export Graphics To export the resulting plot 1 Select File gt EKxport Graphics from the main menu or right click to use the context menu 2 Click Next in the Graphics Export Guide dialog box 3 Select Export whole animation sequence and click Next 2 67 2 Note
116. cSGOFT returns the p value that is below the typical significance level 0 05 The null hypothesis does not pass the test stats csGOFT x cells CDF stats normalCDF O 1 PValue 9 164721121 C StatValue 184 3794698 MinimalExpectedCellFrequencv 17 68346079 3 311 3 Mathematics Perform Kolmogorov Smirnov Test 3 312 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For the Kolmogorov Smirnov goodness of fit test MuPAD provides the stats KksGOFT function This function enables you to test the data against any cumulative distribution available in the MuPAD Statistics library The Kolmogorov Smirnov test returns two p values The null hypothesis passes the test only if both values are larger than the significance level For example create the following data sequence x which contains a thousand entries f X stats normalRandom 1 1 3 f k 1 1000 Use the function stats KsSGOFT to test whether the sequence x has a normal distribution with the mean 1 and the variance 1 3 Suppose you apply the typical significance level 0 05 Since both p values are larger than the significance level the sequence passes the test stats ksGOFT x CDF stats normalCDF 1 1 3 PValuel 0 06518463285 StatValuel 1 163141302 PValue2 0 8735153294 StatValue2 0 2548375105 Test the same sequence but this time compare it to the normal distribution with the var
117. called without arguments end if eqs egr vars var to avoid warnings userinfo l solving exprztext egqgas for exprztext vara else eqs egr userinfo l Solving exprztexti egs end if itf type egs equal then if domtype opleqs 1 DOM LIST and domtype op eqs 2 DOM LIST then Bqs zipliopieqs 1 opleqs 2 equal else eqs aop eqs 1 op eqs 2 if eqs undefined then return procname args 11 end if end if end if Continue execution Mem 1 MB TOs After setting breakpoints you also can leave the current debugging session and start a new one In the new session the Debugger stops at all the breakpoints you previously set You can see the list of all breakpoints in the debugging process using the Breakpoints window To open this window select View gt Breakpoints 9 13 5 Programming Fundamentals 5 74 Remove Breakpoints To remove a breakpoint Select the breakpoint you want to remove 2 Select Breakpoints gt Toggle Breakpoint from the main menu or right click to use the context menu Also you can click the Toggle Breakpoint button on the toolbar The second click releases the button and removes the breakpoint If you want to remove all breakpoints select Breakpoints gt Remove All Breakpoints from the main menu Debug MuPAD Code Using the Debugger File Edit View Step Breakpoints Watches Set Breakpoint Remove All Breakpoints erro
118. click the Calculations tab From the drop down menu Format select Output Math Select the Wrap lines check box mh N 2 107 2 Notebook Interface Format Qutput Math T Defines the math format for the formula output of a new calculation Slant identifiers Select Wrap lines this option Minimal script size 8 j Script size multiplier 71 96 If you disable wrapping MuPAD does not insert lines breaks in the new output expressions If you want to remove line breaks in the existing output expressions reevaluate these expressions 2 108 Wrap Long Lines File Edit View Navigation Insert Format Notebook Window Help you to scale it down to fit the printer setting for a page size If you use the actual page size only the part of the notebook to the left of the vertical line appears on printed pages solve S00000 x 4 123456 x 3 x 2 1000 x 123456789 0 x MaxDegree 4 a g g5g B _ W3 g cay c 53 645 0s 2 eis 035172 was 73 Ul ws 371 5 5080195408992451661 v3 V 6 V 8467460273477442205813016404294527174057 i 1 35284905407 6 2090195408222451661 v7 v9 wv mtr m Rm 2 i 2700000000000000 562500000000000 TO m97656250000 8 78125000 1 6 1 4 E 4 50533531 Us pl MM M SSS SSS isnanias4n900245 3 6 81574602734774422053915301640470457 7174057 1 35284005497 amp 2080195408992451661 v3 W v y 270000000000000
119. compute the Laplace transform or the inverse Laplace transform of an expression it returns an unresolved transform laplace f t t s laplace f r t 5 ilaplace F s s t ilaplace Fis s f Z Transforms Z Transforms Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The Z transform of the function F Z is defined as follows e fh k 0 4 If R 1s a positive number such that the function F Z 1s analytic on and outside the circle z R then the inverse Z transform is defined as follows Se Fx de k 0 1 2 ue You can consider the Z transform as a discrete equivalent of the Laplace transform To compute the Z transform of an arithmetical expression use the ztrans function For example compute the Z transform of the following expression S ztrans sinh n n z z simh 1 z 2 cosh 1 z 1 If you know the Z transform of an expression you can find the original expression or a mathematically equivalent form by computing the inverse Z transform To compute the inverse Z transform use the iztrans function For example compute the inverse Z transform of the expression S iztrans S z n sinh 72 3 249 3 Mathematics 3 250 Suppose you compute the Z transform of an expression and then compute the inverse Z transform of the result In this case MuPAD can return an expression that 1s mathematically equivalent to the original one but presented in a
120. contradict each other Contradicting assumptions can lead to inconsistent and unpredictable results In some cases MuPAD detects conflicting assumptions and issues the following error assume x 0 x assumingAlso x gt 0 Error Assumptions are inconsistent property assume MuPAD does not guarantee to detect contradicting assumptions assume x Type Even x assumingAlso x 1 Type Even X Choose Differentiation Function Choose Differentiation Function Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD provides two functions for differentiation The choice of the function depends on which type of object you want to differentiate To differentiate mathematical expressions use the diff command For example diff co A X diff x 3 x sini x i T 3x To differentiate a function or functional expression use D or its shortcut Using this command you can differentiate any standard mathematical function or your custom created function For example D cos f x gt x sin x T sin X sin x x cos x 3 127 3 Mathematics Differentiate Expressions 3 128 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For differentiating an expression use the diff command Specify the expression you want to differentiate and the differentiation variable Specifying the differentiation vari
121. creates an animation g Frame To create a 3 D plot use the plot c solve x 2 y 2 z 2 i miata pao tana kayaa i e ay Decrease Size w Defaults Em size of text characters Mem 10 MB T 7 Outp Note Graphics size does not change To change graphics size see Scaling Graphics 2 114 Change Font Size Quickly T WE AD Edit Insert Format Notebook Window Help BOWES Py 3 CO ntBO OF Creating 3 D Plots You also can create a 3 D plot by using the plot command By default if the plot command can create a 3 D plot and a 2 D animation for the same expression it creates an animation To create a 3 D plot use the plot command with the option 3D solve x 2 y 2 z 2 1 Z plot x 2 y 2 z 2 e n 4 n F Mem 10 MB T 7 s Outp To undo font size changes select Edit gt Undo or use the toolbar button a Note Using the opposite option such as increasing the fonts you have decreased before does not guarantee to restore the original font size 2 115 2 Notebook Interface Scale Graphics Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To resize your graphics right click the graphics and select Graphics Size a v Notebookl MuPAD File Edit View Navigation Insert Format Notebook Window Help Export Graphics Graphics Size Open in Window r Genera
122. data sample y ys Yn Create the lists X and y X ty Te 0 11 y i 1 2 0 1 To estimate the similarity of these lists compute their covariance For completely uncorrelated nonsimilar data the covariance is a small value A positive covariance indicates that the data change in the same direction increases or decreases together A negative covariance indicates the data change in opposite directions There are two common definitions of the covariance By default the stats covariance function uses the definition with the divisor n 1 To switch to the alternative definition use the Population option stats covariance x y stats covariance x y Population Compute Covariance and Correlation 0 42 0 28 The covariance of a data sample with itself 1s the variance of that data sample stats covariance X x stats variance x The correlation of data samples indicates the degree of similarity of these data samples For completely uncorrelated data the value of the correlation as well as the covariance tends to 0 For correlated data that change in the same direction the correlation tends to 1 For correlated data that change in the opposite directions the correlation tends to 1 Compute the correlation of X and y stats correlation x stats correlation x y X stats correlation x X 0 8504394349 1 0 1 0 3 277 3 Mathematics Handle Outliers 3 278 Note Use only
123. detect and prevent an infinite evaluation loop For interactive computations the default value of the environment variable LEVEL 1s LEVEL 100 3 9 3 Mathematics 3 10 When the evaluation level reaches the value of LEVEL MuPAD stops the evaluation and returns the result of the last computed evaluation step LEVEL 10 i gt x 15 x x 4 10 delete LEVEL x MuPAD does not specify one uniform value of LEVEL for all computations For most computations the value 1s 100 but there are exceptions to this rule Ifthe evaluation occurs in a procedure MuPAD limits the evaluation level to 1 Ifthe evaluation occurs in a matrix MuPAD limits the evaluation level to 1 MuPAD does not evaluate arrays tables and polynomials The evaluation level for these objects 1s 0 e MuPAD does not evaluate a returned value of the last function call or its equivalent The evaluation level is 0 e MuPAD does not evaluate returned values of some other system functions For example the system does not evaluate the results returned by the subs and text2expr functions The help pages for such functions provide the information about the evaluation levels of the returned values Ifthe evaluation occurs in a function call level expression n MuPAD disregards the environment value LEVEL Instead the system uses the evaluation level n For example although LEVEL 100 by default the function call level a x 1 evaluates th
124. different form For example compute the Z transform of the following expression C ztrans exp n n z z Now compute the inverse Z transform of the resulting expression C The result differs from the original expression invC iztrans C z n C e7 el l n m O Simplifying the resulting expression invC gives the original expression simplify invC e Besides arithmetical expressions the ztrans and iztrans functions also accept matrices of arithmetical expressions For example compute the Z transform of the following matrix A 19 matPix 2 2 la n n 7 2 n 115 ZA ztrans A n z 2 a l at a dmn oz l 2 1 z l z 1 j Computing the inverse Z transform of ZA gives the original matrix A iztrans ZA z n Z Transforms F3 5 The ztrans and iztrans functions let you evaluate the transforms of an expression or a matrix at a particular point For example evaluate the Z transform of the following expression for the value Z 2 ztrans 1 nl n 2 we Evaluate the inverse Z transform of the following expression for the valuen 10 iztrans z z exp x z 10 e10 x If MuPAD cannot compute the Z transform or the inverse Z transform of an expression it returns an unresolved transform ztrans f n n Z ztrans f 71 5 Z iztrans F z z n iztrans F z z 7 3 291 3 Mathematics Discrete Fourier Transforms 3 252 Note Use on
125. ellipK x 2 1 i zl elipE x elipK elipK x 1 The first derivatives of these elliptic integrals are as follows E z Elz K z z Elz 1 2 Elz ail Iz 2 1 z z F The standard MuPAD differentiation function diff does not know about these rules Therefore trying to differentiate ellipE and ellipK simply returns the symbolic notations of the derivatives diff ellipE x x diff ellipK x x o elipE x ellpK x Ox C Integrate Custom Functions into MuPAD To make diff work with the new functions create function environments from the procedures ellipE and ellipK In addition function environments let you control the appearance of the symbolic function calls in outputs A function environment consists of three operands The first operand is a procedure that computes the return value of a function call The second operand is a procedure for printing a symbolic function call on the screen The third operand is a table that specifies how the system functions handle symbolic function calls To create function environments use funcenv For example create function environments ellipE and ellipK Use the second argument to specify that symbolic calls to e11ipE and ellipK must appear as E and K outputs output E f hold E op f ellipE funcenv ellipE output E output K f hold K op f ellipK funcenv ellipK output K Although ellipE and ell
126. embedded in a viewing area called the Canvas In the viewer the various plot attributes are associated with the different objects of this graphical hierarchy Typically layout parameters and titles are set within the canvas whilst axes grid lines viewing boxes etc are associated with the coordinate system Some attributes such as colors line width the numerical mesh size etc Easy Plotting Graphs of Functions belong to the function graphs and can be set separately for each function plotted by plotfunc2d plotfunc3d The last entry in the following tables provides the location of the attribute 1n the graphical hierarchy of the object browser For example for changing the background color of the picture select the scene by double clicking the Scene2d Scene3d entry in the object browser Now the property inspector provides a tree of attributes with the nodes Annotation Layout and Style Opening the Style sub tree one finds an entry for BackgroundColor which allows to change the background color interactively Here is a table of the most important attributes for setting the layout and the background of the picture Attributes for Layout attribute name possible values browser entry example Width 12 unit cm physical width 120 unit mm Canvas of the picture Height 8 unit cm physical height 80 unit mm Canvas of the picture BackgroundCol RGB color color of the RGB White Scene2d
127. end while Lilea end SEED 123456789 rndUntil42 900763287358 105114186275 873298641118 648455050747 234588728784 92685732612 9868025206343 604554099645 670181021599 362027535788 418959155834 993175789760 149359951993 321479945512 428476485080 8956822341706 447827957703 41591770379 80666499751 874251833750 992824008008 119331599241 557871606770 7168209806241 14491390573 864609020354 219333389772 427408038876 665245836081 381920617859 300482947701 159259847066 589167468787 999975884731 405723681406 785149905992 7703726763063 739767410836 909396123045 713889761414 247358421991 520049482008 2097806390536 38034535073 730171970247 627506313885 915109441004 131065910285 948970540311 807086241612 SEED 123456789 time rndUntil42 i 1 500 220 013 Alternatively if you cannot predict the number of elements that you will need to collect then use a table that grows automatically a hash table rnduntil42 proc local L i j begin i n L 1 table 1 random 5 147 5 Programming Fundamentals while L i mod 42 lt gt 0 do i i ET L i random end while L j j71 i end SEED 123456789 time rndUntil42 i 1 500 216 014 For this example using the table is slightly faster If you change the value 42 to another value using the list might be faster In general tables are preferable when you collect large amounts of data Choos
128. example GridVisible TRUE FALSE visibility of major FALSE erid lines in all directions SubgridVisible TRUE FALSE visibility of minor FALSE erid lines in all directions AdaptiveMesh integer gt 2 number of sample 121 points of the numerical mesh Axes None Automatic axes type Automatic Boxed Frame Origin AxesVisible TRUE FALSE visibility of all axes TRUE AxesTitles string string titles of the axes EXS ay CoordinateType LinLin LinLog linear linear LinLin LogLin LogLog linear logarithmic logarithmic linear log log Colors list of RGB values line colors first 10 entries of RGB ColorList Frames integer gt 0 number of frames of 50 an animation LegendVisible TRUE FALSE legend on off TRUE LineColorType Dichromatic color scheme Flat Functional Monochrome Rainbow integer gt 2 number of sample 121 points of the numerical mesh Easy Plotting Graphs of Functions attribute name possible values example Scaling Automatic scaling mode Unconstrained Constrained Unconstrained TicksNumber None Low Normal number of labeled Normal High ticks at all axes VerticalAsymptote TRUE FALSE vertical asymptotes TRUE on off ViewingBoxYRange ymin ymax restricted viewing Automatic range in y direction YRange ymin ymax restricted viewing Automatic range in y direction equivalent to ViewingBoxYRange The following plot example features the notorious function sin 1 that osc
129. eye cannot distinguish between different frames if they change with a rate of more than 25 frames per second Thus the number of frames n set for the animation should satisfy n 25 t1 t0 Hence with the default time range TimeBegin tO O TimeEnd t1 10 seconds it does not make sense to specify Frames n with n gt 250 If a higher frame number 1s required to obtain a sufficient resolution of the animated object one should increase the time for the animation by a sufficiently high value of TimeEnd What Can Be Animated We may regard a graphical primitive as a collection of plot attributes Indeed also the function expression sin X in plot Function2d sin X x 0 2 PI is internally realized at the attribute Function sin x So the question is Which attributes can be animated Animations The answer is Almost any attribute can be animated Instead of listing the attributes that allow animation it is much easier to characterize the attributes that cannot be animated None of the canvas attributes can be animated This includes layout parameters such as the physical size of the picture See the help page of plot Canvas for a complete list of all canvas attributes None of the attributes of 2D scenes and 3D scenes can be animated This includes layout parameters background color and style camera positioning in 3D etc See the help pages of plot Scene2d and plot Scene3d for a complete
130. for Center CS3d End the y axis title ZAxisTitleAli Begin Center alignment for Center CS3d End the z axis title YAxisTitleOri Vertical orientation of Horizontal CS2d Horizontal the y axis title AxesTips AxesTips _ TRUE TRUE FALSE TRUE FALSE axes with tips with axes with tips pie C 2d 3d AxesOrigin real value real crosspoint of the value axes 2D AxesOrigin real value real crosspoint of the CS3d value real value AxesOriginX real value x value of NN AxesOrigin AxesOriginY real value y value of D AxesOrigin AxesOriginZ real value z value of CS3d AxesOrigin AxesLineColor RGBcolor color color color of the axes the color of the axes RGB RGB Black cs2d 34 a EUun a physical width M coc M of the axes lines 6 63 6 Graphics and Animations 6 64 attribute name __ possible values browser entry example AxesInFront TRUE FALSE axes in front of FALSE CS2d the objects AxesTitleFont see section font for the axes sans serif 10 CS2d 3d Fonts titles Here is a table of the most important attributes for setting tick marks and tick labels along the axes In the interactive object browser you will find them under CoordinateSystem2d CS2d and CoordinateSystem3d CS3d respectively Attributes for Tick Marks and Tick Labels attribute name __ possible values browser entry example TicksVisible TRUE FALSE visibility of ticks TRUE CS2d 3d along all axes XTicks
131. format the axes of your graphics switch to plot formatting mode and select Coordinate System at the top of the Object Browser pane The bottom of the pane shows axes properties that you can change For example you can add grid lines 1 53 l Getting Started File Edit View Inset Tools Actions Window Help lt a x 0e uUQges k e s8 06029 plot sqrt l x2 y 2 x 1 1 I Canvas 1 54 4 Scene3d 4 d CoordinateSystem3d x Functian3d 4 Grid Lines XGridVisible YGridVisible ZGridVisible GridLineSt GridLine GridLinec XSubqrid a Not Connected Modify Function Plot To format the function plot switch to plot formatting mode and select Function at the top of the Object Browser pane The bottom of the pane shows plot properties that you can change For example you can change the color of a function plot Use Graphics File Edit View Tok Actions Window m plot sqrt l x2 9 2 x 1 1 T3n 4 Canvas a Scene3d 4 i CoordinateSystem3d x Function3d Property b Points 4 Surface Filled FillCol Fill Col FillCol FillCol ee You can use predefined colors or select a color from a more extensive palette 1 55 l Getting Started H Motebookl MuPAD BEA File Edit View Inset Tools Actions Window Help Png AP ng Oi Hest HHGA2QRYe plotisart 1 2 2 lt y 2 x 1 1 fin a Canvas a Scene3d 4 i CoordinateSyste
132. gt lt JPEGMode na gt lt EPSMode n gt lt AVIMode n gt lt WMFMode ng lt FramesPerSecond n lt PlotAt 1 gt Each entry of the list is optional The parameters are b TRUE or FALSE Has an effect for export to some raster formats only With TRUE only 256 different colors are stored in the raster file The default value is FALSE n4 Positive integer setting the resolution in dpi dots per inch Has an effect for export to raster formats only The default value depends on the hardware No One of the integers 1 2 100 This integer represents a percentage value determining the quality of the export Has an effect for jpg 3D eps 3D wmf and avi export only The default value is 75 Ns 0 1 or 2 Has an effect for jpg export only The flag 0 represents the jpg mode Baseline Sequential 1 represents Progressive 2 represents Sequential Optimized The default value is 0 n4 O or 1 Has an effect for eps export only The flag 0 represents the eps mode Painter s Algorithm 1 represents BSP Tree Algorithm The default value is 0 Ns 0 1 or 2 Has an effect for avi export only With 0 the Microsoft Video 1 Codec is used With 1 the Uncompressed Single Frame Codec 1s used With 2 the Radius Cinepak Codec is used The default value is 0 Ne 0 1 or 2 Has an effect for wmf export only With O the Painter s Algorithm is used With 1 the BSP Tree Algorith
133. gt Text Paragraph or Insert gt Text Paragraph Above You cannot insert a text region between adjacent input and output regions You can exchange data between different regions in a notebook For example you can Copy expressions and commands from the text regions to the input regions and evaluate them Copy expressions and commands from the input regions to the text regions Copy results including mathematical expressions and graphics from the output regions to the text regions Copy results from the output regions to the input regions Mathematical expressions copied from the output regions appear as valid MuPAD input commands You cannot paste data into the output regions To change the results edit the associated input region and evaluate it by pressing Enter 1 3 l Getting Started Evaluate Mathematical Expressions and Commands 1 4 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Working in a Single Input Region on page 1 4 Working with Multiple Input Regions on page 1 5 Working in a Single Input Region To evaluate an expression or execute a command in a notebook press Enter 3 2 10 17a 3 9208 3 The results appear in the same grey bracket below the input data By default the commands and calculations you type appear in red color the results appear in blue To suppress the output of a command terminate a command with a colon This allow
134. i t i 1 end for plot myframe i i 0 100 PointSize 5 0 unit mm 0 6 0 4 0 2 0 0 02 04 06 08 10 12 14 16 18 20 22 24 26 28 3 0 2 X 0 4 0 6 0 8 1 0 e 6 145 6 Graphics and Animations 6 146 This frame by frame animation certainly needs a little bit more coding effort than the equivalent objectwise animation where each of the points is animated delete i plot plot Point2d i 100 PI sin i 100 PI i 0 100 Color RGB Red plot Point2d 1i 100 PI cos i 100 PI i Color RGB Blue Frames 101 TimeRange 0 10 PointSize 5 0 unit mm 0 100 0 2 0 0 02 04 06 08 10 12 14 16 18 20 22 24 26 28 3 0 0 2 x 0 4 0 6 0 8 4 0 o There 1s however a special kind of plot where frame by frame animations are very useful Note that in the present version of the graphics new plot objects cannot be added to a scene that 1s already rendered With the special visibility animations for static objects however one can easily simulate a plot that gradually builds up Fill the frames of the animation with static objects that are visible for a limited time only The visibility can be chosen very flexibly by the user For example the static objects can be made visible only for one frame VisibleFromTo so that the objects seem to move In the following example we use VisibleAfter to fill up the plot gradually We demonstrate the caustics generated by sunl
135. identifiers f i proc x option remember begin if testtype x Type Rational then x else genident end if end Modify Subexpressions misc maprec a 5 b PI sqrt 2 c PI ex gt bool freeIndets ex f a NM6 55 X6X7c option remember in f ensures that constants appearing multiple times always get the same identifier Moreover you can access the remember table of the procedure f and select which substitutions you want to make select op op f 5 _not bool x 2 X6 4 2 X7 5 157 5 Programming Fundamentals Variables Inside Procedures 9 158 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Closures on page 5 158 Static Variables on page 5 160 Closures When you call a procedure MuPAD allocates memory for the local variables marks them as uninitialized and evaluates the body of the procedure At the end of a procedure call MuPAD destroys local variables freeing the allocated memory Now suppose that the result of a procedure call refers to local variables of that procedure For example the returned value of this procedure refers to its local variable z T q proc x y local z begin Zi Xxty j return Z end In this case the variable z is replaced by its value at the end of the procedure call Therefore the returned value of the procedure is the value of the variable z not the variable z itself T 1 2
136. in the MuPAD Notebook Interface This functionality does not run in MATLAB The outliers are data points located far outside the range of the majority of the data Glitches data entry errors and inaccurate measurements can produce outliers in real data samples The outliers can significantly affect the analysis of data samples If you suspect that the data that you want to analyze contains outliers you can discard the outliers or replace them with the values typical for that data sample Before you discard or replace the outliers try to verify that they are actual errors The outliers can be a part of the correct data sample and discarding them can lead you to incorrect conclusions If you cannot determine whether the outliers are correct data or errors the recommended strategy is to analyze the data with the outliers and without them To discard outliers use the stats cutoff function For example discard the outliers with the values smaller than the 1 10 quantile 10th percentile and larger than 9 10 quantile of the list x X t 17100 1 2 3 4 B 6 7 8 9 100 stats cutoff x 1 10 1 2 3 4 5 6 7 8 9 To replace the outliers with the value of a k th quantile use the stats winsorize function In the list x replace the values of the outliers with the 10th and 90th percentiles stats winsorize x 1 10 L 1 2 3 4 5 6 7 8 9 9 Bin Data Bin Data Note Use only in the MuPAD Notebook Interf
137. inner procedures The inner procedures use the same local variable of the outer procedure For inner procedures that variable is not local and therefore it does not reset its value proc local x y option escape begin X I y i f g i end proc gt x t x y Ix yl gt y y n X yl 0 0 n C 9 161 5 Programming Fundamentals F g 2 F f 5 162 Utility Functions Utility Functions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Utility Functions Inside Procedures on page 5 163 Utility Functions Outside Procedures on page 5 164 Utihty Functions 1n Closures on page 5 165 Utility Functions Inside Procedures You can define utility functions inside a procedure For example define the utility function helper inside the procedure f T proc arguments local helper begin helper D OC begin end code using helper end The helper function is not visible or accessible outside f Your users cannot see the helper function and therefore they do not rely on a particular 1mplementation of this procedure You can change its implementation without breaking their code At the same time helper can access and modify arguments of f The major disadvantage of this approach 1s that your test files cannot access helper directly Since it 1s typically recommended to start testing at the smalle
138. is overwritten assign For further computations remove protection from the identifier lucas unprotect lucas 9 141 5 Programming Fundamentals Data Collection 9 142 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Parallel Collection on page 5 142 Fixed Length Collection on page 5 144 Known Maximum Length Collection on page 5 145 Unknown Maximum Length Collection on page 5 146 Parallel Collection Suppose the data that you want to collect is generated element by element and you know in advance how many elements will be generated The intuitive approach for collecting such data is to create an empty list and append each new element to the end of the list For example this procedure uses this approach to collect random integers generated by random col proc n local L i begin L Hh for i from 1 to n do L L random end for end The procedure generates random integers and collects them in a list col 5 427419669081 321110693270 343633073697 474256143563 558458718976 To estimate the performance of this approach use the procedure col to generate a list of 50 000 random numbers Data Collection time col 50000 9828 063 The time function returns results measured in milliseconds Now check how much time the procedure actually spends generating random numbers time random i 1 50000 312 02 Thus
139. iszero function checks whether all elements of a matrix are zeros A matrix 2 2 iszero A A 1 1 1 iszero A FALSE The norm function computes the infinity norm row sum norm of a matrix A t matrix 2 2 a 1 1 a1 2 a 2 1 2 2 norm A max 2 25 5 55 Compute with Matrices The zip A B f function combines matrices A and B into a matrix C so that C f Ay Dij matrix 2 2 ay b c d J i matrix 2 2 10 20 30 40 Zip A B power F Hc k 520 d fo 3 187 3 Mathematics Compute Determinants and Traces of Square Matrices 3 188 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD provides the functions for performing many special operations on matrices You can compute the dimensions of a matrix swap or delete columns and rows or transpose a matrix For square matrices you can compute determinants and traces To compute the determinant of a square matrix use the det function For example compute the determinant of the following 2x2 matrix A matrix 2 2 a b c d det A ad bc Now compute the determinant of the 12x12 Hilbert matrix det linalg hilbert 12 l 3791065 7943630451715188547903479639188018808 7864118464104324304732 160000000000 To compute a sum of the diagonal elements of a square matrix the trace of a matrix use the linalg tr function For example the trace of the ma
140. lasts Statistical samples stats sample This data structure is specifically designed for statistical data Using sets tables arrays vectors and matrices 1s less convenient You cannot use these data containers as input parameters for most functions of the Statistics library To use these functions on data stored 1n sets tables arrays vectors or matrices transfer the data to lists or statistical samples Compute Measures of Central Tendency Compute Measures of Central Tendency Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Measures of central tendency locate a distribution of data along an appropriate scale There are several standard measures of central tendency Knowing the properties of a particular data sample such as the origin of the data sample and possible outliers and their values can help you choose the most useful measure of central tendency for that data sample MuPAD provides the following functions for calculating the measures of central tendency The stats modal function returns the most frequent value of a data sample and the number of occurrences of that value The stats mean function calculates the arithmetic mean i 1 ep n ofa data sample x xs Xp m Q7 i l The stats quadraticMean function calculates the quadratic mean l nu xj of a data sample x xs Xn n deli The stats median function returns t
141. main menu or use the context menu 3 Inthe Edit Hyperlink dialog box edit the link You can change the display text or the link target or both 2 56 Work with Links Display text First Order ODEs Link to li Second Motebook mnstargeti Use absolute path instead of relative path Browse and select Existing File Document Current documents x Targets amp First Notebook mn Internet Second Motebook mn Delete Links To delete a link 1 Select the link that you want to delete 2 Right click to open the context menu 3 Select Remove Link Alternatively you can use the Edit Hyperlink dialog box to delete a link To delete a link by using the Edit Hyperlink dialog box 1 Select the link that you want to edit 2 Select Edit gt Link from the main menu or use the context menu 2 57 2 Notebook Interface 2 58 3 Inthe Edit Hyperlink dialog box click the Remove Link button 4 Click OK Delete Link Targets If the list of link targets 1s very long finding the correct link target can be difficult To make this list shorter delete link targets that you do not use To delete a link target 1 Find the link target in a notebook To highlight all link targets in a notebook select View gt Highlight Link Targets 2 Select the link target that you want to delete 3 Select Insert gt Link Target from the main menu or use the context menu 4 Inthe Edit Link Target dialog b
142. matrix A as follows P A L U Here L is an mXm lower triangular matrix that contains 1s on the main diagonal U is an mxn matrix upper triangular matrix and P 1s a permutation matrix To compute the LU decomposition of a matrix use the linalg factorLU function For example compute the LU decomposition of the following square matrix A matrix O 0 1 1 2 3 0 1 2 L U p Linalg factorLU A d 123X 0 01 2 2 3 1 0 001 Instead of returning the permutation matrix P MuPAD returns the list p with numbers corresponding to row exchanges in the matrix A For an nXn matrix the list p represents the following permutation matrix with indices i and j ranging from 1 to n Using this expression restore the permutation matrix P from the list p P matrix 3 3 for i from 1 to 3 do Pli pill 1 end for P UU II D C LL oreo EN Compute LU Factorization More efficiently compute the result of applying the permutation matrix to A without restoring the permutation matrix itself PA matrix 3 3 for i from 1 to 3 do PA i Teas A p i 1 3 end_for PA X The product of the lower triangular matrix L and the upper triangular matrix U 1s the original matrix A with the rows interchanged according to the permutation matrix P Lad a s ps C m ba I EB testeq PA L U TRUE Now compute the LU decomposition for the 3 X2 matrix B B matrix 1 2 3 4
143. mesh points via the Submesh attribute plotfunc3d sin x 2 y 2 x 3 3 y 3 3 Submesh 3 3 The following call specifies a header via Header The function sin x y 2 Grid lines attached to the ticks are switched on by GridVisible TRUE and SubgridVisible TRUE plotfunc3d sin x y 2 x 2 PI 2 PI y 2 2 Header The function sin x y 2 GridVisible TRUE SubgridVisible TRUE 6 52 Easy Plotting Graphs of Functions The function sin x y 2 When singularities are found in the function an automatic clipping 1s called trying to restrict the vertical viewing range in some way to obtain a reasonably scaled picture This is a heuristic approach that sometimes needs a helping adaptation by hand In the following example the automatically chosen range between z 0 and z 0 8 in vertical direction is suitable to represent the pole at x 1 y 1 but it does not provide a good resolution of the pole atx 1 y 1 plotfunc3d 1 x 1 2 1 2 x 1 2 y 1 2 5 y 2 3 y 2 3 Submesh 3 3 Y 6 53 6 Graphics and Animations 6 54 There is no good viewing range that is adequate for both poles because they are of different order We override the automatic viewing range suggested by plotfunc3d and request a specific viewing range in the vertical direction via ViewingBoxZRange plotfunc3d 1 x 1 2 y 1 2 x 1 2 y 1 2
144. model For example modify the data from the previous example by adding small random floating point values to the entries of the list y Then perform linear regression for the entries of the lists X and y1 and plot the data yl y 10 frandom i 1 10 stats linReg x y1 plot plot Scatterplot x y1 13 43518739 2 077876934 76 58789632 Univariate Linear Regression The fact that stats linReg finds a linear model to fit your data does not guarantee that the linear model is a good fit For example you can find a linear model to fit the following uniformly distributed random data points x frandom i y frandom i stats linReg x y plot plot Scatterplot x y 1 100 144100 0 4005452605 0 2002242944 272613418 3 301 3 Mathematics 0 8 0 6 OF o 6 0 5 0 4 0 3 0 2 0 1 0 0 0 0 0 1 0 2 e e e s oe Vt e E tea e e r e Ha s e ki ee E s es E ee i The large value of the quadratic error indicates that the linear model is a poor fit for these data delete x y yl 3 302 Univariate Nonlinear Regression Univariate Nonlinear Regression Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Nonlinear regression can assume any type of relationship between the dependent variable y and independent variables x For nonlinear regres
145. most conversions but it can fail in some cases Calling the constructor of the required domain 1s often the simplest way to convert an object to the element of that domain Suppose you want to convert the following list L to a matrix L 1 2 3 4 5 6 To convert a list to a matrix call the matrix constructor matrix Use the arguments of the matrix constructor to specify the dimensions of the required matrix and the list L of the elements of a matrix The resulting object is the 2x3 matrix of the domain Dom Matrix matrix 2 3 L domtype t A Lu a CH Dom Matrix Alternatively you can convert a list to a matrix by using Dom Matrix Dom Matrix 2 3 L domtype 35 A E F i 1 4 LO 3 Dom Matrix 5 47 5 Programming Fundamentals For further computations delete the identifier L delete L 9 48 Define Your Own Data Types Define Your Own Data Types Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD provides many predefined domains for a wide variety of symbolic and numeric computations The system is also extensible If the predefined MuPAD domains do not satisfy your needs you can create your own domains and define operations on their elements Also MuPAD allows you to change the existing library domains although this approach is not recommended To create a new domain use the newDomain function For exam
146. must also belong to the domain TempF TempF plus proc local elements begin elements map args op 1 1 new TempF _plus op elements end proc The system add the elements of your new domain the same way as it adds numbers The system also displays the degrees Fahrenheit unit for the resulting sum TempF 75 TempF 10 85 amp deg F For further computations delete the identifier x delete x 9 51 5 Programming Fundamentals Access Arguments of a Procedure 9 02 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The terms parameters and arguments are often used interchangeably Strictly speaking the term parameters means object names that you specify while defining a procedure The term arguments means objects that you use while calling a procedure This documentation also uses the term formal parameters for parameters and the term actual parameters for arguments Many programming languages require the number of parameters to be equal to the number of arguments MuPAD does not have this requirement Therefore you can call a procedure with the number of arguments different from the number of specified parameters If you call a procedure using fewer arguments than parameters the system treats additional parameters as additional local variables without specified values If you call a procedure using more arguments than parameters the system does not disregard t
147. not have a unique representation e g there is more than one 8 17 8 More Information About Some of the MuPAD Libraries 8 18 representation of zero You can normalize the components of such a matrix A with the command map A normal The library Dom offers standard coefficient domains such as the field of rational numbers Dom Rational the ring of integers Dom Integer the residue classes of integers Dom IntegerMod n for an integer n or even the rings of polynomials such as Dom DistributedPolynomial ind R or Dom Polynomial R where ind is the list of variables and R 1s the coefficient ring A domain created by the domain constructor Dom SquareMatrix represents the ring of square matrices over a specified coefficient domain Dom SquareMatrix expects the number of rows of the square matrices and optionally a coefficient ring of category Cat Rng There are several possibilities to define matrices of a domain created by Dom Matrix or Dom SquareMatrix A matrix can be created by giving a two dimensional array a list of the matrix components or a function that generates the matrix components delete a b c d A matrix a b c d ab c d The command matrix actually is an abbreviation for the domain Dom Matrix To create diagonal matrices one should use the option Diagonal the third argument of matrix is either a function or a list B matrix 2 2 2 2 Diagonal
148. of plot Conformal for details 6 13 6 Graphics and Animations 1 0 0 8 0 6 i M 0 4 NM A M MM 0 2 YAN 0 0 06 04 D2 0 8 1 0 The following picture shows some elliptic curves generated as a contour plot See the Implicit2d for details examples on the help page of plot 6 14 Gallery The following picture shows the Feigenbaum diagram of the logistic map See the examples on the help page of plot PointList2d for details 6 15 6 Graphics and Animations 0 9 0 6 OF 0 6 0 5 0 4 0 3 0 2 0 1 0 0 28 29 30 31 32 33 34 35 36 37 38 39 40 X The following picture shows a fractal object generated by a turtle plot of a Lindenmayer system See the examples on the help page of plot Lsys for details 6 16 Gallery 3D Functions Surfaces and Curves where The following picture demonstrates a 3D function plot of f x y ih x y J z 1s the Bessel function of the first kind See the examples on the help page of plot Function3d for details 6 17 6 Graphics and Animations The following picture demonstrates a 3D function plot enhanced by a coordinate grid See the examples on the help page of GridVisible for details 6 18 Gallery The following picture demonstrates a 3D function plot of 1 32 y which is not real for some parts of the parameter space See the documentation of plot Function3d for d
149. of the moving points We obtain the following graphical solution the computation takes about two minutes on a 1 GHz computer dt 0 05 imax lt 518 plot The sun plot Point2d Y t 1 Y t 3 Color RGB Orange VisibleFromTo t t 0 99 dt PointSize 4 unit mm t in i dt i O imax The giant planet plot Point2d Y t 5 Y t 7 Color RGB Red VisibleFromTo t t 0 99 dt 6 155 6 Graphics and Animations PointSize 3 unit mm t in i dt i O imax The orbit of the giant planet plot Line2d Y t dt 5 Y t dt 7 Y t 5 Y t 7 Color RGB Red VisibleAfter t t in i dt i 1 imax The small planet plot Point2d Y t 9 Y t 11 Color RGB Blue VisibleFromTo t t 0 99 dt PointSize 2 unit mm t in i dt i O imax The orbit of the small planet plot Line2d Y t dt 9 Y t dt 11 Y t 9 Y t 11 Color RGB Blue VisibleAfter t t in i dt i 1 imax 0 5 0 4 0 3 0 2 0 1 0 2 6 156 Groups of Primitives Groups of Primitives Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB An arbitrary number of graphical primitives in 2D or 3D can be collected in groups of type plot Group2d or plot Group3d respectively This is useful for inheriting attribute values to all elements in a group In the following example we visualize random generators
150. of the general simplifiers simplify 2 fresnelS z fresnelS z S z Particular values of parameters can reduce more general special functions to expressions containing simpler special functions For example reduce mei j erG to the hypergeometric functions Simplify meijerG 1 3 1 3 3 2 0 2 3 4 3 2 3 109 3 Mathematics 3 110 j 3 V 7L F y F T z 2 V 7L V zl The following choice of parameters expresses meijerG in terms of the Bessel functions simplify meijerG 1 111 z zJ o vz Expand Expressions Involving Special Functions MuPAD supports expansions of expressions containing special functions The resulting expressions can involve the original or additional special functions or both For example the expand command expresses the beta function by gamma functions beta x 1 y expand beta x 1 y x T x T Piy x 1 xl ix y j yl x y When you expand the gamma function MuPAD expresses it in terms of gamma functions gamma 5 x 1 expand gamma 5 x 1 z3 x v X r x 1 r x 2 r x 2 T x 3 T x Verify Solutions Involving Special Functions When solving equations especially ordinary differential equations you often get the results in terms of special functions For example consider the following differential equation Convert Expressions Involving Special Functions eq diff y x x x
151. output region Click OK to apply the new default settings and close the Default Formats dialog box 2 31 2 Notebook Interface Use Frames Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If you want to format different parts of a notebook separately use frames Frames can include text mathematical expressions and commands To insert a frame Select the place where you want to insert a frame 2 Select Insert gt Frame 2 32 Use Frames File Edit View Navigation Format Notebook Ld A la gh E TE Calculation i Calculation Above Piecewise solul TetParagraph Text Paragraph Abowe The solution of the quadrat a T Link symbolic parameters and ink aa Piecewise objects often o the variable Image Table Fram solve a x 2 b x iE eee f b b 4ac _ b 4 Line Break 2a File Path if a204520 Ctrl I Ctrl Shift I Ctrl T Ctrl Shift T Here a b and c are eters in addition to Ctrl Enter if a O0Ab 0ac 0 if a204b5b20 cse0 Insert frame at the current cursor position Mem 8 MB TOs 3 Dragthe selected part into the frame 2 33 2 Notebook Interface File Edit View Wavigation Insert Format Notebook Window Help rem lal A eg U E Q TU 4 Q n2 Generic Sans Serif Command Bar Piecewise solutions DENM ae iJ nf ax roa F The solution of the quadratic equation a x bx c 0is piecewise Here a b
152. plot plot plot plot plot plot Canvas Scene2d Scene3d CoordinateSystem2d CoordinateSystem3d Groupad Group3d drawing area container for 2D or 3D scenes container for 2D coordinate systems container for 3D coordinate systems container for 2D primitives and plot Group2d container for 3D primitives and plot Group3d group of primitives in 2D group of primitives in 3D Primitives or groups of primitives can be transformed by the following routines plot plot plot plot plot plot plot plot plot plot Scale2d Scale3d Ref lect2d Ref lect3d Rotate2d Rotate3d Translate2d Translate3d Transform2d Transform3d scaling transformation 1n 2D scaling transformation 1n 3D reflection in 2D reflection in 3D rotation in 2D rotation in 3D translation in 2D translation in 3D general linear transformation in 2D general linear transformation in 3D The following special plot routines are provided plot plot plot plot Cylindrical Polar Spherical Tube Additionally there are plot Camera cylindrical plot in 3D polar plot 1n 2D polar plot 1n 3D tube plot in 3D camera in 3D Primitives plot ClippingBox clipping box in 3D 6 107 6 Graphics and Animations Attributes 6 108 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Default Values on page 6
153. programming tasks but it 1s recommended wherever you can apply it It 1s the simplest and most readable approach to get the calling by reference effect in MuPAD Closures in Objects When working with domains you also can use the approach of having the actual data in a closure For example instead of storing the actual data 1n the objects you can store functions that access the data domain d local get set inherits Dom BaseDomain new proc x option escape begin new dom gt x y gt x y end incr x gt set x get x 1 print x gt get x begin get x gt extop x 1 set x y gt extop x end domain 2 y e d 4 d incr e Calls by Reference and Calls by Value LA LA See Closures for more details Domains in Objects You can implement the calling by reference approach in your code by using domains as tables with reference effects Using domains as tables is unrelated to object oriented programming The following example demonstrates this strategy domain dd local get set inherits Dom BaseDomain new proc x local d begin d newDomain genident d number x new dom d end get x entry gt slot extop x 1 entry set x entry value gt slot extop x 1 entry value incr x gt dom set x number dom get x number 1 x print x gt dom get x number end domain e d
154. provides the name that labels the horizontal axis Functions can also be defined by piecewise objects plotfunc2d piecewise x lt 1 1 x 1 lt x and x lt 2 1 2 xX gt 2 2 x X 2 3 6 28 Easy Plotting Graphs of Functions 2 0 1 5 1 0 0 5 0 5 1 0 14 2 0 25 3 0 1 Note that there are gaps in the definition of the function above no function value is specified for x 1 and x 2 This does not cause any problem because plotfunc2d simply ignores all points that do not produce real numerical values Thus in the following example the plot 1s automatically restricted to the regions where the functions produce real values plotfunc2d sqrt 8 x 4 1n x 3 2 x 1 x 2 2 6 29 6 Graphics and Animations 6 30 e mE 20 las 40 0 5 5 1 0 15 20 E x l 4 l l l l l 4 l l l i l l E 2 x 17 72 aee inx 3 2yWix 1 When several functions are plotted in the same scene they are drawn in different colors that are chosen automatically With the Colors attribute one may specify a list of RGB colors that plotfunc2d shall use plotfunc2d x x 2 x 3 x 4 x 5 x 0 1 Colors RGB Red RGB Orange RGB Yellow RGB BlueLight RGB Blue Easy Plotting Graphs of Functions Animated 2D plots of functions are created by passing function expressions depending on a variable x say and an animation parameter a say and speci
155. r g b lists provided by the color names The easiest way to do this is to append the list a to the RGB list via the concatenation operator We create a semitransparent grey RGB Grey 0 5 0 752907 0 752907 0 752907 0 5 The following command plots a highly transparent red box containing a somewhat less transparent green box with an opaque blue box inside plot plot Box 3 3 3 3 3 3 FillColor RGB Red 0 2 plot Box 2 2 2 2 2 2 FillColor RGB Green 0 3 plot Box 1 1 1 1 1 1 FillColor RGB Blue LinesVisible TRUE LineColor RGB Black Scaling Constrained 6 173 6 Graphics and Animations In the following example we plot points randomly distributed with random colors and random translucencies plot plot PointList2d frandom i 1 2 frandom i 1 4 i 1 3001 PointSize 4 Axes None Scaling Constrained sete gt 09 gt HSV Colors Apart from the RGB model there are various other popular color formats used in computer graphics One is the HSV model Hue Saturation Value The RGB library provides the routines RGB f romHSV and RGB toHSV to convert HSV colors to RGB colors and vice versa hsv RGB toHSV RGB Orange 24 0 1 0 1 0 RGB fromHSV hsv RGB Orange 6 174 Colors 1 0 0 4 0 0 1 0 0 4 0 0 With the RGB f romHSV utility all colors in a MuPAD plot can be specifi
156. recursion formula that defines the nth Lucas number is similar to the definition of the Fibonacci numbers Ly 1 2 3 L LL 4 7 1 Although MuPAD does not provide a function that computes the Lucas numbers writing your own procedure for this task 1s easy lucas proc n Type PosInt begin if n 1 then 1 elif n 2 then 3 else lucas n 1 lucas n 2 end if end proc The procedure call lucas n returns the nth Lucas number For example display the first 10 Lucas numbers 9 81 5 Programming Fundamentals 9 82 lucas n n 1 10 l 3 4 7 11 18 29 47 76 123 Suppose you want to trace this procedure To switch execution of a particular procedure domain method or function environment to the tracing mode use the prog trace function For example to trace the lucas procedure enter prog trace lucas Now if you call the lucas procedure the trace mechanism observes every step of the procedure call and generates the report for that call lucas 5 enter lucas 5 enter lucas 4 enter lucas 3 enter lucas 2 computed 3 enter lucas 1 computed 1 computed 4 enter lucas 2 computed 3 computed 7 enter lucas 3 enter lucas 2 computed 3 enter lucas 1 computed 1 computed 4 computed 11 11 The prog traced function call returns the names of all currently traced procedures domains methods and function environments prog traced lucas Debug MuPAD Code in the Tracing
157. reverse order of unknowns used as a tie break 1 e the monomial that is lexicographically smaller if the order of variables 1s reversed 1s considered the bigger one this one 1s denoted by DegInvLexOrder user defined orderings They constitute a domain Dom MonomOrdering of their own Orderings always refer to the order of the unknowns of the polynomial e g x is lexicographically bigger than y in F x y but smaller than y when regarded as an element of F y x The import Library The import Library Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The import library provides functions for importing external data into MuPAD The package functions are called using the package name import and the name of the function E g use import readdata datafile for reading external data from the file datafile This mechanism avoids naming conflicts with other library functions If this is found to be inconvenient then the routines of the import package may be exported via use E g after calling use import readdata the function import readdata may be called directly readdata datafile All routines of the import package are exported simultaneously by use import The functions available 1n the import library can be listed with info import 8 11 8 More Information About Some of the MuPAD Libraries Integration Utilities 8 12 Note Use only in the MuPA
158. roots of a polynomial You can use the expressions containing RootOf in your further computations For example find the sum over all roots of the polynomial sum S 2 S 2 S in RootOf X 5 2 X 1 X 10 3 31 3 Mathematics 3 32 To get the numeric approximation of the roots use the float command float RootOf X 4 X 1 X 1 0 7271360845 0 4300142883 1 0 7271360845 0 4300142883 L 0 7271360845 09340992895 1 0 7271360845 0 9340992895 i For more details on numeric approximations see Solving Equations Numerically For univariate polynomial equations MuPAD also can compute intervals containing the real roots See Isolating Real Roots of Polynomial Equations Find Multiple Roots By default the solve command does not return the multiplicity of the roots When the solution of an equation contains multiple roots MuPAD removes duplicates solve x 2 6 x 9 O x put t The solver does not display multiple roots because it returns results as a set A set in MuPAD cannot contain duplicate elements To obtain polynomial roots with their multiplicities use the option Multiple solve x 2 6 x 9 0 x Multiple solve x 1 3 x 2 7 x Multiple Isolate Real Roots of Polynomial Equations For some polynomial equations the solver cannot return the explicit symbolic solutions p x 5 81 x 4 32 32 x 3 33 33 x 2 34 34 x 35 35 36 solve p x Solve Algebraic Equatio
159. s Cmd A amp INS 3 Inthe appropriate fields of the Frame Format dialog box type the size of left margin frame border size width of the left bracket that encloses the input region and background color 2 35 2 Notebook Interface EU wath 52 92 mm 0 00 mm Border 0 14 mm Padding 2 01 mm Background 4 Click OK to apply the new frame settings and close the Frame Format dialog box 2 36 File Edit View Wavigation Insert Format Notebook Window Help Generic Sans Serif BUVA U300m2 009 Piecewise solutions z Jf ax yok f fu The solution of the quadratic equation a x bx c 0is piecewise Here a b and c are symbolic parameters and x is a symbolic variable Mem 8 MB TOs Use Frames uf iva F Fg HJ a 6 2 37 2 Notebook Interface Use Tables Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Tables on page 2 38 Add and Delete Rows and Columns on page 2 40 Format Tables on page 2 41 Create Tables To insert a table in a notebook 1 Select the place where you want the table to appear 2 Select Insert gt Table 2 38 File Edit View Wavigation Format Notebook d W o d AZ Calculation i Calculation Above Piecewise solul Tet Paragraph Text Paragraph Above The solution of the quadrat ba T Link symbolic parameters and ink tance Piecewise objects often o the variable Image Fra
160. same mean and the same variance To create a quantile quantile plot use the plot QQplot function For example create the data samples data1 and data2 that contain random floating point numbers from the interval 0 0 1 0 Use the f random function to create the data1 sample Use the stats uniformRandom function to create the data2 sample Both functions produce uniformly distributed numbers The quantile quantile plot of these two data samples confirms that the samples come from the same distribution family The plot is close to the line with a slope of 1 data1 frandom i 1 100 data2 stats uniformRandom O 1 k 1 100 p plot QGQplot data data2 plot p Create Quantile Quantile Plots 0 8 0 8 0 7 e 0 6 0 5 0 4 0 3 p pt 02 x 0 1 T d 0 0 The following quantile quantile plot clearly shows that these two data samples come from different distribution families datal stats uniformRandom O 1 data2 stats exponentialRandom O p plot QGQplot data data2 plot p eae 100 k 1 3 297 3 Mathematics 3 298 0 0 0 5 1 0 1 5 25 3 5 40 Univariate Linear Regression Univariate Linear Regression Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Regression is the process of fitting models to data Linear regression assumes that the relationship between the dependent variabl
161. samples or to show how individual elements contribute to an aggregate amount use bar charts A bar chart represents each element of a data sample as one bar Bars are distributed along the horizontal or vertical axis with each data element at a different location To compare data samples create a bar chart for two or more data samples In this case MuPAD accesses elements with the same index and plots the bars for these elements next to each other For example create three lists of random numbers x frandom i 1 10 y frandom i 1 10 z frandom i 1 10 0 2703581656 0 8310371787 0 153156516 0 9948127808 0 2662729021 0 1801642277 0 452083055 0 6787819563 03549849261 0 6818588132 0 7219186551 0 4738297742 0 7889814922 0 2115258358 0 8556871754 0 044897394 0 8791601269 0 9193848479 0 7350574234 0 7875450269 3 285 3 Mathematics 3 286 0 9371484273 0 2953238727 0 9334772314 0 9362730734 0 5910800883 0 6358075032 0 4285065377 0 2939293408 0 1940618534 0 4678382754 To create a 2 D bar chart use the plot Bars2d function The chart displays data from the data samples X y and z The resulting plot shows the elements with the same index clustered together Small gaps separate each group of elements from the previous and the next group plot plot Bars2d x y z To create a 3 D bar chart use the plot Bars3d function This function accepts matrices and arrays
162. set the value of Pref report to 4 MuPAD displays a few status messages while executing these operations Pref report 4 sort random i 1 10 7 used 167852k reserved 168579k seconds 30 used 294614k reserved 295370k seconds 60 used 421376k reserved 422161k seconds 90 If you increase the value of Pref report to 6 MuPAD prints the status messages more frequently Pref report 6 sort random i 1 10 7 used 84035k reserved 84661k seconds 10 used 126987k reserved 127664k seconds 21 used 169940k reserved 170600k seconds 32 used 212892k reserved 213537k seconds 43 used 255844k reserved 256540k seconds 54 used 298797k reserved 299476k seconds 65 used 341749k reserved 342413k seconds 76 used 384701k reserved 385416k seconds 87 used 427654k reserved 428352k seconds 98 used 470606k reserved 471355k seconds 109 Every time you execute this example MuPAD adds a new list of 10 random numbers and stores that list in the history table By default the history table contains up Display Memory Usage to 20 elements While this list remains in the history table MuPAD cannot release the memory needed to store 10 integers To release this memory use one of these alternatives Continue computations waiting until MuPAD writes 20 new elements to the history table Performing computations with a reduced amount of available memory can be very slow Termin
163. several cameras can be installed simultaneously in a scene cameral plot Camera 3 cos a 3 Sin a 1 cos 2 a 0 0 0 PI 3 a 0 2 PI Name Camera 1 camera2 plot Camera 2 cos a 2 sin a 2 cos 2 a O 0 0 PI S a 0 2 PI Name Camera 2 plot plot Function3d sin x y 3 x 1 1 y 1 1 cameral camera2 6 185 6 Graphics and Animations Per default the first camera produces the view rendered After clicking on another camera in the object browser of the viewer see section Viewer Browser and Inspector Interactive Manipulation the selected camera takes over and the new view is shown 6 186 Cameras in 3D fy Notebooki MuPAD l siasa eraoo rih e x mz iuo e A 3 rlMb pis l plot plot Function3d sin x y 3 x 4 Object Browser El f Canvas Fl t Scene3d d CoordinateSyst e x Function3d Aa Camera i 2 BH Camera 2 Property Value E Definition Mame hal amera 2 OrthogonaDefrnitian Position 2 cos a Position 2 sin a i Posiionz cos 2 a i FocalPointX 0 i FecalPointY 0 i FocalPoint O ie ViewingAngle 1 3 PI i UpVectorX 0 0 UpMectorY 0 0 F cameral camera2z Next we have a look at a more appealing example the so called Lorenz attractor The Lorenz ODE is the system pv x E E ES gt XZ4FX y 7 xy bz with fixed para
164. sin a type a b plus mult and sm equal If an operator or a function has a type slot the type function returns the string value stored in that slot For example the type slot of the addition operator contains the string value plus the type slot of the multiplication operator contains mult the type slot of the sine function contains sin and so on An expression can include more than one operator Typically MuPAD associates the expression type of such expressions with the lowest precedence operator If you visualize an expression as an expression tree the lowest precedence operator appears at the root of that tree See Visualizing Expression Trees for more information For example consider the expression a b c When evaluating this expression the system performs multiplication and then performs addition Therefore the addition operator 1s the lowest precedence operator in the expression This operator determines the expression type type a b c plus If the lowest precedence operator in the expression does not have a type slot the type function returns the string function type f a 2 a 2 Data Type Definition function The domtype and type functions return the same results for elements of most MuPAD domains domtype 5 7 type 5 7 domtype 1 2345 type 1 2345 domtype a type a DOM RAT DOM RAT DOM FLOAT DOM FLOAT DOM IDENT DOM IDENT
165. solve eqni eqn2 a b solve sin a cos 5 a b cos 5 sim a a 5 For numeric approximations of the solutions of the nonlinear system of equations use the numeric fsolve The numeric solver returns only one solution numeric fsolve eqni eqn2 a b a 221 473252 b 0 009030067696 Note When numeric fsolve finds one solution it stops looking for other solutions When you solve an arbitrary nonlinear system numerically there is no general way to find all solutions For more information see Solving Equations Numerically 3 43 3 Mathematics Solve Ordinary Differential Equations and Systems 3 44 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB General Solutions on page 8 44 Initial and Boundary Value Problems on page 3 46 Special Types of Ordinary Differential Equations on page 3 47 Systems of Ordinary Differential Equations on page 3 49 Plot Solutions of Differential Equations on page 3 51 General Solutions An ordinary differential equation ODE contains derivatives of dependent variables with respect to the only independent variable If y is a dependent variable and x is an independent variable the solution of an ODE is an expression y X The order of the derivative of a dependent variable defines the order of an ODE The solution of a single explicit first order ODE can always be computed by in
166. solve o inlx 2xi D e ni If you explicitly specify the type as Bernoulli the solver returns another form of the result 02 solve o Type Bernoulli In x 2xi re ru _ e C2x 2xEi 1 2xi i Check the equality of these two solutions by calling the testeq command for each pair of the solutions Remember that testeq cannot compare sets testeq o1 1 o2 1 testeq o1 2 o2 2 If Results Differ from Expected TRUE FALSE The second solution returns FALSE because testeq does not know that C2 and C3 are arbitrary constants When you explicitly assume the equality of the constants testeq confirms that the solutions are mathematically equal testeq o1 1 02 1 assuming C1 C2 testeq o1 2 o2 2 assuming C1 C2 TRUE TRUE Arbitrary Constants Representing Different Expressions Verifying mathematical equality of the results by assuming that the arbitrary constants are equal does not always work The solver can choose arbitrary constants to represent different expressions For example one form of a solution can include C7 and another form of the same solution can include e In this case you need to assume that C1 eX If the results include arbitrary constants the number of elements in a solution set can depend on the form in which MuPAD returns the results For example if you specify the type of the following ordinary differential equation as Chini the solver returns three separate solut
167. solver BAN i increases performance ffi f gt Maf The solver recognizes the following values of Ode Tyne Abel Abel differential equation Help about The men M ac Bernoulli Bernoulli differential equation Chini Chini differential equation Clairaut Clairaut differential equation Undo ExactFirstOrder exact first order ordi ExactSecondOrder exact second orde Homogeneous homogeneous first ord Lagrange Lagrange differential equatia Riccati Riccati differential equation Interactive link to this point s Ex b b T Redo Example 1 Select Contents Suppose you want to solve an ordinary differential e Select Region equations Delete Output o ode y x 1 x 2 I y x r Plot Commands E Create link General Math aolve o 0 1 X3 Insert link interactively glnl 2 xi c30 2 Eil 2xiji zt Linktarget Characters The solver recognizes the type of the equation and Paragraph equations To improve performance you can explicit Exe solve o Type Bernoulli Ari Ari Q d S C31x 14 2x 1 El 2x1i i Mot Connected Insert Links to Arbitrary Files To insert a link to any file on your computer 1 Select the part of a notebook where you want to insert a link 2 Select Insert gt Link from the main menu or use the context menu 3 Inthe Create Hyperlink dialog box select Existing File 2 53 2 Notebook Interface 4 Select the file you want t
168. test A typical value of a significance level is 0 05 P values below a significance level provide strong evidence for rejecting the null hypothesis 3 309 3 Mathematics Perform chi square Test 3 310 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For the classical chi square goodness of fit test MuPAD provides the stats csGOFT function This function enables you to test the data against an arbitrary function f For example you can define f by using any of the cumulative distribution functions probability density functions and discrete probability functions available in the MuPAD Statistics library You also can define f by using your own distribution function For example create the data sequence x that contains a thousand random entries reset f stats normalRandom O 1 2 X f k 1 1000 Suppose you want to test whether the entries of that sequence are normally distributed with the mean equal to 0 and the variance equal to 1 2 The classical chi square test uses the following three step approach 1 Divide the line of real values into several intervals also called bins or cells 2 Compute the number of data elements in each interval 3 Compare those numbers with the numbers expected for the specified distribution When you use the stats csGOFT function specify the cell boundaries as an argument You must specify at least three cells The recommen
169. the Save as PDF button are not editable To create editable PDF files click the Print button and try using a PDF printer available for your system 2 119 2 Notebook Interface Note If a MuPAD document has links these links are replaced by regular text in the resulting PDF file Get More Out of Print Preview Using the Print Preview toolbar you can view one or more pages zoom in and out and switch between page orientations If Print Preview shows that your document has layout problems visible when printed you can fix these problems without leaving the Print Preview window To see what a particular button lets you do hover the pointer over the button and wait for a tooltip to appear A Indicates the current page number Use this field to jump to a particular page Click the appropriate arrow to display the previous or the next page B Lets you zoom in and out on a page C Displays the current zoom factor Use this field to zoom in or out by a fixed percentage The drop down menu lets you quickly select one of the commonly used zoom factors D Fits the page to the Print Preview window The button adjusts the document so the width of the page matches the width of the Print Preview window The button i3 adjusts the document so that an entire page fits 1n the Print Preview window If you display two pages side by side the Fit buttons adjust the document so that both pages fit in the window E Scales the document
170. the determinant of a square matrix numerically use the numeric det function For example compute the determinant of the 5 x5 Pascal matrix numeric det linalg pascal 5 1 0 When you use numeric functions the result can be extremely sensitive to roundoff errors For example the determinant of a Pascal matrix of any size is 1 However if you use the numeric det function to compute the determinant of a 25x25 Pascal matrix you get the following incorrect result numeric det linalg pascal 15 1 000043957 When computing determinants numerically you can use the HardwareFloats and Sof twareFloats options to employ the hardware or software float arithmetic respectively You can use the short names for these options Hard and Soft When you use the HardwareFloats option MuPAD converts all input data to hardware floating point numbers and passes the data for processing by compiled C code outside of the MuPAD session Then the results get back into the MuPAD session Hardware arithmetic often allows you to perform computations much faster than software arithmetic which uses the MuPAD kernel for performing computations The precision of hardware arithmetic is limited to about 15 digits By default the numeric det function uses the HardwareFloats option The function switches to software arithmetic under one or more of the following conditions You use the Sof twareFloats option or the MinorExpansion option explicitly Th
171. the int function int cos x 3 x O PI 4 1 LJ 12 You can use infinity as a limit when computing a definite integral int sin x x x infinity infinity Perform Computations Numeric Approximation If MuPAD cannot evaluate an expression in a closed form it returns the expression For example int sin x 2 2 x 1 1 1 EG dx 1 You can approximate the value of an integral numerically using the float command For example float int sin x 2 2 x 1 1 0 3324031519 You also can use the numeric int command to evaluate an integral numerically For example numeric int sin x 2 2 x 1 1 0 3324031519 Linear Algebra Create a Matrix To create a matrix in MuPAD use the matrix command A B matrix 1 2 Sy 4 5 6 matrix 1 2 3 4 5 6 g 2 d 5 6 1 27 1 28 Getting Started 456 You also can create vectors using the matrix command V matrix 1 2 3 1 2 ae You can explicitly declare the matrix dimensions C matrix 3 3 1 Eg 33 4 E 6 f3 8 01 1 W matrix 1 3 1 2 3 Fed 445 4 5 6 7 83 9 123 If you declare matrix dimensions and enter rows or columns shorter than the declared dimensions MuPAD pads the matrix with zero elements F matrix 3 3 1 1 0 2 2 D a is Y 2 0 0 If you declare matrix dimensions and enter rows or columns l
172. the matrix exponential for the following square matrix and then simplify the result A matrix 0 1 1 0 simplify exp A t cos f smit e sin r cos t Now compute the matrix exponential for the following matrix Simplify the result B matrix 2 2 0 2 2 0 simplify exp B x cosh 2x smh 2 x snh 2 x cosh 2 x 3 202 Compute Cholesky Factorization Compute Cholesky Factorization Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The Cholesky factorization expresses a complex Hermitian self adjoint positive definite matrix as a product of a lower triangular matrix L and its Hermitian transpose L A L L The Hermitian transpose of a matrix is the complex conjugate of the transpose of that matrix For real and symmetric matrices the transpose coincides with the Hermitian transpose Thus the Cholesky factorization of a real symmetric positive definite matrix is A L L where L is the transpose of L Create the 5x5 Pascal matrix This matrix is symmetric and positive definite P linalg pascal 5 111 1 1 123 4 5 13 6 10 15 1 4 10 20 35 5 15 35 70 To compute the Cholesky decomposition of a matrix use the linalg factorCholesky function The result 1s the following lower triangular matrix L linalg factorCholesky P 10000 11000 12100 13310 14641 The product of the triangular matrix L and its transpose gives t
173. the notebook engine To restart an engine you can use one of the following methods Select Notebook gt Disconnect and then Notebook gt Start Engine 2 111 2 Notebook Interface Close the notebook and reopen it After you restart an engine you can access all the objects defined in the Notebook Properties dialog box from your notebook Nc a DATT de code NIuPAL File Edit View Wavigation Insert Format Notebook Window Help ifi d LJ ial A F gt oj I i p Q TU dL Q o9 x Generic Monospace hm f i a F b plot sin a x exp b x x 5 15 Jf ax f gt f v3 1 73 tF wr General Math Plot Commands Mem 22 MB TOs 2 112 Change Font Size Quickly Change Font Size Quickly Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To quickly resize all the characters in your notebook including the characters in the output regions Select the part of a notebook you want to resize If you want to resize fonts in a whole notebook select Edit gt Select All Select Format gt Increase size or Decrease size 2 113 2 Notebook Interface nt Notebookl MuPAD File Edit View Navigation Insert Notebook Window Help m daa d A Ia n c T Q O Y eee Math T Creating 3 D Plots Paragraph You also can create a 3 D plot by Culion 1 By default if the plot command can create a 3 D plot a a he same expression it
174. the procedure spends most of the time appending the newly generated numbers to a list In MuPAD appending a new entry to a list of n entries takes time proportional to n Therefore run time of col n is proportional to n You can visualize this dependency by plotting the times that col n spends when creating lists of 1 to 50 000 entries plotfunc2d n time col n n 1 50000 Mesh 20 AdaptiveMesh QO Y 16000 F 14000 12000 100040 8000 8000 4000 2000 0 o 0 20000 30000 40000 50000 5 143 5 Programming Fundamentals 9 144 When appending a new entry to a list MuPAD allocates space for the new longer list Then it copies all entries of the old list plus a new entry to this new list The faster approach is to create the entire list at once without adding each new entry separately This approach 1s called parallel collection because you create and collect data simultaneously Use the sequence operator to implement this approach col proc n local 1 begin random i 1 n end This procedure spends most of its time generating random numbers time col 50000 312 03 Fixed Length Collection Suppose you know how many elements you will generate but you cannot generate them all at once In this case the best strategy 1s to create a list of the required length filling it with some constant such as 0 or NIL Then you can replace any entry of this list with the generated value In this c
175. the test script and execute it after any update The test script in MuPAD includes a set of single tests created by the prog test function See Writing Single Tests for more information Each test script starts with the prog testinit function and ends with the prog testexit function To specify the name of the tested procedure use print Unquoted testname after prog testinit This name does not affect the tested procedure itself It only appears in the test reports generated by your test script To test the procedure f for different choices of parameters write the following test script and save it to the test f tst file The test does not find any unexpected results or errors After MuPAD executes the test script 1t generates the test report The test script does not require any particular file extension You can use any file extension that you like The test report shows the number of executes tests the number of errors encountered while executing the test script and the time and memory used to execute the test script Write Test Scripts test f tst prog testinit f print Unquoted function f that compares two numbers prog test f 1 1 1 prog test f 1 2 2 prog test f 2 1 2 prog test f 100 0 01 100 prog test f O0 ES 100 100 prog test f 1 10 10 sit amis Ue M 2L L prog test T 2 I 2 1 24 I i prog test error f 2 I 3 I TrapError 1003 prog test error f x y
176. time the procedure encounters the error but does not terminate It also does not display the error message Instead it returns the result g 100 3628800 To retrieve and display the error message caught during execution of the procedure g use the lasterror function lasterror Error The number must not exceed 10 test To display the error code and the text of that message use the getlasterror function g 100 getlasterror 1028 Error The number must not exceed 10 test When to Analyze Performance When to Analyze Performance Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Symbolic computations can be very time consuming For many tasks MuPAD provides its own optimized functions When you use these functions the system typically chooses algorithms that provide the best performance for your task However in some cases you might want to measure and investigate your code performance This task is also called profiling For example profiling is helpful when you Feel that your code runs too slowly Want to estimate the performance of a particular computation algorithm Want to compare performances of different algorithms Define and use your own data types and methods MuPAD provides tools to measure the running time of a particular code snippet or the whole MuPAD session The system also provides the profiling tool to help you find and eliminate pe
177. to data One or two dimensional Multidimensional Convert Matrices and Arrays To create a matrix from an array use the matrix command A array 1 2 3 Ix y Z B matrix A type A type B DOM ARRAY Dom Matrix To convert a matrix into an array use the expr command C expr B type C DOM ARRAY 9 38 Vectors and Matrices To convert a matrix or an array to a sequence use the 0p command op B op C r l E 3 X F Z l 2 X F Z To convert a matrix or an array to a list or a set 1 Convert a matrix or an array to a sequence using the op command 2 Create a list or a set from the sequence 5 39 5 Programming Fundamentals Choose Appropriate Data Structures 9 40 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When you create a new MuPAD object you choose the domain type of that object either explicitly or implicitly Typically MuPAD does not require you to declare domain types of simple objects such as numbers identifiers or expressions The system associates an object with a particular domain during run time When you create more complicated data structures such as sets lists arrays matrices procedures and so on the syntax that you use to create these structures 1s a shortcut to the domain constructors For example matrix is a shortcut for the domain constructor Dom Matrix with the default ring Dom
178. to solve the congruence numlib mroots p 299 229 252 298 Using the numlib mroots function you also can solve the congruence for a multivariate polynomial For a multivariate polynomial P X4 Xn numlib mroots returns a nested list as a result Each inner list contains one solution X4 Xn For example find modular roots of the following multivariate polynomial Congruences p poly x 3 y 2 x 2 y x y 1 numlib mroots p 11 3 333 3 Mathematics Sequences of Numbers Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Fibonacci Numbers on page 3 334 Mersenne Primes on page 3 334 Continued Fractions on page 3 335 Fibonacci Numbers The Fibonacci numbers are a sequence of integers The following recursion formula defines the nth Fibonacci number F OGF ELF F F nil din nil To compute the Fibonacci numbers use the numlib fibonacci function For example the first 10 Fibonacci numbers are numlib fibonacci n n 0 9 0 1 1 2 3 5 8 13 21 34 Mersenne Primes The Mersenne numbers are the prime numbers 2 1 Here p is also a prime The numlib mersenne function returns the list that contains the following currently known Mersenne numbers numlib mersenne 2 3 5 7 13 17 19 31 61 89 107 127 521 607 1279 2203 2281 3217 4253 4423 9689 9941 11213 19937 21701 23209 44497 86243 110503 1
179. tribute to Carl Friedrich Gauss we wish to display his picture in this plot Assume that we have his picture as a ppm bitmap file Gauss ppm We import the file via import readbitmap that provides us with the width and height in pixels and the color data width height gauss import readbitmap Gauss ppm We have to use Scaling Constrained to preserve the aspect ratio of the image Unfortunately this setting 1s not appropriate for the function plots So we use two different scenes that are positioned via Layout Relative in one canvas see section Layout of Canvas and Scenes The first scene plots the two functions using the default setting Scaling Unconstrained for function plots With the sizes Width 1 Height 1 representing fractions of the canvas size this scene fills the whole canvas The second scene 1s given a width and height of approximately the desired magnitude It uses Scaling Constrained to get the aspect ratio right automatically With the attributes Bottom and Left the lower left corner of Gauss 1mage is moved to an appropriate point of the canvas 6 179 6 Graphics and Animations pdf stats normalPDF O 1 cdf stats normalCDF O 1 plot plot Scene2d plot Function2d pdf x x 4 7 plot Function2d cdf x x 4 7 Width 1 Height 1 plot Scene2d plot Raster gauss Scaling Constrained Width 0 3 Height 0 6 Bottom 0 25 Left 0 6 BorderWidth O 5 unit m
180. use the standard arithmetic operators For example add substract multiply and divide the following two matrices by using the standard and operators A matrix a b c d B matrix 1 2 8 4 A B A B A B A B i el m et setae Pt S693 d A Nc 3 d Al c 3d2e 4ds 3a a a To perform basic operations on a matrix and a number use the same operators When you multiply a matrix by a number MuPAD multiplies all elements of a matrix by that number o A se sa 4 LA LA L LA When you add a number to a matrix MuPAD multiplies the number by an identity matrix and then adds the result to the original matrix 3 183 3 Mathematics 3 184 Note MATLAB adds a number to each element of a matrix MuPAD adds a number only to the diagonal elements of a matrix You can combine matrices with the same number of rows by using the concatenation operator A B e ME Lig LL More Operations Available for Matrices Besides standard arithmetic operations many other MuPAD functions are available for computations involving matrices and vectors To check whether a particular function accepts matrices as parameters see the Parameters section of the function help page The following functions can operate on matrices The conjugate function computes the conjugate of each complex element of a matrix A i matrix 1 2 3 I 1 I 2 I conjugate A L3 4
181. used to define a smooth function r x from the measurements 6 87 6 Graphics and Animations samplepoints 0 00 0 60 0 10 0 58 0 20 0 55 0 30 0 51 0 40 0 46 0 50 0 40 0 60 0 30 0 70 0 15 0 80 0 23 0 90 0 24 0 95 0 20 1 00 0 00 r numeric cubicSpline samplepoints We reconstruct the object as a surface of revolution via plot XRotate The rotation angle is restricted to a range that leaves a gap in the surface The spline curve and the sample points are added as a plot Curve3d and a plot PointList3d respectively and displayed 1n this gap plot plot XRotate r x x 0 1 AngleRange 0 6 PI 2 4 PI Color RGB MuPADGold plot Curve3d x 0 r x x O 1 LineWidth 0 5 unit mm Color RGB Black plot PointList3d p 1 O p 2 p in samplepoints PointSize 2 0 unit mm Color RGB Red CameraDirection 70 70 40 6 88 Advanced Plotting Principles and First Examples Example 5 The following sum is a Fourier representation of a periodic step function fa Y os lL toa ES 2 2k 1 We wish to show the convergence of the partial sums sin 2 k 1 x a Oe 2k 1 for some small values of n To this end we assign the value of f x to the MuPAD identifier f n For our second and third example we will need to accept fractional values of n so the code uses floor to get a proper integer value for the sum f n sum
182. v_0 gt 0 The assumption a O holds true only for this particular call to solve The assumption does not affect other calculations is a 0 UNKNOWN If you set an assumption in the form of an inequality both sides of an inequality should represent real values Inequalities with complex numbers are invalid because the field of complex numbers is not an ordered field For example if you try to use the following assumption MuPAD returns an error 3 123 3 Mathematics 3 124 y 1 assuming y gt 2 I Error Assumptions are inconsistent property assume You can use complex values in assumptions presented in forms of equations y 1 assuming y 2 I 1423 Assign Temporary Values to Parameters To solve the linear motion equation for particular values of the parameters assign the values to the parameters II O solve r r 0 v O t a t 2 2 t assuming t gt 0 If you use assignments MuPAD evaluates variables to their values in all further computations r r0 v 0 8 4 0 3 2 To be able to reuse the variables 1n further computations use the delete command delete r r0 v0 a Using assumptions you can temporarily assign values to the parameters For example solve the equation for the following values t solve r r_0 v O t a t 2 2 t assuming r 4 and r_O O and v_O 3 and a 2 and t gt O Use Temporary Assumptions 4 I la ae pl The variables remain free for fur
183. want to use as generic fonts Use these specified generic fonts to format text mathematical expressions or calculations 1n your notebooks 2 80 Set Font Preferences fi Character Format Font Generic Sans Serif Generic Seni Adobe Ca Adobe Caslon Pro Bold Adobe Fangsong Std R Adobe Garamond Pro Adobe Garamond Pro Bold Adobe Heiti Std R Adobe Kaiti Std R Adobe Ming Std L Default Generic Fonts for Microsoft Windows Macintosh and Linux The default generic fonts in MuPAD depend on the platform you use fot Wekws Mains 000 Generic Sans Serif Arial Lucida Grande Generic Monospace Courier New Monaco On Linux platforms the default generic fonts depend on the system default fonts 2 81 2 Notebook Interface Set Engine Preferences Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Change Global Settings on page 2 82 Restore Default Global Settings on page 2 84 Add Hidden Startup Commands to All Notebooks on page 2 84 Options Available for MuPAD Engine Startup on page 2 84 Change Global Settings Global settings in MuPAD serve for specifying a particular engine you want to run using additional libraries startup commands and options To change global settings 1 Select View gt Configure 2 Inthe left pane of the Configure MuPAD dialog box click Engine 2 82 Notebook z User Interface Engine Set Engine Preferences
184. wi 2 2 2 2 sum also computes definite sums with infinite boundaries sum x n n n O infinity sum 1 n x 2 n 1 2 n 1 n O infinity stn x To find a sum over two variables use nested calls to sum sum sum x n n n O infinity x a 100 a a100 atl et e l If your sum has a small finite number of terms use the plus command instead of sum The sum command is slower than plus _plus x x 2 1 x 0 10 Compute Symbolic Sums 3829008689 1693047850 To compute a sum for a large finite number of terms use the sum command sum x x 2 1 x 1 10 10 v l 1 w l 1i1 w 10000000001 1 w 10000000001 1 7 3 4d 3 34 If the result of a finite summation contains more than 1000 terms the sum command returns an unexpanded symbolic sum If you want to display all the terms explicitly use the expand function To get the expanded result in the following example delete the colon at the end of the example S sum exp x x 2 1 x a a 1000 expand S a 1000 x 1 Sums Over Roots of a Polynomial The sum command also computes sums for which the summation index runs over all roots of a polynomial To specify all roots of a polynomial use RootOf sum i 10 i RootOf a X 10 b X 8 C X 5 1 X 3 153 3 Mathematics Approximate Sums Numerically Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB I
185. x Compute Indefinite Integrals unassume x Also disable the warnings intlib printWarnings FALSE 3 137 3 Mathematics Compute Definite Integrals 3 138 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For definite integration the int command restricts the integration variable x to the given range of integration int sin ln x x 0 5 2 2 Ssin In 5 5cos In 5 If the int command determines that an integral does not converge it returns the special value undefined int exp X I x 1 infinity undefined When the int command cannot compute an integral and also cannot prove that the integral does not converge it returns an unresolved integral int sin cos x x 0 10 10 J sin cos x dx For definite integrals the int command restricts the integration to the specified interval If you use the assume function to set properties on the integration variable int temporarily overwrites these properties and integrates over the specified interval To display warnings set the value of intlib printWarnings to TRUE intlib printWarnings TRUE assume x 0 int x X OT 2 int x X 1 l I CO Compute Definite Integrals Warning The assumption that x has property Dom Interval 1 2 instead of giv I2 Warning The assumption that x has property Dom Interval 3 1 instead of gi 4 After computing an inte
186. x assuming x in R When you simplify the following expression the returned expression 1s shorter than the original one However you can further simplify the returned expression f In 2 sin sin x I 2 2 sin sin x I I 1 Simplify f i F 4 8 2 59mx 1V pep ane s 2 sin wiy sn sin x i i 1 E D 2 ssa m y we Increasing the number of steps simplifies the expression further Simplify f Steps 300 In cosh sin x smh sin x 3 106 If You Want to Simplify Results Further If you want to get a simplified result for real X assume that x is real assume x Type Real Simplify f Steps 300 stn x To remove an assumption use the unassume command unassume x is x Type Real When assuming any additional mathematical property for a variable such as assuming that X 1s real make sure that your problem does not require solutions to be valid for all complex numbers Be especially careful if your initial expression contains complex numbers For more information about assumptions see Properties and Assumptions 3 107 3 Mathematics Convert Expressions Involving Special Functions 3 108 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Simplify Special Functions Automatically on page 3 108 Use General Simplifiers to Reduce Special Functions on page 3 109 Expand Expressions Invol
187. y direction ZGridVisible TRUE FALSE visibility of major erid lines in z direction ZSubgridVisib TRUE FALSE visibility of minor grid lines in z direction FALSE CS2d 3d Easy Plotting Graphs of Functions attribute name __ possible values browser entry example GridLineColor RGB color color of all RGB Grey75 CS2d 3d major grid lines SubgridLineCo RGB color color of all RGB Grey CS2d 3d minor grid lines GridLineWidth 0 1 unit mm width of all 0 1 unit mm CS2d 3d major grid lines SubgridLineWi 0 1 unit mm width of all 0 1 unit mm CS2d 3d minor grid lines LOL i drawing style of Solid CS2d 3d Dotted Solid lall major grid lines SubgridLineSt Dashed drawing style of Solid CS2d 3d Dotted Solid lall minor grid lines GridInFront TRUE FALSE erid lines in CS2d front of all objects Animations require that plotting ranges X xmin xmax and y ymin ymax are fully specified in plotfunc2d or plotfunc3d respectively Animations are triggered by passing an additional range such asa amin amax to plotfunc2d plotfunc3d The animation parameter a may turn up in the expression of the functions that are to be plotted as well as in various other places such as the coordinates of titles etc See section Graphics and Animations for details Attributes for Animations 6 69 6 Graphics and Animations 6 70 attribute name __ possible values browser entry example
188. 0 562500000000000 4 0765362300000 781253000 1 3 50533531 Us 2 109 2 Notebook Interface Hide Code Lines 2 110 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB You can run MuPAD commands without displaying them in a notebook MuPAD evaluates these commands every time you start a notebook engine To specify the commands you want to execute invisibly Select File Properties 2 Inthe Start Up Commands field of the Notebook Properties dialog box specify the commands you want to run without displaying in the notebook Alternatively attach an existing file containing the commands Hide Code Lines i Notebook Properties Document Title 2 Hiding code lines Start Up Script B r C Work MuPAD initial script mu Start Up Commands am mh a sn nlve Z x 3 x z C xs x assuming x gt 0 z l l 0 int coa x x BPI 5 Z2 PI e AMuPAD uses this title only when exporting a notebook to HTML B Attach an existing file with the MuPAD script that you want to execute invisibly at the notebook startup C Type the commands that you want to execute invisibly at the notebook startup J Save the notebook MuPAD saves the hidden code with the notebook This code does not affect other notebooks If you want to use hidden code for all notebooks see Adding Hidden Startup Commands to All Notebooks To execute the commands you entered restart
189. 0 unit mm Height 90 unit mm 6 124 0 35 Height2 Width3 0 22 Height3 Layout of Canvas and Scenes In detail 6 125 6 Graphics and Animations The Canvas Heads scene 1 Left 2 ocene 3 m 4Botomi Layout of Scenes The following scene attributes are relevant for the layout and the style of a scene Layout and style parameters for scenes attribute name possible values example Width 0 8 12 unit cm width of the scene automatic relative or absolute value 0 8 8 unit cm height of the scene automatic relative or absolute value BackgroundColor RGB color color of the RGB White background 6 126 Layout of Canvas and Scenes attribute name possible values example BackgroundColor2 RGB color secondary color for RGB Grey75 color blend 3D only BackgroundStyle Flat LeftRight style ofcolor blend FLAT Pyramid 8D only TopBottom BackgroundTranspa TRUE FALSE background FALSE transparent or opaque BorderColor RGB color color of the border RGB SlateGrey BorderWidth 1 unit mm width of the border 0 M common width for all margins BottomMargin LeftMargin etc BottomMargin 1 unit mm width of the bottom 1 unit mm margin LeftMargin 1 unit mm width of the left 1 unit mm margin RightMargin 1 unit mm width of the right 1 unit mm margin TO 1 unit mm width of the top 1 unit mm margin a FooterAlignment Left Center horizontal f
190. 1 108 31 1 2 108 1 2 1 3 1 3 3 1 2 1 9 29 54 1 108 31 1 2 108 1 2 1 3 29 54 1 108 31 1 2 108 1 2 1 3 1 2 1 A When you copy some part of an output region to an input region plain text outputs serve best To obtain plain text outputs disable both typeset and pretty print modes When you copy an entire output region to an input region typeset mode serves best To enable the pretty print mode select Notebook gt Pretty Print Alternatively you can switch between the pretty print and plain text modes by using PRETTYPRINT Note that first you must disable the typeset mode For example switch to the plain text mode PRETTYPRINT FALSE Switch to the pretty print mode PRETTYPRINT TRUE Mathematical Notations Used in Typeset Mode By default MuPAD displays the output expressions using the Typeset Math mode In this mode MuPAD uses standard mathematical notations for special functions For example Result int sin x 2 x V2 vx s 22 2 If you are not familiar with a notation you can see the corresponding MuPAD command using one of following methods Disable typesetting mode by selecting Notebook Typeset Math Reevaluate the expression containing the unknown notation Use Different Output Modes Copy the output expression and paste it to an input region Set PRETTYPRINT to FALSE and then use the print command with the option Plain to display the re
191. 109 Inheritance of Attributes on page 6 110 9999 Primitives Requesting Special Scene Attributes Hints The Help Pages of Attributes on page 6 119 on page 6 117 The plot library provides for more than 400 attributes for fine tuning of the graphical output Because of this large number the attributes are grouped into various categories in the object browser see section Viewer Browser and Inspector Interactive Manipulation and the documentation Camera parameters that change the object itself parameters that do not change the objects but their presentation visibility color line width point size etc Arrow Style style parameters for arrows Line Style style parameters for line objects Definition Es gt gt gt E IS3is5 DH ce E ajos on D o 3 5 Un ct ce eS D Attributes Point Style style parameters for point objects Surface Style style parameters for surface objects in 3D and filled areas in 2D Tick Marks axes tick marks style and labels On the help page for each primitive there is a complete list of all attributes the primitive reacts to Clicking on an attribute you are lead to the help page for this attribute which provides for all the necessary information concerning its semantics and admissible values The examples on the help page demonstrate the typical use of the attribute Default Values Most attributes have a default value that is used if no value is speci
192. 1s called summation The variable over which you compute the sum is called the summation index The function you get as a result of a symbolic summation 1s called antidifference MuPAD implicitly assumes that the summation index uses only integer values For continuous values of a variable summation naturally turns to integration Similarly to integration you can compute indefinite and definite sums including sums over roots of polynomials Indefinite Sums The function f 7 Y E d is called the indefinite sum of x over i if the following identity holds for all values of 1 f 1 f x When you compute an indefinite sum the result often involves much more complicated functions than those you use in the original expression If the original expression consists of elementary functions you can get the result in terms of elementary functions sum x 2 x 2 1 x Although the following expression consists of elementary functions the result involves a special function 3 151 3 Mathematics 3 152 sum x x 2 1 x w x i w x i 2 2 nal Definite Sums When computing an indefinite sum the sum command implicitly assumes that the integration index runs through all integer numbers Definite summation lets you specify the range of the summation index For example specify the summation index range using a symbolic parameter sum x x 2 1 x a 10 a a i wla i 10a4 1 i w l0a 1 1 w a i w a wi
193. 1s particularly useful when there are many primitives of the same kind in the plot Imagine a picture consisting of 1000 points If you wish to change the color of all points to green it would be quite cumbersome to set PointColor RGB Green in all 1000 points Instead you can set PointColor RGB Green in the PointColor defaults entry at some tree node that contains all the points e g the canvas Similarly if there are 1000 points in one scene and another 1000 points in a second scene you can change the color of all points in the first scene by an appropriate default entry in the first scene whilst the default entry for the second scene can be set to a different value A 3D plot can be rotated and shifted by the mouse Also zooming in and out is possible In fact these operations are realized by moving the camera around closer to or farther away from the scene respectively There 1s a camera control that may be switched on 6 101 6 Graphics and Animations and off via the Camera Control item of the View menu It provides the current viewing parameters such as camera position focal point and the angle of the camera lens fi Notebook1 MuPAD File Edit view Insert Tools Actions Window Help jenem MOOR ReFst leee eaa Je Fit to Contents ea z Stop Recalculate CameraPositionX 6 86519 Eoo CameraPositonyY 10 7776 I Object Browser CameraPositionZ 7 53301 s FocalPointX o 2 used FocalPoin
194. 2 11 11 111 11 1 4 5 6 7 8 9 10 1 1 13 11 1 101 1 1 1 ll 5 6 7 E 9 WW 1 1 1 3 14 1 1 11 1 11 1 1 1 6 7 B8 9 10 1 1 13 1 4 13 1 1 1 11 1 1 1 1 1 7 B8B 9 10 1 1 1 3 1 4 15 16 1 1 1 1 1 1 1 1 1 3 37 3 Mathematics To solve this system use linalg matlinsolve linalg matlinsolve A b 3 38 Solve Algebraic Systems Specialized Matrices If your system of linear equations can be presented as a specialized matrix you can solve the system by calling a special solver Direct calls to the special solvers often improve the performance of your code MuPAD offers special solvers for linear systems that can be represented by matrices of the following types A matrix given by L U X b where L is a lower triangular matrix and U is an upper triangular matrix LU decomposition of a matrix Toeplitz matrix For example the following matrix 1s a Toeplitz matrix n a a a BE Uy PS a l oe hr dz olx d Ba 2 i Gy a da AA dE On 07 arta cu 3 39 3 Mathematics 3 40 See linalg toeplitz for the definition and details Vandermonde matrix For example the following matrix 1s a Vandermonde matrix bus d 7 aol 1 a a a a E l a 4 EC la a a l H mE HK See linalg vandermonde for the definition and details Suppose you want to solve the following system given by a Toeplitz matrix Use linalg toeplitz to define the system T linalg toeplitz 3 0 2 5 3 O 23 3 Th
195. 21 c xly2 1 d v2 e l 7 V2 e x 4 1 T le A A v x v2 E vite g we ia A A To access the right side of the equation use square brackets or the rhs command Fl 2 2 rhs f 1 2 x l 241 y x 42 1 V J e l E y e z Ly l 4 4 Toxly2 21 cT xl2 1 v2 e E E Jle PROS 4 4 Plot this solution plotfunc2d f 1 2 2 x 1 1 3 93 3 Mathematics 1 0 D 8 0 6 E 2i 0 2 0 4 0 6 0 6 1 0 To plot a solution of the system of ODEs in 3 D use the plot Curve3d command solution plot Curve3d x f 1 2 2 f 1 1 2 X 2 2 GridVisible plot solution 39 94 Solve Ordinary Differential Equations and Systems MuPAD provides the functions plot Ode2d and plot Ode3d for visualizing solutions of ODEs Also you can plot a vector field associated with an ODE For all graphic capabilities available in MuPAD see Graphics and Animations 3 99 3 Mathematics Test Results 3 56 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Solutions Given in the Form of Equations on page 3 56 Solutions Given as Memberships on page 3 58 Solutions Obtained with IgnoreAnalyticConstraints on page 3 59 Solutions Given in the Form of Equations Suppose you want to verify the solutions of this polynomial equation x 3 4 0 solve equation equation solution Lo nays oaei vi 3 4 V8 3 2 r 4 y l E
196. 2d or plot Function3d respectively and call the renderer via plot General Principles In general graphical scenes are collections of graphical primitives There are simple primitives such as points line segments polygons rectangles and boxes circles and Advanced Plotting Principles and First Examples spheres histogram plots pie charts etc An example of a more advanced primitive is plot VectorField2d that represents a collection of arrows attached to a regular mesh visualizing a vector field over a rectangular region in R Yet more advanced primitives are function graphs and parametrized curves that come equipped with some internal intelligence e g knowing how to evaluate themselves numerically on adaptive meshes and how to clip themselves in case of singularities The most advanced primitives in the present plot library are plot Ode2d plot Ode3d and plot Implicit2d plot Implicit3d The first automatically solve systems of ordinary differential equations numerically and display the solutions graphically The latter display the solution curves or surfaces of algebraic equations f x y 0 or f x y z 0 respectively by solving these equation numerically All these primitives are just objects representing some graphical entities They are not rendered directly when they are created but just serve as data structures encoding the graphical meaning collecting attributes defining the presentation style
197. 3 16 7 3190308193 77616 89 3019825 Dom Matrix Dom Integer index 50467 24 27149 65 3019825 1 Dom Matrix Dom Integer index intern 5 103 5 Programming Fundamentals 13984 84 95990 02 1000 6 g 4 12 7 13984 84 95990 02 1000 f 18373 13 77616 89 3019825 3 Dom Matrix Dom Integer index 5460 346 0 3019825 2 Dom Integer coerce 5 5 0 5460 346 0 3019825 Dom Integer convert 6 0 0 8 0 109974 8 1 g 13984 84 95990 02 1000 4 f Time sum 109982 873 ms Top rows of the profiling report indicate that the procedure spends most of its time accessing each matrix element To improve performance rewrite the procedure so that it can access fewer elements of a matrix in each call to the procedure f For example use the algorithm based on the bisection method f proc M n x begin if M 1 x M n x gt O then return FALSE elif M 1 x M n x O then return TRUE else a 1 b n while b a gt 1 do if is b a Type 0dd then c a b a 1 2 else 5 104 Profile Your Code c a b a 2 end if if M c x 0 then return TRUE elif M a x M c x lt O then D i cC else a i c eng ir end while end if return FALSE end proc Before calling the procedure f you must convert the matrix M to a list and sort that list Sorting the list that contains 10 entries is an expensive operation Depending on the number of calls to the procedure f
198. 30 X y 2 z x y Z linopt maximize c OPTIMAL x 0 y 19 z 1 57 to solve the linear optimization problem defined in the variable c This mechanism avoids naming conflicts with other library functions If this is found to be inconvenient then the routines of the linopt package may be exported via use E g after calling use linopt maximize the function linopt maximize may be called directly c i 3 x 4 y 3 z lt 23 5 x 4 y 3 z lt 10 7 x 4 y 11 Z lt 30 X y 2 z x y Z maximize c OPTIMAL fx 0 y 19 z z z All routines of the 1inopt package are exported simultaneously by use linopt 8 23 8 More Information About Some of the MuPAD Libraries The functions available in the linopt library can be listed with info linopt Library linopt a package for linear optimization Interface linopt Transparent linopt corners linopt maximize linopt minimize linopt plot data 8 24 The misc Library The misc Library Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The misc library contains some miscellaneous utility functions The package functions are called using the package name misc and the name of the function E g use myplus misc genassop plus O to create your own n ary plus operator This 1s not really useful since plus is an n ary operator anyway This mechanism avoids naming
199. 31 sqrt 108 M 3 54 108 C 9 omo Me 1 54 108 29 sqrt 31 sqrt 108 1 3 eo onm MM 1 1 54 108 rere er eee eee eee i eee ee a ee ee d d 3 29 sqrt 31 sqrt 108 1 3 2 18 54 108 1 1 sqrt 3 3 29 sqrt 31 sqrt 108 1 3 ee A 54 108 29 sqrt 31 sqrt 108 1 3 V A eje di gg 54 108 2 89 2 Notebook Interface 2 90 29 sqrt 31 sqrt 108 1 3 1 V 54 108 1 hy a ok aa cee yg at eee nea sane sds a E as dh on ones us dedere hat ei esha sb ur ce ee Gu uu d UE n Mec e 29 sqrt 31 sqrt 108 1 3 2 3 18 54 108 1 sqrt 3 29 sart 31 sqrt 108 1 3 cf REN A A 54 108 29 sqrt 31 sqrt 108 1 3 V Docs I 2 54 108 d P To enable the typeset mode select Notebook gt Typeset Math You cannot disable the typeset mode programmatically Pretty Print Mode To see how the pretty print mode affects the output disable the typeset mode first With the typeset mode disabled and the pretty print mode enabled the results look as follows solve x 3 x 2 1 0 x MaxDegree 3 1 29 sqrt 31 sqrt 108 1 3 29 sqrt 31 sqrt 108 1 3 54 108 SAAS I I I I I I I I I I I I I I I I I I I I I I I I I I
200. 32049 216091 756839 859433 1257787 1398209 2976221 3021377 6972593 13466917 20996011 24036583 25964951 30402457 32582657 37156667 42643801 43112609 57885161 3 334 Sequences of Numbers Continued Fractions The continued fraction approximation of a real number r is an expansion of the following form Here a1 is the integer f loor r and a2 a3 are positive integers To create a continued fraction approximation of a real number use the numlib contfrac function For example approximate the number 123456 123456789 by a continued fraction numlib contfrac 123456 123456789 1000 3 S as Alternatively you can use the more general contfrac function This function belongs to the standard library While numlib contfrac accept only real numbers as parameters contfrac also accepts symbolic expressions When working with real numbers contfrac internally calls numlib contfrac and returns the result of the domain type numlib contfrac a contfrac 123456 123456789 domtype a 1000 4 amp 4 3 335 3 Mathematics numlib contfrac Since contfrac internally calls numlib contfrac calling the numlib contfrac directly can speed up your computations 3 336 Programming Basics Conditional Control on page 4 2 Loops on page 4 8 Procedures on page 4 18 Functions on page 4 26 Shortcut for Closing Statements on page 4 29 4 Programming Basics Condi
201. 34 The kurtosis measures the flatness of a distribution For normally distributed data the kurtosis is zero Negative kurtosis indicates that the distribution function has a flatter top than the normal distribution Positive kurtosis indicates that the peak of the distribution function is sharper than it 1s for the normal distribution stats kurtosis 2 1 0 5 0 0 5 1 2 1 1 stats kurtosis 0 5 0 0 0 0 0 5 1 0 8333333333 0 1606648199 3 215 3 Mathematics Compute Covariance and Correlation 3 216 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If you have two or more data samples with an equal number of elements you can estimate how similar these data samples are The most common measures of similarity of two data samples are the covariance and the correlation MuPAD provides the following functions for computing the covariance and the correlation of two data samples The stats covariance function calculates the covariance X Xn and y is the arithmetic average of the data sample y ys ys 1 n Es x y y Here x 1s the arithmetic average of the data sample x The stats correlation function calculates the linear Bravais Pearson correlation coefficient cha A A 2 ixi 5 79 X Here x is the arithmetic average of the data sample x x JG sx 24 7 Xn and y is the arithmetic average of the
202. 35333310 Va 3 gr 976562500000 78125000 Mem 15 MB TO s When you wrap text in a notebook and then unwrap it the vertical line appears This line shows you the position of the right margin of the current page format 2 103 2 Notebook Interface I Notebookl MuPAD File Edit View Navigation Insert Format Notebook Window Help d s x A T C e Tl 4 Y uJ 9 n Generic Sans Serif The vertical dashed gray line shows the right margin of the printed page When you print this notebook MuPAD offers you to scale it down to fit the printer setting for a page size If you use the actual page size only the part of the notebook to the left of the vertical line appears on printed pages solve 300000 x 4 123456 x 3 x 2 l1000 x 123456789 0 x MaxDegree 643 643 _ g 5883 q 543 NES O1 Os UD DO 0 m T o sm 9 95 5230 1 3 6250 5250 Position of the right margin Ed 35284905497 E 5080195408992451661 v3 v6 v 8467460273477442205913016404294527174037 i Ja b d 2 700000000000000 F 3 2251 Tm sat i 2700000000000000 62500000000000 q 976562500000 n 59533531 0 7 f T 444444070032001 d y J oa o O z at i y 7 78123000 5 4 90000000000 Mem 15 MB TOs When you print the page MuPAD lets you choose between scaling down the whole page or cropping the content to the right of the line The line does not appear on printed pages To remove this line sel
203. 3d background BorderColor RGB color color of the RGB Grey50 Scene2d 3d border BorderWidth 1 unit mm width of the Scene2d 3d border Margin common width Scene2d 3d for all margins BottomMargin LeftMargin etc BottomMargin 1 unit mm width of bottom 1 unit mm Scene2d 3d margin LeftMargin 1 unit mm width of left 1 unit mm Scene2d 3d margin RightMargin 1 unit mm width of right 1 unit mm Scene2d 3d margin 6 57 6 Graphics and Animations attribute name pee values browser entry example TopMargin 1 unit width of top 1 unit Scene2d 3d margin Backgroundsty Flat background Flat Scene3d LeftRight style of 3D TopBottom scenes Pyramid BackgroundCol RGB color secondary RGB Grey75 Scene3d color of the background used for color blends BackgroundTrai TRUE FALSE transparent FALSE Scene2d background An overall title can be set as a footer and or a header Here 1s a table of the attributes determining the footer and or header of the picture Attributes for Footer and Header attribute name possible values browser entry example string string footer text no footer Scene2d 3d Header Header fstring string header text no header Scene2d 3d 3d FooterAlignmerLeft Center horizontal Center cec ES Right alignment HeaderAlignmerLeft Center horizontal Center Scene2d 3d Right alignment FooterFont see section font for the sans serif 12 Scene2d 3d Fonts footer
204. 3d piecewise X lt y y x x gt y y A Qus xX 0 1 y 6 44 Easy Plotting Graphs of Functions Tn m Note that there are gaps 1n the definition of the function above no function value is specified for x y This does not cause any problem because plotfunc3d simply ignores points that do not produce real numerical values if it finds suitable values in the neighborhood Thus missing points do not show up in a plot if these points are 1solated or are restricted to some 1 dimensional curve 1n the x y plane If the function 1s not real valued in regions of nonzero measure the resulting plot contains holes The following function is real valued only in the disk x y 1 plotfunc3d sqrt 1 x 2 y 2 x 0 1 y 0 1 6 45 6 Graphics and Animations When several functions are plotted in the same scene they are drawn in different colors that are chosen automatically With the Colors attribute one may specify a list of RGB colors that plotfunc3d shall use plotfunc3d 2 x 2 y 2 1 x 4 y 4 x 6 y 6 x 1 1 y 1 1 Colors RGB Red RGB Green RGB Blue 6 46 Easy Plotting Graphs of Functions Animated 8D plots of functions are created by passing function expressions depending on two variables x y say and an animation parameter a say and specifying a range for x y anda plotfunc3d x a y a x 0 2 y 0 2 a 1 2 6 47 6 Graphics and Animation
205. 40 9 42 9 43 9 44 5 47 5 49 5 52 5 59 5 59 5 57 5 60 5 64 5 64 5 65 5 66 5 69 Evaluate Variables and Expressions After a Particular punction Cas co escterete badd aeo V roro ee s Watch Intermediate Values of Variables and Expressions View Names of Currently Running Procedures CODPect EP PO S 52 4rd eh Qa REAPER REA EAE GA RUNS amp Debug MuPAD Code in the Tracing Mode Display Progress cc ee ee ee eee Use Assertions 0 cc eens Write Error and Warning Messages Handle vrors 2234622548548 L654 2R840R ERR EN E SR When to Analyze Performance ss Measure Time eh Calls to MuPAD Processes ee ee Calls to External Processes eren Profile Your Code 00 00 00 cece ees Techniques for Improving Performance Display Memory Usage 000000 eee Usethe State Das adus astu oat aad oe DOES oe was Generate Memory Usage Reports Periodically Generate Memory Usage Reports for Procedure Calls Remember Mechanism seen Why Use the Remember Mechanism Remember Results Without Context Remember Results and Context ens Clear Remember Tables eee Potential Problems Related to the Remember Mechanism History Mechanism 2e wee Rad a a Rh s
206. 5636836 enter lucas 1 mem 5637200 computed 1 mem 5636916 computed 4 mem 5636532 computed 11 mem 5636052 l1 To stop using the Mem option for further calls set its value to FALSE prog trace Mem FALSE To stop tracing calls to the lucas procedure use the prog untrace function prog untrace Display Progress Display Progress Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB By default MuPAD procedures do not show progress information or comments on run time For example create the following procedure that returns the sign of an input number MuPAD provides the standard function ign for this task S proc z Type Numeric begin if not testtype z Dom Real then z abs z elif z gt 0 then 1 elif z 0 then 1 else 0 end if end proc When you execute this procedure 1t returns only the final result S 10 Typically the final result 1s all that your users want to see However if executing a procedure takes a long time or if users can benefit from the comments on some procedure steps you can extend the procedure to include additional information To embed the progress information into your procedure use the print function For example modify the procedure S so it reports its progress S proc z Type Numeric begin print Unquoted Is expr2text z a real number if not testtype z Dom Real then print Unquoted expr2te
207. 5x erase ete Set sable e or ei oso de A te qr e M e Generate Simple Animations 00000000 PI3y Anma On a adt ots aber edo step TE SS wb E des The Number of Frames and the Time Range What Can Be Animated llle Advanced Animations The Synchronization Model Frame by Frame Animations llle Esan les MRUERESCTUSISOTOTTUTTRRTS E a a a 6 2 6 2 6 7 6 17 6 25 6 25 6 41 6 56 6 78 6 78 6 84 6 93 6 98 6 103 6 108 6 109 6 110 6 117 6 119 6 120 6 120 6 126 6 129 6 129 6 134 6 135 6 138 6 140 6 143 6 149 XiX XX Contents Groups of Primitives lt lt 4445 66364535 aeRO REQUE 6 157 Transformations cR eek eee feeb eu 6 159 Lesentls 2 2 t os es ee a ee us red 6 164 ponc cepe Sh hos ain Sv A CIT 6 168 COlOVS acera dA BEE ESKER CER REESE RS ERIRES a 6 171 ROB COOS wu tots be ees a Xon d Sot LA p od 6 171 PON MGOlOLS Ade Ind ere ERI ode Sew Ae we eewes IU 6 174 Save and Export Pictures een 6 176 Save and Export Interactively 04 6 176 Save in Batch Mode 00 0002 ee eee 6 176 Import Pictures eee 6 179 Cameras in 3D v o Rye Rh a Ra 6 181 Possible Strange Effects in 3D 6 192 Quick Reference 7 GIOS eh oras unte Oe ai Pm AS No S anderen ko Pane tasa ra dst in a Rt 1 2 More Information About Some of the MuPAD Libraries Abstract Data Types Lib
208. 6 7 a b 112 6 7 b Note When you replace and delete elements of a set the order of its elements can change even if you delete or replace the last element When replacing or deleting an element always check that you access the element at the correct position set4 op set4 4 J L1 2 6 7 a b 6 The subs command does not modify the original set set4 a b 2 6 7 subs set4 a 1 set4 J 7 b f1 2 6 7 b I R 7 hi I2 6 7 a b To delete elements from a set use the minus command You can simultaneously delete several elements of a set set5 lt 41 2 6 7 b set5 minus 1 b 9 28 5 Programming Fundamentals a I3 9 24 Tables Tables Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Tables on page 5 25 Access Table Elements on page 5 26 Operate on Tables on page 5 27 Replace or Remove Table Entries on page 5 28 Create Tables Tables associate arbitrary indices with arbitrary values For example you can use tables to represent collections of equations in the form index value To generate a table use the table command T table a b c d en cla You can create tables from equations existing tables lists or sets of equations table s t T x 6 y 13 MuPAD inserts index value pairs 1n a table in the same order as you enter them Each new entry can ov
209. 6 10 15 21 141020 35 56 13 15 35 70 126 6 21 56 126 252 For that matrix MuPAD finds eigenvalues in the form of RootOf eigenvalues linalg eigenvalues P RootOf z 351 z 6084 z 13869 z 6084 z 351 z 1 z You can find floating point approximation of the result by using the float command float eigenvalues 10 003004389575 0 06429432079 04893388287 2 04357378 15 55347327 332 8463154 Find Eigenvalues and Eigenvectors For more information about approximating eigenvalues and eigenvectors numerically see Numeric Eigenvalues and Eigenvectors 3 199 3 Mathematics Find Jordan Canonical Form of a Matrix 3 200 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The Jordan canonical form of a square matrix is a block matrix in which each block is a Jordan block A Jordan block is a square matrix with an eigenvalue of the original matrix on the main diagonal A block also can contain 1s on its first superdiagonal Each Jordan block corresponds to a particular eigenvalue Single eigenvalues produce 1X1 Jordan blocks If an nxn square matrix has n linearly independent eigenvectors the Jordan form of that matrix 1s a diagonal matrix with the eigenvalues on the main diagonal For example create the 3 x3 Pascal matrix P P linalg pascal 3 b E Qs F s Em pi RR Lad bJ The Jordan canonical form of the matrix P 1s a diagonal matrix with
210. 60949992 6713652774 0 0 1 54453 7491 You can get the same result faster by calling the numeric factorization function from the beginning Q R numeric factorQR V 0 5773502692 0 08763169824 0 8117803595 0 5773502692 0 05920056045 04817814566 4 0 5773502692 0 7468382628 0 3299989029 1 997275809 6 773052 174 1 732050808 3 160949992 Sd 0 0 1544537491 Within floating point precision the product of Q and R gives the original 3x3 Vandermonde matrix V float V Q R 1 0 2 0 40 1 0 2 0 40 18 3 1413592654 9 869604401 1 0 3 141592654 9 869604401 1 0 0 3333333333 0 1111111111 1 0 0 3333333333 0 1111111111 Singular Value Decomposition The singular value decomposition expresses an mXn matrix A as follows A US V Here S is an mxn diagonal matrix with singular values of A on its diagonal The columns 3 224 Compute Factorizations Numerically of the mxm matrix U are the left singular vectors for corresponding singular values The columns of the nXn matrix V are the right singular vectors for corresponding singular values V is the Hermitian transpose the complex conjugate of the transpose of V To compute the singular value decomposition of a matrix use the numeric svd or numeric singularvectors function These two functions are equivalent For example compute the singular value decomposition of the following matrix A matrix 9 4 6 8 2 7 Svd n
211. 79295 282172 AnnualRateWorld AnnualRateUS 1 26 2 ee ee a 07 99 94 87 1 1 la J 4 0 0 C tie OOO OO OO LCD JU 95 Import Data The first row in that sample contains text The statistical functions cannot work with the text Before you start analyzing the data delete the first row 9 1970 1971 1972 stats sample delRow s 3711962 205052 2 07 3789539 207661 3865804 209896 Tega 1 1 26 1 07 1 94 0 95 3 263 3 Mathematics 3 264 1973 3941551 211909 1 87 0 91 1974 4016056 213854 1 79 0 99 1975 4088612 215973 1 73 0 95 1976 4159763 218035 1 71 1 01 1977 4231510 220239 1 68 Tl 1978 4303134 222585 1 71 1 18 1979 4877497 225055 1 7 0 98 1980 4452548 227726 1 7 0 96 1981 4528882 229966 1 75 0 91 1982 4608682 232188 1 75 0 87 1983 4690278 234307 1 7 0 89 1984 4770468 236348 1 7 0 91 1985 4852052 238466 1 71 0 89 1986 4935874 240651 1 73 0 91 1987 5022023 242804 1 71 0 94 1988 5108860 245021 1 69 1 12 1989 5195713 247342 1 68 1 33 1990 5283687 250132 1 57 1 33 1991 5367185 253493 1 56 1 3 1992 5451672 256894 1 9 qux 1993 5534138 260255 1 46 1 18 1994 5615311 263436 1 44 1 16 1995 5696677 266557 1 4 aat 1996 5776857 269667 1 35 1 17 1997 5855087 272912 1 31 1 15 1998 5932091 276115 1 28 1 02 1999 6008255 279295 1 25 1 01 2000 6083550 282172 1 24 0 94 The MuPAD statistical functions accept the resulting sample because it contains only numeric d
212. 8 1 33 1990 5283687 250132 1 57 1 33 1991 5367185 253493 1 56 1 3 1992 5451672 256894 1 5 1 21 1993 5534138 260255 1 46 1 18 1994 5615311 263436 1 44 1 16 1995 5696677 266557 1 4 1 2 1996 5776857 269667 1 35 1 17 1997 5855087 272912 1 31 1 15 11998 5932091 276115 1 28 1 02 1999 6008255 279295 1 25 1 011 2000 6083550 282172 1 24 0 947 You can convert the resulting nested list to other data structures For example represent the imported data as a sample A sample is a collection of statistical data in the form of a matrix To convert the nested list of imported data to a sample use the stats sample function 9 year 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 world thousands 3711962 3789539 3865804 3941551 4016056 4088612 4159763 4231510 4303134 4377497 4452548 4528882 4608682 4690278 4770468 4852052 4935874 9022023 5108860 5195713 5283687 5367185 5451672 5534138 5615311 5696677 5776857 5855087 5932091 6008255 6083550 stats sample data US thousands 205052 207661 209896 211909 213854 215973 218035 220239 222585 225055 227726 229966 232188 234307 236348 238466 240651 242804 245021 247342 250132 253493 256894 260255 263436 266557 269667 272912 276115 2
213. 81828 Suppose you implement the complete elliptic integral functions of the first and second kind K Z and E z These functions appear in different contexts such as calculating the perimeter of an ellipsis the gravitational or electrostatic potential of a uniform ring and the probability that a random walk 1n three dimensions ever goes through the origin The elliptic integrals have the following special values E 0 K 0 ED 1 3 ze k 1 r iy 2 I MuPAD provides the built in functions ellipticE and ellipticK for computing these elliptic integrals However you can implement your own functions for the same task For example write the procedures ellipE and ellipK These procedures define the values of the elliptic integrals for special values of x For all other argument values the values 5 177 5 Programming Fundamentals 9 178 of elliptic integrals are unknown and the procedures return the symbolic expressions ellipE x and ellipK x Use procname to return symbolic expressions ellipE proc x begin if x 0 then PI 2 elif x 1 then 1 else procname x end if end proc ellipK proc x begin if x 0 then PI 2 elif x 1 2 then 8 PI 3 2 gamma 1 4 2 elif x 1 then gamma 1 4 2 4 sqrt 2 PI else procname x end if end proc ellipE and ellipK return special values for particular arguments For all other arguments they return symbolic expressions ellipE O ellipE 1 2 ellipK 12 17
214. 9 2 120 2 122 2 123 Mathematics 3 Evaluations in Symbolic Computations 3 5 Level of Evaluation 00 0 0 0 000 ees 3 8 What Is an Evaluation Level 3 8 Incomplete Evaluations lt i 2004462 otarrea bers PUE PR XR 3 9 Control Evaluation Levels leen 3 11 Enforce Evaluation 0 0 000000 cee eee eee 3 16 Prevent Evaluation 0 0 000000 ccc ee ees 3 19 Actual and Displayed Results of Evaluations 3 21 Hvaltiate ata PON 665 be oe eG be ON eek a 3 23 Choose a Solver 2225 2 LA EAR OE AA 3 25 Solve Algebraic Equations and Inequalities 3 28 Specify Right Side of Equation 00 8 3 28 Specify Equation Variables 00000008 3 29 Solve Higher Order Polynomial Equations 3 30 Find Multiple Roots ei ered ters 0 0 00 00 0000 aee 3 32 Isolate Real Roots of Polynomial Equations 3 32 Solve Diequalities 22522232 a Pag CORP EROS Rs doa oad 3 33 Solve Algebraic Systems eee 3 34 Linear Systems of Equations 000000008 3 34 Linear Systems in a Matrix Form 3 35 Nonlinear Systems 0 0000 ee ee ee ees 3 41 Solve Ordinary Differential Equations and Systems 3 44 General Soblutlols cu oda be eov Cat ow Mo ee 3 44 Initial and Boundary Value Problems 3 46 Special Types of Ordinary Differential Equations
215. 9 y 0 6529880654 x 22 204123351 y 0 4796455988 x 0 9816416007 y 0 7209295436 m TR Ir Isolate Numeric Roots If you know an interval containing the solutions of a polynomial equation you can significantly speed up numeric approximations To find one solution inside a specified interval use the numeric realroot command The command returns real solutions and omits the complex ones numeric realroot 1 4 x 4 x 3 x 17 0 x 5 0 4174547488 You also can specify an interval and search for all subintervals that can contain real roots The numeric realroots command returns a complete list of such subintervals numeric realroots 1 4 x 4 x 3 x 1 0 x 5 0 74 1875 4 15625 0 7109375 0 70703125 If the equation you solve is polynomial each subinterval contains exactly one root For nonpolynomial equations numeric realroots can return subintervals that do not contain any roots numeric realroots guarantees that the search interval does not contain any real roots outside the returned subintervals Solve Differential Equations and Systems There is no general way to solve an arbitrary second or higher order ordinary differential equation ODE Often such an equation does not have a symbolic solution In some cases the solution exists but 1t can be presented only by special functions For example the solution of the following second order ODE includes the err
216. 9 176 Debug MuPAD Code Using the Debugger Alternatively you can select an expression and hover the cursor over it If the expression is syntactically correct and can be computed fast MuPAD displays the value of the expression in a tooltip l proci n z name f 3 begin 4 gil10 n 5 end proc B 7 proc x B8 name g 9 begin 10 11 end proc M 12 x x 1 10 11 Watch Intermediate Values of Variables and Expressions You can observe the values of variables during the debugging process in the Watch pane If you do not see the Watch pane select View gt Watch By default the Debugger displays the values of the parameters used in the function call args the results of the most recent command 5 and the values of variables declared in the procedure To watch the values of other variables and expressions during the debugging process select Watches gt Add Watch and enter the object or the expression you want to observe in the Add Watch dialog box Z5 Add Watch Mame x1 2 Cancel You also can enter the expressions directly into the Watch table 5 77 5 Programming Fundamentals Expression args or 10 end of automatic display varia 11 Mem 1 MB TOs View Names of Currently Running Procedures In the Call Stack pane you can see the list of the procedures participating 1n the debugging process If you do not see the Call Stack pane select View gt Call Stack The Debugger lists
217. C XVZ the MuPAD native format You can import the images saved in this format into a notebook and activate and manipulate them with the MuPAD notebook graphic tools JVX JVD JavaView Java based format for 2 D and 3 D images that you can embed into HTML Web pages Exporting an animation to JavaView you can choose to export the current view or a sequence of images EPS Encapsulated PostScript Standard format for publishing images in scientific articles and books This format serves best for 2 D images 3 D images are exported as raster images embedded in EPS and therefore can loose quality You cannot export animations to this format SVG Scalable Vector Graphics The format serves for including vector graphics and animations on Web pages MuPAD does not support svg animations You can only export the current view of an animation in this format You cannot export 3 D images to this format WMF Windows Metafile You can use this file format on Windows operating platforms only PDF Portable Document Format You can use this format to export non animated 2 D 1mages Bitmap Formats Bitmap formats save an 1mage pixel by pixel allowing the 1mage to look identical on different computers To save 1mages in bitmap format you need to select the image resolution The quality of images saved in bitmap formats depend on the resolution and can be decreased if you scale an image after saving MuPAD supports the following
218. D Notebook Interface This functionality does not run in MATLAB First steps on page 8 12 Integration by parts and by change of variables on page 8 14 This library contains functions for manipulating and solving integrals Currently there are only described interfaces for the well known integration methods change of variables and integration by parts In addition a function for integrating over arbitrary subsets of the real numbers exists In future versions more interfaces will be added First steps Integration is the process inverse to differentiation Any function F in the variable X with 8 F f is an integral of f ax j f cos x exp sin x sin x E Di cos x F int f x sin ac e a diff F x sin x e Af X cos x No constant is added to the integral or in other words a special integration constant 1s chosen automatically With MuPAD it is possible to determine integrals of elementary functions of many special functions and with some restrictions of algebraic functions Integration Utilities int sin x 4 cos X x sin x int 1 2 cos x x v3 tan E 2 4 3 arctan tan z 24 3 arctan a T 3 3 int exp a x 2 x vt erf a x 2 4a int x 2 sqrt 1 5 x 3 X 3 J V 1 5x 15 normal simplify diff x x 3 y1 5x It is also possible to compute definite and multiple integrals int exp x 2 l1n x 2
219. D completes the command If more than one name starts with the characters you typed MuPAD displays a list of all names starting with those characters 1 15 l Getting Started I Notebookl MuPAD File Edit View Wavigation Insert Format Motebook Window Help Ld A J A E 3 C TU 4 GJ 9 Generic Monospace Command Bar lm f Bax X Jfa soy General Math Plot Commands Command Bar Find and Replace Mem 9 MB TOs Use Tooltips and the Context Menu To get a brief description and acceptable syntax for a function type the function name in a notebook and hover your cursor over the command 1 16 Access Help for Particular Command File Edit View Wavigation Insert Format Notebook Window Help Jalg amp d AP DOO ntead solve solve equations and inequalities solve eq x lt Options gt solve eq x a b lt Options gt 30lve eq vars Options solve eq lt Options gt solve eqs x lt Options gt solve eqs vars lt Options gt solve eqs lt Options gt solve ODE solve REC Mem 9 MB TOs For more detailed information right click the name of a command and select Help about from the context menu 1 17 l Getting Started File Edit View Navigation Insert Format Notebook Window Help ie Ld daly A F gt Oy E Q TU 4L Q 9 Generic Monospace X 1 18 Command Bar x B lim f E A 2 ax f XH 3 nf Help about solve Ds m A m
220. Error in test function f that compares two numbers 8 Input T 2 I 2 I Expected 2 I Got TrapError 1003 Error Can t evaluate to boolean _leequal r n Evaluating f Near line 10 Info 11 tests 2 errors runtime factor 0 0 nothing expected Write Test Scripts Info CPU time 12 7 S Info Memory allocation 20452460 bytes prog testexit Although the change seems reasonable and safe the test report shows that the procedure does not work for equal complex numbers anymore Instead the procedure throws an error If you do not test the code you can miss this change in procedure behavior If this behavior 1s expected correct the test script Otherwise correct the procedure 5 137 5 Programming Fundamentals Code Verification 9 138 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Even if your code executes without errors and all your tests run without failures the code can still have some flaws For example it can Modify global variables protected identifiers environment variables and formal parameters Declare local variables or formal parameters and not use them afterwards Contain undefined entries of domains or domain interfaces To ensure that your code does not introduce such flaws use the prog check function to verify 1t Use this function to check your procedures domains and function environments Suppose you wrote the followi
221. ExpressionField Also when defining your own procedure you can specify the types of arguments accepted by that procedure In this case for every call to that procedure MuPAD automatically checks the types of provided arguments For more information see Checking Types of Arguments The domtype function returns the name of a domain to which an object belongs domtype a b c DOM LIST When choosing a data structure for a new object try to answer these questions Which features are essential to the new object For example some structures keep the initial order of elements while other structures can change the order Another example is that you can create multidimensional arrays but you cannot create MuPAD matrices with more than two dimensions Which functions do you want to use on that object Each MuPAD function accepts only objects of particular domain types If an object that you pass to a function is not one of the acceptable domain types for that function the function issues an error To determine the domain types acceptable for a particular function see the help page for that function For example you cannot use standard mathematical operations for MuPAD arrays Choose Appropriate Data Structures If you already created an object and then realized that it must belong to another domain type try to convert the domain type of the object See Converting Data Types 9 41 5 Programming Fundamentals Convert Data
222. GL using hardware drivers for your graphics card if installed If you encounter strange graphical effects in 3D we recommend to use the menu item Help OpenGL Info to check which OpenGL driver you are currently using Switch to the alternative driver via View Configure Quick Reference Quick Reference Glossary 1 2 MATLAB Note Use only in the MuPAD Notebook Interface This functionality does not run in This glossary explains some of the terms that are used throughout the MuPAD documentation arithmetical expression domain Syntactically this is an object of Type Arithmetical In particular this type includes numbers identifiers and expressions of domain type DOM EXPR The phrase domain is synonymous with data type Every MuPAD object has a data type referred to as its domain type It may be queried via the function domtype There are basic domains provided by the system kernel These include various types of numbers sets lists arrays hfarrays tables expressions polynomials etc The documentation refers to these data types as kernel domains The name of the kernel domains are of the form DOM XXX e g DOM INT DOM SET DOM LIST DOM ARRAY DOM HFARRAY DOM TABLE etc In addition the MuPAD programming language allows to introduce new data types via the keyword domain or the function newDomain The MuPAD library provides many such domains
223. IP AL epuggel File Edit View Step Breakpoints Watches Help T L2 QD ul Toggle Breakpoint B Set Breakpoint s CHE IF Remove All Breakpoints qat then error solve called without arguments end if if argas 0 1 then egs egr vars var to avoid warnings userinfo l solving exprztext eqs for exprztext vars else egs egr userinfo l Solving exprztexti eg3 end if if type egas equal then if domtype op eqa 1 DOM LIST and domtype opieqs 2 DOM LIST then eqs zip ap egs 1 op eqs 2 equal else eqs ap eqs 1 opleqs zi if eqs undefined then return procname args 100 end if 101 end if 102 end if 103 Set conditional breakpoint Mem 3 MB TO s J Inthe Set Breakpoint dialog box type the condition under which you want the Debugger to stop on this line In the dialog box you also can change the placement of a breakpoint defining the file and line where you want to set the breakpoint 9 71 5 Programming Fundamentals zs Set Breakpoint File STDLIB solve mu Condition arg 0 2 Use Breakpoints After you set the breakpoint you can continue the debugging process The Debugger pauses at the breakpoints and executes the line with the breakpoint after you click the Continue button 5 72 Debug MuPAD Code Using the Debugger File Edit View Step Breakpoints Watches Help LLA 76 H error solve
224. Iz z C0 0 2 0 4 1 0 2 1 0 pa i er ae ee L6 04 07 ag Iz A m e 4 iS In these calls the position of the camera is not fully specified by CameraDirection This attribute just requests the camera to be placed at some large distance from the scene along the ray in the direction given by the attribute The actual distance from the scene is determined automatically to let the graphical scene fill the picture optimally For a full specification of the perspective there are camera objects of type plot Camera that allow to specify the position of the camera its focal point and the opening angle of its lens position 5 10 5 focalpoint 0 O 0 angle PI 12 camera plot Camera position focalpoint angle This camera can be passed like any graphical object to the plot command generating the scene Once a camera object is specified in a graphical scene 1t determines the view No automatic camera is used plot plot Function3d sin x y 3 x 1 1 y 1 1 camera 6 183 6 Graphics and Animations 6 184 Camera objects can be animated camera plot Camera 3 cos a S sin a 0 0 O PI 3 a Frames 100 1 cos 2 a 0 2 PI Inserting the animated camera in a graphical scene we obtain an animated plot simulating a flight around the scene plot plot Function3d sin x y 3 x 1 1 y 1 1 camera Cameras in 3D In fact
225. LSE If you want to search for an object among the indices and the values of a table use the has command TRUE FALSE Replace or Remove Table Entries To replace an entry of a table access the entry by its index and assign the new value to the entry T table a 11 c 12 T a 5 T als c 12 To remove an entry from a table use the delete command 9 28 Tables delete T a T c 12 9 29 5 Programming Fundamentals Arrays 9 30 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Arrays on page 5 30 Access Array Entries on page 5 31 Operate on Arrays on page 5 32 Replace or Remove Array Entries on page 5 34 Arrays with Hardware Floating Point Numbers on page 5 34 Create Arrays Arrays represent multidimensional data structures You can use only integers for array indices To generate an array use the array command A soy B i T array array 0 2 O 0 2 O 0 4 NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL array 0 2 0 3 0 4 For two dimensional arrays the first range defines the number of rows the second range defines the number of columns Ranges for array indices do not necessarily start with O or 1 A array 3 5 1 2 NIL NIL NIL NI NIL NIL Arrays Access Array Entries To access an entry of an array use brackets or index A i1 array 0 1 0 2 1 2 3 ay b
226. Mode By using different options of the prog trace function you can customize generated reports Most of these options are independent of a particular procedure call They affect all reports generated after you use an option See the prog trace help page for more details If a procedure uses many nested procedure calls the generated report for that procedure can be very long To limit the number of nested procedure calls in a report use the Depth option of prog trace prog trace Depth 2 lucas 5 enter lucas 5 enter lucas 4 computed 7 enter lucas 3 computed 4 computed 11 11 The Depth option affects all reports generated for further calls to procedures domains methods and function environments If you do not want to use this option for further calls set its value to 0 The value 0 indicates that prog trace must display all nested calls prog trace Depth 0 To display memory usage in each step of the procedure call use the Mem option prog trace Mem lucas 5 enter lucas 5 mem 5636064 enter lucas 4 mem 5636544 enter lucas 3 mem 5636944 enter lucas 2 mem 5637344 computed 3 mem 5637060 enter lucas 1 mem 5637424 computed 1 mem 5637140 computed 4 mem 5636756 9 83 5 Programming Fundamentals 9 84 enter lucas 2 mem 5637120 computed 3 mem 5636836 computed 7 mem 5636356 enter lucas 3 mem 5636720 enter lucas 2 mem 5637120 computed 3 mem
227. MuPAD User s Guide V0 5b X B How to Contact MathWorks Latest news www mathworks com Sales and services www mathworks com sales and services User community www mathworks com matlabcentral Technical support www mathworks com support contact us Phone 908 647 7000 The MathWorks Inc 3 Apple Hill Drive Natick MA 01760 2098 MuPAD User s Guide COPYRIGHT 1993 2015 by SciFace Software GmbH amp 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 22 1 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
228. Notebook Interface This functionality does not run in MATLAB When computing eigenvalues and eigenvectors of some matrices symbolically you can get a long result in a form that is not suitable for further computations For example the linalg eigenvectors function returns the following results for eigenvalues and eigenvectors of the 3 x3 Hilbert matrix H linalg hilbert 3 eigen linalg eigenvectors H 3 214 Compute Eigenvalues and Eigenvectors Numerically 418 c 6559 7 8 484 7 2113 3375 Gy 450 zc c 1 453 2998 3295 soe 123 78 _ 6559 Lg 1 di 135006 gt 3 675 49 as l za Mo 240859 78 rg 2113 8750 Gg 3 2 450 i _g 45913 Ug 3205 5066 23 8 6558 4g 270000 2 3 675 45 2 43000 E l g 6559 778 480 2113 6750 Gg 450 7 E e g 45913 Ug 329 5066 270006 3 3 675 l where 6559 _ 78 23 M o S a 649000 2 6559 8 23 O oO 5 a 648000 2 8 42 4 3 6 i O ake Es 3 5 24 v3 60 1 ns zd 4 5 6559 a oOo Y 40 4 gt gt 32400c 5 45 215 v3 a i 3 Mathematics Numeric approximation of the result returned by the symbolic linalg eigenvectors function gives a shorter answer that contains complex numbers float eigen 2 558147015 1 575682167 1013 i 1 408318927 1 084202172 10 1 1 1 0 1 422413022 1 522668397 10 5 i 1 0 0 1853704181 c 0 002687340356
229. O 1 3 3 83 3 Mathematics 3 84 0 3983192206 0 549573 7569 11 79725153 30 00571043 0 002624699038 0 3333436668 MuPAD also offers an alternate way to generate parameters for the ODE numeric solvers 1 Define your initial value problem as a list or a set IVP i 1y t V9 0 y 0 D y 0 1 3 2 Define a set of fields over which you want to get a solution fields y t y t 3 Convert the initial value problem and the fields into a procedure acceptable by numeric odesolve The function numeric ode2vectorfield generates the required procedure ODE tO YO numeric ode2vectorfield IVP fields proc ODE t Y end 0 o L Now call numeric odesolve to approximate the solution at particular values of t numeric odesolve ODE t0 1 YO 0 3983192206 0 5495737569 Represent Numeric Approximations as Functions The function numeric odesolve also requires the system of first order ODEs dynamic system to be represented by a procedure To generate parameters for numeric odesolved2 use the following steps Solve Equations Numerically 1 Define your initial value problem as a list or a set IVP i y t Cy t yO D y 0 1 3 2 Define a set of fields over which you want to get a solution fields y t y t 3 Convert the initial value problem and the fields into a procedure acceptable by numeric odesolve2 The function numeric ode2vectorfi
230. PAD Notebook Interface This functionality does not run in MATLAB General Principles on page 6 78 Some Examples on page 6 84 In the previous section we introduced plotfunc2d and plotfunc3d that serve for plotting functions in 2D and 3D with simple calls in easy syntax Although all plot attributes accepted by function graphs of type plot Function2d or plot Functionsd respectively are also accepted by plotfunc2d 3d there remains a serious restriction the attributes are used for all functions simultaneously If attributes are to be applied to functions individually one needs to invoke a slightly more elaborate calling syntax to generate the plot plot plot Function2d fi x1 a1 b1 attribi1 attribi2 plot Function2d f2 x2 a2 b2 attrib21 attrib22 ra In this call each call of plot Function2d creates a separate object that represents the graph of the function passed as the first argument over the plotting range passed as the second argument An arbitrary number of plot attributes can be associated with each function graph The objects themselves are not displayed directly The plot command triggers the evaluation of the functions on some suitable numerical mesh and calls the renderer to display these numerical data in the form specified by the given attributes In fact plotfunc2d and plotfunc3d do precisely the same Internally they generate plot objects of type plot Function
231. Point Also MuPAD does not evaluate arrays tables and polynomials For example the system does not evaluate the identifiers a and b of the following array A A array 1 2 b kd b 2 a a 1 a A When you access the entries of the array A by using the op function the system does not evaluate the entries of A When you use the indexed access the system evaluates the entries of arrays matrices and tables op A 1 op A 2 A 1 A 2 3 17 3 Mathematics To evaluate all entries of an array a table or a polynomial apply the eval function to that array table or polynomial Use the map function to apply eval to an array or a table map A eval 12 For polynomials use the mapcoeffs function p poly c x x c 10 mapcoeffs p eval poly 10 x x delete a b c 3 18 Prevent Evaluation Prevent Evaluation Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When you perform interactive computations in MuPAD the system tries to evaluate all expressions before returning them For example if the system can compute an integral it returns the evaluated result In most cases the result is also simplified int x 2 sin x x 2 x sin x cos x x 2 The hold command enables you to prevent the evaluation of a MuPAD object For example hold lets you display the integral in its symbolic form hold int x 2 sin x x int x 2 sin
232. T 3 debug f 5 Debug Step by Step Using the MuPAD Debugger you can run a procedure step by step Running a procedure step by step helps you isolate the errors in your code To start the step by step debugging process select Step from the main menu Debug MuPAD Code Using the Debugger ep Breakpoints Watches Help T 25 Q EL Break lE Continue proc in picis i Step Over Procedure Qi Step Into end proc Qo Step Out A Stack Up wW Stack Down Value 5 end of automatic display variabl Mem 1 MB TO s Step into next function call Also you can use the toolbar buttons ii g v Executing your code step by step you can 9 67 5 Programming Fundamentals Use Step Over to execute the current line If the code line contains a call to another function the Debugger passes to the next code line without stepping into that function Use Step Into to execute the current code line and if the code line contains a call to another function the Debugger steps into that function After stepping in use Step Out to run the rest of the current function leave the called function and pause For example use Step Into to open and step through the inner procedure g 9 68 Debug MuPAD Code Using the Debugger name d begin g 10 7n end prac Procedure procix name g ip p Oy c ae M begin 11 end proc 12 10 end of automatic display variabl Mem 1 MB TOs
233. T TT E TTL TT 8 33 ODF caos dx Sou sev iui ul ee 8 34 Comparison Operators celles 8 35 Other Symbols 4 35 3 4 oa Et noa ae n De eO ee ERROR n ed 8 35 MILeS ACCS 4 2 5 2 2 44 1215 9 3 8 0 9 ea odor Q1 BO e dede tobd 8 36 huc MOT PP LC PIE 8 36 Punctuation Marks er goin orp e OE RACE ES ore ee REE 8 37 Uma WES v Soc E ye E oe BER asks E E UE S 8 38 Ciero 5 3 543 Sak tulad med Pda d eae hel qc Bed 8 38 XXI XXil Contents INNA Gy OSs aaa acest a See a uota iol deaur Type Checking and Mathematical Properties Example 1 Example 2 Example 3 Example 4 8 38 8 39 8 41 8 41 8 42 8 42 Getting Started Desktop Overview on page 1 2 Evaluate Mathematical Expressions and Commands on page 1 4 Shortcut to Access Standard MuPAD Functions on page 1 7 Access Help for Particular Command on page 1 15 Perform Computations on page 1 19 Use Graphics on page 1 39 Use the MuPAD Libraries on page 1 62 l Getting Started Desktop Overview Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB A MuPAD notebook has three types of regions input regions output regions and text regions A Notebookl MuPAD fo amp z Boeae DOO v t UO 9 exc T me A notebook has three types of regions input regions output regions and text regions ES region 8 lim f w ee D Input a 2 1 2 2 1 3 i region pl
234. T is a basic number domain lexppe T agep b expr in T and a lt expr expr b Type Interval a Here a b are expressions b T and T is a basic number domain bZ a expr b Z a or expr expr in b Z a Type Residue a Here a and b are integers b or expr b Type Integer a 8 30 Typeset Symbols in MuPAD Typeset Symbols in MuPAD Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Greek Letters on page 8 31 Open Face Letters on page 8 33 Arrows on page 8 33 Operators on page 8 34 Comparison Operators on page 8 35 Other Symbols on page 8 35 Whitespaces on page 8 36 Braces on page 8 36 Punctuation Marks on page 8 37 Umlauts on page 8 38 Currency on page 8 38 Math Symbols on page 8 38 Symbol provides access to typesetting symbols All available symbols are shown below sorted in appropriate groups The symbols can be accessed via slots of Symbol for example Symbol alpha for the symbol a or via function calls for example Symbol alpha Some symbols can be accessed only via function calls For example Symbol minus throws an error so use Symbol minus instead For details see Symbol new Greek Letters 0L alpha B beta gamma amp delta im 8 31 8 More Information About Some of the MuPAD Libraries 8 32 T aq pe qa go em OND t amp x 1 b M M eps
235. The following two examples show the meaning of the third argument delete x matrix 2 2 gt x matrix 2 2 x XX xil 1 x 1 2 pe met A x 2 1 x 2 2 Linear Algebra Library The MuPAD arithmetical operators are used to perform matrix arithmetic A B 2 B 1 A ad bc ad bc _ e a ad be ad be Next we create the 2x2 generalized Hilbert matrix see also Linalg hilbert asa matrix of the ring of two dimensional square matrices MatQ2 Dom SquareMatrix 2 Dom Rational Dom SquareMatrix 2 Dom Rational H2 MatQ2 i j gt 1 i j 1 o A vector with n components is a 1Xn matrix a row vector or a nX1 matrix a column vector The components of a matrix or a vector are accessed using the index operator 1 e A i j returns the component of the row with index i and column with index j The input A i j xX sets the i j th component of the matrix A to the value of x The index operator can also be used to extract sub matrices by giving ranges of integers as its arguments A Dom Matrix Dom Integer 8 19 8 More Information About Some of the MuPAD Libraries 8 20 1 2 3 4 5 6 7 8 9 A 1 co un pa 4 6 7 g 8 T8 A33 18 2E 4 5 789 78 See also the function linalg submatrix Remarks on Improving Runtime The runtime of user defined procedures that use functions of the linalg library and methods of the c
236. The function also accepts nested lists with flat inner lists The plot Bars3d function draws each element as a separate 3 D block The elements of each row of an array or a matrix or the elements of each flat list appear along one horizontal axis Bars that represent elements in the first column of an array or a matrix appear along the other horizontal axis If you use a nested list the elements of the inner lists with the same indices appear along the other horizontal axis By default the plot Bars3d function does not display gaps between the groups of elements Use the Gap option to create gaps and specify their size 0 8 0 0 amr 0 e 0 tn D Pa 0 La 0 ha 0 1 0 0 Create Bar Charts Histograms and Pie Charts plot plot Bars3d x y z Gap 0 5 0 8 Histograms Histograms show the distribution of data values across a data range They divide the data range into a certain number of intervals bins tabulate the number of values that fall into each bin and plot these numbers using bars of varying height To create a histogram use the plot Histogram2d function By default this function divides the data range into seven bins To specify the number of bins use the Cells option For example create the histogram of the following data sample categorizing the data into 10 bins data lt 10 1 1 1 1 3 5 13 O 5 5 0 5 7 9 15 0 15 6 7 2 9 plot plot Histogram2d dat
237. Types 9 42 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Use the coerce Function on page 5 43 Use the expr Function on page 5 44 Use Constructors on page 5 47 When creating new objects in MuPAD the best practice 1s to consider which domain the object must belong to Choosing the correct data type from the beginning helps you avoid unnecessary conversions Nevertheless some computation tasks require data types conversions For such tasks MuPAD enables you to convert the elements of some domains to elements of other domains To convert an object to a different domain type use one of the following alternatives Some of the alternatives do not work for conversions between particular domains Use the coerce Function on page 5 43 Call the coerce function to convert an object to an element of a specified domain The coerce function can call the convert convert to and coerce domain methods If the conversion is not possible or if none of these methods 1s implemented for the domains participating in conversion the coerce function returns FAIL Use the expr Function on page 5 44 Call the expr function to convert an object to an element of a basic domain The expr function calls the expr method If the conversion is not possible or if the expr method is not implemented for the specified domains the expr function returns FAIL Use Constructors on page 5 47 Call the do
238. U S and the Hermitian transpose of V returns the original matrix A U d V res U res V svd A U S conjugate transpose V 94v 9 0 4 0 6 5 6 0 so 274 amp 20 70 Mathematical Constants Available in MuPAD Mathematical Constants Available in MuPAD Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Special Real Numbers on page 3 227 Infinities on page 3 228 Boolean Constants on page 8 228 Special Values on page 3 228 Special Sets on page 3 229 Special Real Numbers MuPAD provides symbolic representations of the following commonly used special real numbers You can perform exact computations that include the constants Also you can get floating point approximations with the current precision DIGITS by using the f loat function E Euler number exponential constant base of natural logarithm e 2 718281828 PI n 3 141592653 EULER Euler Mascheroni constant Ed A lim i 1n 9 05772156649 zit CATALAN Catalan constant a r 1 x 22 z 0 9159655941 ap 2 i1 3 227 3 Mathematics 3 228 Infinities MuPAD provides the symbolic representations for real and complex infinities Many functions accept infinities as their arguments For example you can use infinities when computing sums limits integrals and so on Also you can perform arithmetical operations with infinities MuPAD can return infinities as results of computation
239. V 8 d LLL NIA SA LLL M e ee PS sss ULLLI NI M BR NN UC MCA se ee OS 85aE ea NE LULA tA m 4 See gt NN m ed ill eter a ET LR Y T e See Pe NMDUAN ee A AS ee PO A ee Ae Ae PPPs M VI ee A PL rr ee ee es P LL LL mmu v err eu n rr LL Pr NI A F P LT P qiu LEEREN ED ALL eee V ru n i OL LL I NI A a A a F ee Fi i a a er 2 ee a ap ti ae 5 xX J 5 x RGB Black 39 df x 2 tasto la 39 RGB Orange VisibleAfter 5 x 1 f x 2 RGB Orange VisibleAfter 21 B Y 1 Color e X41 f x lee ld J 1 f x 1 x f x 7 Color x in 1 1 20 i The reflected rays leaving to the left plot Line2d x f x 1 f x Color xin 1 i 20 i 1 x in 1 i 20 i The reflected rays leaving to the right plot Line2d x f x a Reh plot The static rim gt plot Line2d x 2 x f x VisibleAfter plot Function2d f x x The incoming rays ViewingBox X Compare the spherical mirror with a parabolic mirror that has a true focal point T 4 6 148 Animations diu 2 A X LUIS v O AaMNIUE IE TL a RE uL JUL HE y o yu 2 NON SS CRUCE i E TEE nn HA AEL 1 S m Vt is M P M A a Examples Example 1 We build a 2D animation that displays a function f x together with the in
240. V V v X5 1 v y v 4 4 4 7 4 4 4 To obtain real solutions only pass the assumption to MuPAD using the assuming command solve x 5 2 1 x assuming x in R_ 1 You can make various assumptions on the values that a variable represents For example you can solve an equation assuming that the variable x represents only positive values solve x 4 1 0 x assuming x gt 0 571 L lj Perform Computations You can make multiple assumptions solve x 4 a 0 x assuming a 16 and x in R_ Integrate with Assumptions You can use assumptions when integrating mathematical expressions For example without an assumption on the variable x the following integral depends on the sign of 2 the expression x 1 int 1 abs x 2 1 x arctanh x sion x 1 If you know that x gt 1 you can pass the assumption to the integral int 1 abs x 2 1 x assuming x gt 1 arctanh x Simplify Expressions with Assumptions Using assumptions along with the simplification functions narrows down the possible values that variables represent and can provide much shorter results than the simplification functions alone For example simplify sqrt x 2 2 x 1 sqrt x 2 2 x 1 sqrt x 2 4 x 4 sqrt x 2 4 x 4 I E l i3 l E 3 ix l a xl a laxa x 2Y V j V j yA YA j versus simplify sqgrt x 2 2 x 1 sqrt x 2 2 x 1 Sqrt X 2 4 x 4 sqrt x 2 4 x
241. Visible TRUE FALSE visibility of ticks TRUE CS2d 3d along the x axis YTicksVisible TRUE FALSE visibility of ticks TRUE CS2d 3d along the y axis ZTicksVisible TRUE FALSE visibility of ticks TRUE CS3d along the z axis TicksDistance positive real distance CS2d 3d between labeled ticks along all axes XTicksDistanc positive real distance CS2d 3d between labeled ticks along the x axis YTicksDistancipositive real distance CS2d 3d between labeled ticks along the y axis ZTicksDistanctipositive real distance CS3d value between labeled Easy Plotting Graphs of Functions attribute name possible values browser entry example ticks along the a a LM TicksAnchor _ real value the position of CS2d 3d a labeled tick to start with XTicksAnchor real value the position of CS2d 3d a labeled tick to start with CS2d 3d YTicksAnchor real value the position of a labeled tick to start with ZTicksAnchor real value the position of CS3d a labeled tick to start with TicksNumber None Low number of Normal CS2d 3d Normal High labeled ticks along all axes XTicksNumber None Low number of Normal CS2d 3d Normal High labeled ticks along the x axis YTicksNumber None Low number of Normal CS2d 3d Normal High labeled ticks along the y axis ZTicksNumber None Low number of Normal CS3d Normal High _ labeled ticks along the z axis TicksBetween integer gt 0 number 1 CS2d 3d of smaller unlabeled tick
242. a a b c op set2 1 op set2 2 op set2 3 ila b cl 8 E al le a 5 When using a notebook interactively you can access an element of a set by its position in an output region To access an element by the position as you see it on screen use brackets or index set2 c a b b c a a b c set2 1 9 19 5 Programming Fundamentals 9 20 _index set2 3 You can access particular solutions from a set returned by the solve command To use the order of elements of a set as they appear on screen use brackets or index solutions solve x 4 1 x solutions 3 index solutions 2 4 I m 1 1 1 L5 1 ii If you use an indexed assignment without creating a set MuPAD generates a table instead of a set set 1 x set i Ix Operate on Sets MuPAD sets support the following operations Defining an object as a member of a set e Verifying that a set contains a particular object Using a set as a function in a function call Applying a function to all elements of a set Extracting entries of a set Sets Computing the intersection of sets Dividing a set according to particular properties of its elements To define an object as a member of a set use the in command x in 1 2 3 a d 5 re 11 2 3 5 4 d To check if an object belongs to a set use the contains command Set a 3 b C d 180 15 contains set d contains set e FALSE If you u
243. a Cells 10 3 287 3 Mathematics 3 288 10 8 6 4 2 0 2 4 8 8 0 2 14 Pie Charts Pie charts can help you effectively communicate a portion or percentage that each element of a data sample contributes to the total number of all elements To create a 2 D pie chart use the plot Piechart2d function To create a 3 D pie chart use the plot Piechart3d function A 3 D pie chart does not show any additional information The 3 D view simply adds depth to the presentation by plotting the chart on top of a cylindrical base and lets you rotate the plot Suppose you need to analyze the following list of numbers data 10 1 1 1 1 3 5 13 0 5 5 0 5 7 9 15 0 15 6 7 2 9 First use the stats frequency function to categorize the data into bins See Data Binning for more details T stats frequency data Create Bar Charts Histograms and Pie Charts 1 o 7 59 1 10 1 2 se 5 081 1 5 5 3 5 08 2 57 0 4 2 57 0 061 1 1 5 0 06 2 45 5 0 0 15 0 5 1 1 2 6 2 45 4 96 1 3 5 7 4 96 7 47 1 6 7 8 7 47 9 98 2 7 9 9 9 9 98 12 49 0 T 10 12 49 15 0 2 13 15 The result 1s a table that shows the intervals bins number of elements 1n those bins and the data elements in each bin The plot Piechart2d and plot Piechart3d functions do not accept tables as arguments They accep
244. a procedure call with the same arguments MuPAD can store the results of the first procedure call in a special table This table is called the remember table The system stores the arguments of a procedure call as indices of the remember table entries and the corresponding results as values of these entries When you call a procedure using the same arguments as in previous calls MuPAD accesses the remember table of that procedure If the remember table contains the entry with the required arguments MuPAD returns the value of that entry Otherwise MuPAD evaluates the procedure call and writes the arguments and corresponding results to the remember table of the procedure Using the remember mechanism in MuPAD can significantly accelerate your computations especially when you use recursive procedure calls For example create the procedure that computes the Lucas numbers The Lucas numbers are a sequence of integers The recursion formula that defines the nth Lucas number is similar to the definition of the Fibonacci numbers L llj AL LL 1 f The following recursive procedure returns any Lucas number 9 115 5 Programming Fundamentals 9 116 lucas proc n Type PosInt begin if n 1 then 1 elif n 2 then 3 else lucas n 1 lucas n 2 end if end proc However if the value n is large computing the nth Lucas number can be very slow The number of required procedure calls 1s exponential Often the procedure calls i
245. able is important even if your expression contains only one variable For example find the derivative of an expression with one variable diff x 2 sqrt sin x x cos x i L F 2 V Six 2x Note If you do not specify differentiation variable diff expr returns the expression expr Find first order partial derivatives of a multivariable expression by specifying differentiation variables diff sin x cos x y x diff sin x cos x y y cos x cos x y cos x y x y sim x yi 7 pF F r L x six y cosix cos x yj To take second and higher order derivatives you can use nested calls to the diff function More efficiently use only one diff command and specify variables for each differentiation step Calling diff only once is shorter and also can improve performance because MuPAD internally converts nested calls to diff into a single call with multiple arguments Differentiate Expressions diff diff sqrt sin x x x diff sqrt sin x x x j MV SIUX cos x E e 7 PD 4 smixr s FO 2 Oy 593m cos x 2 4 sin x When computing higher order derivatives with respect to one variable use the sequence operator as a shortcut diff sqrt sin x x 3 diff sqrt sin x x x x r i F 3 r 3 cos x 3cosixy X cosix 3 cosix EF 45 2 Led F F 572 i m z 3 F 4 V si x 8 smixx y sm x amp smixx To compute mixed derivatives specify differen
246. ace File Edit View Navigation Insert Format Notebook Window Help diu amp Hd yxu0d00m amp t8060m9 m Model involving the van der Pol equation The van der Pol equation is a second order ordinary differential equation This model is created and can be use in Simulink amp General Math Plot Commands Mot Connected 3 The selected image appears in the original size You cannot format images in text regions of a notebook 2 46 Embed Graphics File Edit View Navigation Insert Format Notebook Window Help BOWES APY ID OO nb OO OV es Model involving the van der Pol equation Scope The van der Pol equation is a second order ordinary differential equation This model is created and can be use in Simulink General Math Plot Commands Mot Connected 2 47 2 Notebook Interface Work with Links 2 A8 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Insert Links to Targets in Notebooks on page 2 48 Insert Links Interactively on page 2 51 Insert Links to Arbitrary Files on page 2 53 Insert Links to Internet Addresses on page 2 54 Edit Existing Links on page 2 56 Delete Links on page 2 57 Delete Link Targets on page 2 58 Insert Links to Targets in Notebooks Create Link Targets You can insert a link to a particular location in the same notebook or in some other MuPAD notebook This location is called a link targe
247. ace This functionality does not run in MATLAB The stats frequency function categorizes the numerical data into a number of bins given by semiopen intervals aj bj This function returns a table with the entries rows corresponding to the bins Each entry shows the following information The number of the bin The interval defining the bin The number of data in the bin The data contained in the bin The stats frequency function enables you to specify the number of bins By default stats frequency categorizes the data into 10 bins For example categorize the following data into 10 bins X i19 10 1 1 1 1 95 9 13 Oy 5 5 0 5 ladr Wx Ulog BJ Sy 911 stats frequency x Now categorize the same data into 5 bins 3 279 3 Mathematics 3 280 stats frequency x 5 5 081 2 10 1 5 5 7 5 08 0 06 1 7 1 0 06 4 96 6 0 0 15 0 5 1 1 2 3 5 9 98 15 0 2 13 15 Un qp ou bi n When creating the bins you can specify the intervals For example divide the data into two bins one bin contains the numbers that are less or equal to zero and the other bin contains the numbers that are greater than zero stats frequency x infinity O O infinity 1 OL 4 10 1 5 5 1 OT 2 T0 ac 10 0 15 0 5 1 1 2 3 5 6 7 7 9 9 13 15 For graphical interpretation of the data binning see Create Bar Charts Hist
248. acobi number i Cannot be solved by numlib msqrts Try numlib mroots MuPAD implements the Jacobi symbol as the numlib jacobi function If the Jacobi symbol 1s equal to 1 the congruence does not have a solution numlib jacobi 19 21 1 numlib msqrts 19 21 If Jacobi symbol is equal to 1 the congruence might have solutions numlib jacobi 16 21 numlib msqrts 16 21 4 10 11 17 However the value 1 of the Jacobi symbol does not guarantee that the congruence has solutions For example the following congruence does not have any solutions numlib jacobi 20 21 3 331 3 Mathematics 3 332 numlib msqrts 20 21 If a and m are not coprime the Jacobi symbol is equal to O In this case numlib jacobi function returns 0 and numlib msqrts errors numlib jacobi 18 21 0 numlib msqrts 18 21 Error Arguments must be relative prime numlib msqrts General Solver for Congruences Besides solving a linear congruence or computing modular square roots MuPAD also enables you to solve congruences of a more general type of P x O mod m Here P X isa univariate or multivariate polynomial To solve such congruences use the numlib mroots function For example solve the congruence x x x 1 O mod 3 First define the left side of the congruence as a polynomial by using the poly function p poly x 3 x 2 x 1 poly x x x 1 x Now use the num1ib mroots function
249. age 3 296 3 9 3 Mathematics 3 4 Univariate Linear Regression on page 3 299 Univariate Nonlinear Regression on page 3 303 Multivariate Regression on page 3 306 Principles of Hypothesis Testing on page 3 309 Perform chi square Test on page 3 310 Perform Kolmogorov Smirnov Test on page 3 312 Perform Shapiro Wilk Test on page 3 313 Perform t Test on page 3 314 Divisors on page 3 315 Primes and Factorizations on page 3 318 Modular Arithmetic on page 3 322 Congruences on page 3 327 Sequences of Numbers on page 3 334 Evaluations in Symbolic Computations Evaluations in Symbolic Computations Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Evaluation is one of the most common mathematical operations Therefore it is important to understand how and when MuPAD performs evaluations For example assign the value 2 2 to the variable y Instead of assigning the expression 2 2 MuPAD evaluates this expression and assigns the result of the evaluation the value 4 to the variable y y i 2 2i y The variable y is an identifier and the number 4 1s the value of that identifier Values of identifiers are not always numbers For example a value of an identifier can also contain identifiers In the following assignment y is an identifier and the expression a xis the value of that identifier The value of y is a sum of two identifiers a and x You can assi
250. al begin if abs x gt 1 then error invalid number Choose a value from the interval 1 1 end if arcsin x end proc Typically when you call one MuPAD procedure that procedure internally calls other MuPAD procedures Some of these internal calls are multiple calls to the same procedure with different sets of arguments Testing arguments for each internal procedure call can become computationally expensive By default the system uses the following general principle for testing arguments of a typical MuPAD procedure 9 01 5 Programming Fundamentals 9 58 Ifyou call a procedure interactively the procedure performs all argument checks fone procedure internally calls another procedure the second procedure skips argument checks Currently the procedure p always checks whether the value of its argument belongs to the interval 1 1 To follow the general principle for testing arguments the procedure must be able to recognize internal and interactive calls and skip argument checking when a call 1s internal For this task MuPAD provides the testargs function When you call testargs inside an interactive procedure call testargs returns the value TRUE For internal procedure calls testargs returns the value FALSE by default For example rewrite your procedure p as follows p proc x begin if testargs then if abs x 1 then error invalid number Choose a value from the interval 1 1 ena IT end if ar
251. all by using the logical operators For example set two assumptions on X assume x in Z and x in R is x in Z is x in R TRUE TRUE When adding assumptions always check that a new assumption does not contradict the existing assumption MuPAD does not guarantee to detect conflicting assumptions For example assume that y is simultaneously nonzero real and an imaginary value Type Imaginary refers to all complex numbers lying on the imaginary axis When you set these assumptions MuPAD does not 1ssue any warning and does not error assume y 0 assumeAlso y in R assumeAlso y Type Imaginary Note Do not set conflicting assumptions because they can lead to unpredictable and inconsistent results To check if the assumption still holds true use the is command For example MuPAD drops the assumption that the variable y represents imaginary numbers because this assumption conflicts with the combination of the previous two assumptions is y lt gt 0 is y in R is y Type Imaginary TRUE TRUE FALSE If you set conflicting assumptions the order in which you set them does not always determine which assumption MuPAD accepts assume y 0 3 119 3 Mathematics 3 120 assumeAlso y Type Imaginary assumeAlso y in Z is y lt gt 0 is y Type Imaginary is y in Z TRUE FALSE TRUE Clear Permanent Assumptions Permanent assumptions hold for all further calculations Before using a pa
252. all prime numbers that are less than the number at startup The default startup number is 1000000 You can increase this number The maximum value for this option is 4362773009 Specify options as strings See Pref userOptions for details Start the engine in the test coverage mode See prog tcov for details Start the engine in the test coverage mode and export the test coverage information to filename See prog tcov for details 2 85 2 Notebook Interface Get Version Information 2 86 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Type of Information You Want To Get the Information Version and Release Numbers 32 bit or 64 bit version Build Number From the product select Help gt About MuPAD Alternatively call version or Pref kernel for a version number From the product select Help gt About MuPAD Alternatively call Pref kernel BitsInLong For the build number of the kernel call Pref kernel BuildNr For the build number of the MuPAD library call buildnumber Use Different Output Modes Use Different Output Modes Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Abbreviations on page 2 87 Typeset Math Mode on page 2 88 Pretty Print Mode on page 2 90 Mathematical Notations Used in Typeset Mode on page 2 92 Abbreviations MuPAD can display results of you
253. aller or equal to n The Euler s totient function returns the number of such integers To compute the Euler s totient function in MuPAD use the numlib phi function numlib phi i i 1 20 1 2 2 4 2 6 4 6 4 10 4 12 6 8 8 16 6 18 8 For other modular arithmetic functions available in MuPAD see the numlib library Residue Class Rings and Fields For the two integers a and m all integers b such that a b mod m construct a residue class The MuPAD domain Dom IntegerMod lets you create a ring that consists of all residue classes modulo some integer m For example create a residue class ring of integers modulo 11 Z11 Dom IntegerMod 11 Dom IntegerMod 11 Now create the elements a and b of this ring Then compute the sum of a and b a Z11 1 b Z11 6 a b 1 mod 11 6 mod 11 7 mod 11 You can use Dom IntegerMod to specify polynomials over a coefficient ring When computing the coefficients of a polynomial Dom IntegerMod 7 uses the positive modulo function modp poly 9 3 13 1 x Dom IntegerMod 11 3 325 3 Mathematics 3 326 poly 9 x 2 x x Dom IntegerMod 1 1 For specifying polynomials over a residue class ring Z the poly function also provides the IntMod option This option enables you to create a polynomial with the coefficients that belong to the IntMod n ring Here n is an integer greater than 1 Mathematically this ring coincides with Dom
254. and By default the resulting list has the same number of entries as the shortest list list a b list2 lt d e T Zip listi list2 plus Zip listi list2 mult Zip listi list2 power To produce the list with the number of entries equal to the longer list use a default value as additional parameter Zip listi list2 plus 100 a d b e f 100 Add Replace or Remove List Entries To add new entries to the end of a list use the append command or the dot operator list a b c list append list d e f list list 1 2 3 4 la bc d e f To concatenate lists use the operator dot or its functional form _concat listi i19 a b c list2 t 3 t 0 3 list3 list1 list2 list4 concat list2 list la b c 0 1 8 27 01 8 27 a b c You can replace an entry of a list list 8 D c d e list 1 newEntry list 2 lt T 2 3 list 1 matrix 1 2 3 5 6 71195 list a 7 ch newEntry 1 2 3 c d I2 To remove an entry from a list use the delete command list a b c d e T delete list 1 list Lists 9 17 5 Programming Fundamentals Sets 9 18 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Sets on page 5 18 Access Set Elements on page 5 19 Operate on Sets on page 5 20 Add Replace or Remove Set Ele
255. and providing numerical routines to convert the input parameters to some numerical data that are to be sent to the renderer An arbitrary number of such primitives can be collected to form a graphical scene Finally a call to plot passing a sequence of all primitives 1n the scene invokes the renderer to draw the plot The following example shows the graph of the function f x x sin x At the point xo f xo a graphical point is inserted and the tangent to the graph through this point 1s added f x gt x sin x x0 1 2 dx 1 g plot Function2d f x x 0 2 PI p plot Point2d xO f x0 t plot Line2d xO dx f xO f xO dx xO dx f xO f x0 dx The picture is drawn by calling plot plot g p t 6 79 6 Graphics and Animations 6 80 Each primitive accepts a variety of plot attributes that may be passed as a sequence of equations AttributeName AttributeValue to the generating call Most prominently each primitive allows to set the color explicitly g plot Function2d f x x 0 2 PI Color RGB Blue Alternatively the generated objects allow to set attributes via slot assignments of the form primitive AttributeName AttributeValue as in p Color RGB Black p PointSize 3 0 unit mm t Color RGB Red t LineWidth 1 0 unit mm The help page of each primitive provides a list of all attributes the primitive 1s reacting to Certain att
256. and select Turn full keyboard access on or off This table lists common MuPAD shortcuts Action Microsoft Windows linux Apple Macintosh Insert calculation Ctrl Shift lI Ctrl Shift I Cmd 4Shift I Insert text above Ctrl Shift T Ctrl Shift T Cmd Shift T Display Tab T T autocomplete suggestions ab ab Select contents of F7 F7 F7 region Move cursor to Ctrl Alt Shift Ctrl Alt Shift Cmd Alt RIGHT closing right RIGHT RIGHT delimiter 2 99 2 Notebook Interface Adin Mio Windows nux Apple Macintosh Move cursor to Ctrl Alt Shift Ctrl Alt Shift Cmd Alt LEFT the opening left LEFT LEFT delimiter To correct a mismatched delimiter place the cursor to the right of the closing delimiter and press the Tab key 2 100 Use Mnemonics Use Mnemonics Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Using mnemonics you can access menu items and buttons Mnemonics are underlined on the menu item or button For example on the File menu the F in File is underlined which indicates that Alt F opens the menu The Macintosh platform does not support mnemonics Some versions of Windows operating system do not automatically show the mnemonics on the menu For example you might need to hold down the Alt key while the tool is selected to see the mnemonics on the menus and buttons Use the Windows Control Panel to set preferences for underlining keyboard shortcuts See the
257. animated version and details The following picture demonstrates hatched areas inside curves See the examples on the help page of plot Hatch for details 6 6 Gallery Other 2D examples The following picture shows an imported bitmap inside function plots See section Importing Pictures for details 6 Graphics and Animations The following picture shows some frames of an animation of the perturbed orbit of a small planet kicked out of a solar system by a giant planet after a near collision See section Example 3 for details of the animation The following picture shows three solution curves of an ODE inside the directional vector field associated with the ODE See the examples on the help page of plot VectorField2d for details Gallery 6 9 6 Graphics and Animations The following picture shows the Mandelbrot set together with two blow ups of regions of special interest See the examples on the help page of plot Density for details 6 10 Gallery The following picture shows several rotated copies of a function graph See the examples on the help page of plot Rotate2d for details 6 11 6 Graphics and Animations 9 The following picture shows a data plot of type plot Bars2d See the examples on the help page of plot Bars2d for details Gallery The following picture shows the image of a rectangle in the complex plane under the map z sin z See the examples on the help page
258. ansion does not exist for the following expression MuPAD throws an error taylor arccot x x Error Cannot compute a Taylor expansion of arccot x Try series for a more gener You can represent the following expression by a Taylor series around x 1 To compute the series expansion around a nonzero value of a variable specify the value For example compute the Taylor series expansions around x 1 for the following expressions taylor ln x x 1 taylor arccot x x 1 F 2 F 3 F 4a F 5 F 5 3 x 1 x l1 x 1 x 1 x 1 Afr Y x 1 7 M0 M C5 Yt Ol x 1 2 3 4 5 6 _ d 1 F 1 A F 3 Kk 1 3 T X t d J z x J x J O x _ 1 6 4 2 12 40 i The taylor command returns results in the form of Taylor series including the order term 0 To convert the results to a regular polynomial expression without the O term use the expr command s taylor sin x exp x x expr s 3 3 5 _6 ET x x 4X X 4X alr Vidi d a Compute Taylor Series for Multivariate Expressions Compute Taylor Series for Multivariate Expressions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To compute a series expansion for a multivariate expression use the mtaylor command When expanding multivariate expressions list all variables and their values to specify the expansion point By default mtaylor computes the series expansion around the point whe
259. antics can behave unexpectedly Be careful when exposing reference semantics to your users because it can be confusing Calls by Reference and Calls by Value Suppose your task requires a function call to be able to change the values of its arguments The simple strategy is to return a modified copy of the arguments and overwrite the original object by using assignment For example replace matrix A with its upper row echelon form A linalg hilbert 3 M e Lu Lum eal A linalg gaussElim A Fi l 1 4E l l E 00 1 X 180 When working with large data sets and deep nested calls this strategy can cause memory problems Check the profiling report to see if your implementation has such problems For details see Profiling Your Code You also can achieve the calling by reference effect in MuPAD using Lexical Scoping Closures in Objects Domains in Objects Context Switching Lexical Scoping Instead of passing data as arguments of a procedure you can use a local variable of the outer procedure to store the data For the inner procedure this variable 1s not local Therefore the inner procedure can change the value of that variable and the variable 1s not destroyed after the inner procedure 1s executed f i 9 171 5 Programming Fundamentals 9 172 proc x local n incr begin n 0 incr gt n n 1 while x gt n do incr end while end proc This approach does not fit many
260. aphics from the main menu or right click to use the context menu 2 61 2 Notebook Interface File Edit View WNavigation Insert Format Notebook Window Help plotfuncsd cos x PI cos y FL x D 2 y 0 2 uA Export Graphics Graphics Size pen in Window Mem 5 MB TOs 2 Click Next in the Graphics Export Guide dialog box 2 62 Save and Export Graphics Graphics Export Guide This quide will help you exporting the graphics to an image file J Select the file format to which you want to export the 1mage 2 63 2 Notebook Interface 2 64 i Export Graphics Image Format and File Name Image format S PNG is a cP Export 4 The next steps depend on the file format you selected Follow the instructions 1n the Export Graphics dialog box Choose the Export Format The appearance of your exported graphics its quality and compatibility with other documents depend on the file format you select for saving graphics The set of file formats avallable for exporting graphics from a MuPAD notebook could be limited by your operating system and by the type of image Vector Formats You can save an image as a set of vector objects such as lines and geometric figures Images in vector formats are resolution independent and scale almost without quality loss These images can look different on different computers MuPAD supports the following vector graphics formats Save and Export Graphics XV
261. aragraph Format Indention Spacing Left 0 00 mm Top 0 00 First 0 00 mm Bottom 0 00 Right 0 00 mm Hide Help buttons Select this option if you do not want to see help buttons i in the dialog boxes Hide Welcome dialog Select this option if you do not want to see the welcome dialog box on startup 2 78 Set Font Preferences Set Font Preferences Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Select Generic Fonts on page 2 79 Default Generic Fonts for Microsoft Windows Macintosh and Linux on page 2 81 Select Generic Fonts You can specify three most frequently used fonts The MuPAD app uses these fonts as default font settings for its input output and text regions for text used in tables links and so on To change the default font settings for all new notebooks see Change Default Formatting on page 2 73 To specify the generic fonts for use in MuPAD notebooks 1 Select View gt Configure 2 Inthe left pane of the Configure MuPAD dialog box click Fonts 2 79 2 Notebook Interface Define substitute fonts for the named standard fonts You must restart MuPAD for these substitutions to take effect Generic Serif Times New Roman I Generic Sans Serif Arial User Interface Generic Monospace Courier New i mal LL o gt 3 Use the right pane of the dialog box to select the fonts you
262. ase you do not need to generate elements in the order in which you want them to appear 1n the list For example use this procedure to generate the list of the first n Lucas numbers The procedure creates a list of n entries where each entry is 0 Then it assigns the values to the first two entries To replace all other entries of the list with the Lucas numbers the procedure uses the for loop lucas proc n local L i begin L 0 n L 1 1 L 2 e 3 for i from 3 to n do L i L i 1 L i 2 end for L Data Collection end Measure the time needed to create a list of 10 000 Lucas numbers time lucas 10000 62 4004 If you use the procedure that creates an empty list and appends each generated Lucas number to this list then creating a list of 10 000 Lucas numbers takes much longer lucas proc n local L 1 begin r II L f Ls L L for i from 3 to n do L L L i 1 L 1i 2 end for L end time lucas 10000 421 2027 Known Maximum Length Collection If you cannot predict the number of elements that you will generate but have a reasonable upper limit on this number use this strategy 1 Create a list with the number of entries equal to or greater than the upper limit 2 Generate the data and populate the list 3 Discard the unused part of the list For example use the following procedure to create a list The entries of this list are modular squares of a numbe
263. at Notebook Window Help Bobasar itoourtseas matrix a b c d T ca Mem 7 MB TOs 2 D plots and animations 1 11 l Getting Started 1 12 FEN i E Oye File Edit View Wavigation Insert Format Notebook Window Help Boas SP DFA 00x1 800969s plot sin x cos 10 x exp 0 1 tal 41 0 dm 14 TW Ji Mem 9 MB TOs Shortcut to Access Standard MuPAD Functions Y File Edit View Navigation Insert Format Notebook Window Help plot sin x sin y 3D Mem 9 MB TOs Cmd f INS General Math and Plot Commands menus at the bottom of the Command Bar display the categorized lists of functions 1 13 l Getting Started 1 14 Expand Factor Normalize Evaluate Simplify Combine Rewrite Solve Calculus Power Series Matrices Polynomials Reset Session Access Help for Particular Command Access Help for Particular Command Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Autocomplete Commands on page 1 15 Use Tooltips and the Context Menu on page 1 16 Use Help Commands on page 1 18 Autocomplete Commands MuPAD helps you complete the names of known commands as you type them so that you can avoid spelling mistakes Type the first few characters of the command name and then press Ctrl space If there is exactly one name of a command that starts with these letters MuPA
264. at Cy A matrix 2 4 a b c 1 2 3 aodoed H a4 If you declare matrix dimensions and enter rows or columns longer than the declared dimensions MuPAD returns the following error message ft Cp A matrix 2 1 a b c 1 2 3 Error The number of columns does not match Dom Matrix Dom ExpressionField 9 36 Vectors and Matrices As a shortcut for providing elements of a matrix you can use the gt command A matrix 5 5 i j gt i j 12 3 4 53 24 6 8 10 3 6 9 12 15 48 12 16 20 X5 10 15 20 25 Create Vectors To create a vector also use the matrix command The command matrix x yl z creates a column vector As a shortcut for creating a column vector use a matrix x y z r X E i E To create a row vector declare the vector dimensions or use double brackets b1 matrix 1 3 x y z 5 b2 matrix x y Z x y z x y z Combine Vectors into a Matrix To create a matrix you also can combine vectors by using the concatenation operator v matrix 1 2 3 w matrix 4 5 6 A i V W d a 5 37 5 Programming Fundamentals hy Ch un fe ho NR il QUU La3 423 CN Un Jp EM d Matrices Versus Arrays Matrices and arrays are different data types Movies Ae Data containers with defined standard Data containers for storing only mathematical operations Slow access to data Fast access
265. at node The default value can be overwritten by another value at each node further down in the sub tree for example finally by a specific value in the primitives In the following call the default color red is set in the canvas This value is accepted and used in the first scene The second scene sets the default color blue overriding the default value red set in the canvas Additionally there is an extra point with a color set explicitly to black This point ignores the defaults set further up 1n the tree hierarchy extrapoint plot Point2d 1 4 0 5 PointSize S3 unit mm PointColor RGB Black 1 plot Scene2d points extrapoint S2 plot Scene2d points2 extrapoint PointColor RGB Blue Attributes plot plot Canvas S1 S2 PointColor RGB Red Y 10 0 9 0 8 0 7 0 6 0 5 0 4 0 3 02 0 1 0 0 1 2 3 0 2 0 4 E T 0 6 0 8 4 0 The following call generates the same result Note that the plot command automatically creates a canvas object and passes the attribute PointColor RGB Red to the canvas plot S1 S2 PointColor RGB Red 6 113 6 Graphics and Animations 6 114 Yao Y 40 0 9 0 8 en 0 6 l 0 7 0 4 E 0 6 02 0 5 e 0 0 7 ET 1 2 s 3 0 3 02 E 0 2 D 4 r 0 1 OG xm D 8 X 1 0 We note that there are different primitives that react to the same attribute We used LinesVisible in the previous sec
266. ata Now you can analyze the sample For example compute the correlation between the US population and total world population stored in the second and third columns of the sample Use the float function to approximate the result float stats correlation s 2 3 0 99724 6119 The correlation coefficient 1s close to 1 Therefore the world population data and the US population data are linearly related Now compute the correlation coefficient for the population growth rates stored in the fourth and fifth columns of the sample In this case you can omit the float function MuPAD returns a floating point result because the input data contains floating point numbers Import Data stats correlation s 4 5 0 2127844699 The correlation coefficient indicates that the data for the world population growth rates and the data for the US population growth rates are not linearly related 3 265 3 Mathematics Store Statistical Data 3 266 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD offers various data containers such as lists arrays tables and so on to store and organize data For details about the MuPAD data structures see Data Structures Although you can use any of these data containers to store statistical data the following containers serve best The reason is that many functions of the Statistics library accept these data containers as input parameters
267. ate the MuPAD engine connected to the notebook by selecting Notebook gt Disconnect The new engine starts when you evaluate any command in the notebook Clear the history table by setting the value of variable HISTORY to 0 This variable specifies the maximum number of elements in the history table To restore the default value of HISTORY enter delete HISTORY HISTORY O delete HISTORY HISTORY 20 For more information about the history mechanism in MuPAD see History Mechanism For further computations also restore the default value of Pref report Pref report NIL Generate Memory Usage Reports for Procedure Calls MuPAD can print memory usage information when you execute a procedure in the tracing mode In this case the system reports memory usage on each step of a procedure call For example create the recursive procedure juggler that computes the Juggler number sequence for any initial positive integer n juggler proc n Type PosInt begin J append J n if n 1 then return J 9 113 5 Programming Fundamentals 9 114 end if if testtype n Type Even then juggler floor n 1 2 else juggler floor n 3 2 end if end proc Suppose you want to see the memory usage report for every call to this procedure First call the prog trace function with the Mem option Then switch execution of the juggler procedure to the tracing mode prog trace Mem prog trace juggler Now when yo
268. atics 3 90 op diff Y t A Y B E Now specify the set of functions x y t for which you want to solve the system Solve the system E if or c y t t x t y t E x t x t 7230 1 ode solve s x t y t P ya a cos 4 2 1 9 v a sin 2 t Un x t e cosl y2 t o e sin 2 f o D oo 1 7 U 7 2 where o o aL 1 L f fO M gt Ff v fF amp a C37 sin4 2 11 2 4 2 eosl 2 t 6rainly a 1 3 4 2 areoly 2r n gs P T C36 em V2 0 12 v2 sin 2 2 6 recon 2 2 8 v2 esinl 2 1 5 If you are solving several similar systems of ordinary differential equations in a matrix form create your own solver for these systems and then use it as a shortcut The solver for such systems must be a function that accepts matrices as input arguments and then performs all required steps For example create a solver for a system of the first order linear differential equations in a matrix form Y A Y 8 where the components of functions depend on the variable t solveLinearSystem A B Y gt solve ode op diff Y t A Y B op Y The solveLinearSystem function accepts matrices as input parameters creates a matrix of equations extracts these equations to a set and solves the system Y matrix x t y t A matrix 1 2 3 1119 B matrix 2 t solveLinearSystem A B Y Solve Ordinary Differential Equations an
269. ation mechanism to function names For example assign the function call f m to the identifier y y f PI f x Now assign the function sin to f If you evaluate the identifier y the system replaces the identifier f by its value sin Then the system evaluates the call s in m and returns 0 f sin y If you change or delete the value of f the evaluation of f n changes accordingly f cos y 1 delete f y E d es y 4 E l E 3 7 3 Mathematics Level of Evaluation Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB What Is an Evaluation Level on page 3 8 Incomplete Evaluations on page 3 9 Control Evaluation Levels on page 3 11 What Is an Evaluation Level The value of an identifier can contain arbitrary MuPAD objects including identifiers If the value of an identifier contains another identifier MuPAD tries to find the value of that second identifier If the value of that second identifier also contains identifiers MuPAD tries to find their values and so on Typically evaluation continues until the system replaces all 1dentifiers that have values by these values The final result can contain identifiers that do not have assigned values This recursive evaluation process is called a complete evaluation Each evaluation step in this recursive process is an evaluation level For example evaluate the value of the identifier y y a tx a
270. atrix row dimension Dom Matrix Di If you specify matrix dimensions and then enter rows or columns longer than the declared dimensions MuPAD also issues an error A matrix 2 3 1 2 3 4 5 6 7 8 9 Error The number of list entries does not match matrix row dimension Dom Matrix Di The matrix command creates an object of the type Dom Matrix A matrix 1 2 3 4 5 6 type A Dom Matrix 3 173 3 Mathematics Create Vectors 3 174 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Vectors in MuPAD do not form a separate data type As matrices vectors belong to the type Dom Matrix To create a row or a column vector use the matrix command and specify one of the dimensions to be 1 For example create a row vector that contains five elements matrix 1 5 1 2 3 4 51 12345 Now create a column vector of five elements matrix 5 1 1 2 3 4 5 LAO fe UO po ee If you do not specify the dimensions the matrix command creates a column vector matrix x y z Fach E Create Special Matrices Create Special Matrices Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD provides functions for creating special types of matrices such as identity diagonal Hilbert Toeplitz and other matrices For example create the 3x3 identity matrix matrix identi
271. book Interface Tl Export Graphics Create Movie or snapshot Export whole animation sequence 3 Export current image of animation only Export 4 Select the format for saving 1mages of the sequence and the file name A sequence of numbers automatically appends to the file name you enter For example when you enter image jvx you get the following sequence of files image 1 jvx image 2 jvx and so on This sequence of file names displays below the entry field for the file name 2 68 Save and Export Graphics TWX is the geometry description format of JavaView JavaView allows display of interactive graphics on web pages see www javaview de The animation is exported as a sequence of image files erare mei cs The image files will be named image 1 jvx image 2 jvx image 3 vx 5 Select the number of frames per second This number defines the total number of image files you create 2 69 2 Notebook Interface 2 70 Set Preferences for Notebooks Set Preferences for Notebooks Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Preferences Available for Notebooks on page 2 71 Change Default Formatting on page 2 73 Scalable Format for Copying Graphics on page 2 74 Preferences Available for Notebooks To change preferences for displaying the contents of notebooks Select View gt Configure 2 Inthe left pane of the Configure MuPAD d
272. c objects Note With VisibleAfter toO an object is invisible from the start of the animation until time tO Then it will appear and remain visible for the rest of the animation Note With VisibleBefore t1 an object is visible from the start of the animation until time t1 Then it will disappear and remain invisible for the rest of the animation These attributes should not be combined to define a visibility range from tO to t1 Use the attribute VisibleFromTo instead Note With VisibleFromTo t0 t1 an object is invisible from the start of the animation until time tO Then it will appear and remain visible until time t1 when it will disappear and remain invisible for the rest of the animation We continue the example of the previous section 1n which we defined the following animated points p1 plot Point2d 1 sin a a O PI Color RGB Red PointSize 5 unit mm TimeBegin O TimeEnd 5 I p2 plot Point2d O sin a a O PI Color RGB Green PointSize 5 unit mm TimeBegin 6 TimeEnd 12 p3 plot Point2d 1 sin a a O PI Color RGB Blue PointSize 5 unit mm TimeBegin 9 TimeEnd 15 p2 VisibleAfterEnd FALSE p3 VisibleBeforeBegin FALSE 6 143 6 Graphics and Animations 6 144 We add a further point p4 that is not animated We make it invisible at the start of the animation via the attribute VisibleFromTo It is made visible after 7 seconds to disap
273. cPeriodic numlib cornacchia numlib decimal numlib divisors numlib factorGaussInt numlib fibonacci numlib fromAscii numlib g adic numlib ichrem numlib igcdmult numlib invphi numlib ispower numlib isquadres numlib issqr numlib jacobi numlib lambda numlib legendre numlib lincongruence numlib mersenne numlib moebius numlib mroots numlib msqrts numlib numdivisors numlib numprimedivisors numlib omega numlib order numlib phi numlib pi Use the MuPAD Libraries numlib primedivisors numlib primroot numlib proveprime numlib reconstructRational numlib sigma numlib sqrt2cfrac numlib sqrtmodp numlib sumOfDigits numlib sumdivisors numlib tau numlib toAscii To see brief information about a particular library function use the mouse pointer to hover the cursor over the function name For more information about the library and for information about the library functions enter numlib To see the implementation of a library function use the expose command expose numlib tau proc a name numlib tau begin if args 0 lt gt 1 then error message symbolic numlib IncorrectNumberOfArguments else if not testtype a Type Numeric then return procname args else if domtype a DOM INT then error message symbolic numlib ArgumentInteger end if end if end if numlib numdivisors a end proc Avoid Name Conflicts Between MuPAD Objects and Library F
274. ccepts direct and inverse trigonometric functions direct and inverse hyperbolic functions diff D erf exp fact gamma harmonic piecewise and more See the rewrite help page for the complete list of target functions If You Want to Simplify Results Further If You Want to Simplify Results Further Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Increase the Number of Simplification Steps on page 3 103 Apply Several Simplification Functions on page 3 104 Use Options on page 3 105 Use Assumptions on page 3 106 Increase the Number of Simplification Steps When simplifying a complicated expression MuPAD can return results that would benefit from further simplifications Suppose you want to simplify the following expression f 4 PI 3 1 2 3 PI 1 3 4 2 1 2 3 1 2 2 I 8 2 3 cos 3 arccos x t I Haft am le E cos 3 arccos x 153 19 vr v 242i o Lag First try calling the general simplifier simplify simplify f 435 waa zl 21 f 2 a xx 1 v 22i 0 9 The returned expression has an even shorter representation To simplify this result further call the Simplify command Simplify fF 3 103 3 Mathematics 3 104 2m fi x 2 1 y ig J 1 i 4 ate 3 3 You can simplify the result even more by increasing the number of steps Simplify f Steps 150
275. cipalValue If an expression can be integrated in a strict mathematical sense and such an integral exists the Cauchy principal value coincides with the integral int X 2 X 1 1 int x 2 x 1 1 PrincipalValue ad ban fal 3 147 3 Mathematics If MuPAD Cannot Compute an Integral Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Approximate Indefinite Integrals on page 3 148 Approximate Definite Integrals on page 3 149 If the int command cannot compute a closed form of an integral MuPAD returns an unresolved integral int sin sinh x x J sin sinh x dx If MuPAD cannot compute an integral of an expression one of the following reasons may apply The antiderivative does not exist in a closed form The antiderivative exists but MuPAD cannot find it Try to approximate these integrals by using one of the following methods e For indefinite integrals use series expansions Use this method to approximate an integral around a particular value of the variable For definite integrals use numeric approximations Approximate Indefinite Integrals If int cannot compute an indefinite integral in a closed form it returns an unresolved integral F int cos x sqrt 1 x 2 x 3 148 IF MuPAD Cannot Compute an Integral cos x d F Ff V x To approximate the result around some point use the series function For example approximat
276. complete elliptic integral of the second kind Elliptic integral of the third kind Complementary complete elliptic integral of the third kind Elliptic nome Lambert W Function omega Function The 1ambertW function represents the solutions of the equation y e x You can use the function as input for your computations MuPAD can return results 1n terms of this function 3 233 3 Mathematics Floating Point Arguments and Function Sensitivity 3 234 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Use Symbolic Computations When Possible on page 3 235 Increase Precision on page 3 235 Approximate Parameters and Approximate Results on page 3 237 Plot Special Functions on page 3 238 Particular choices of parameters can reduce some special functions to simpler special functions elementary functions or numbers Nevertheless for most parameters MuPAD returns the symbolic notation of a special function In such cases you can approximate the value of a special function numerically To approximate a special function numerically use the float command or call the special function with floating point arguments When approximating the value of a special function numerically remember that floating point results can be extremely sensitive to numeric precision Also floating point results are prone to roundoff errors The following approaches can help you recogn
277. conflicts with other library functions If this 1s found to be inconvenient then the routines of the misc package may be exported via use E g after calling use misc genassop the function misc genassop may be called directly myplus genassop plus O All routines of the misc package are exported simultaneously by use misc The functions available in the misc library can be listened with info misc We would especially like to thank Raymond Manzoni for contributing the function misc pslg 8 25 8 More Information About Some of the MuPAD Libraries Numeric Algorithms Library 8 26 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The numeric package provides algorithms from various areas of numerical mathematics The package functions are called using the package name numeric and the name of the function E g use numeric solve equations unknowns to call the numerical solver This mechanism avoids naming conflicts with other library functions If this is found to be inconvenient the routines of the numeric package may be exported via use E g after calling use numeric fsolve the function numeric fsolve may be called directly fsolve equations unknowns All routines of the numeric package are exported simultaneously by use numeric Note however that presently naming conflicts with the functions indets int linsolve rationalize solve and sort o
278. csin x end proc When you call the procedure p it checks whether the input argument belongs to the specified interval p 1 2 p 1 p 0 al ba I p 10 Error invalid number Choose a value from the interval 1 1 p Now write the simple wrapper procedure f that calls the procedure p f proc x begin p x end proc When the wrapper procedure f calls p the procedure p does not check its arguments because testargs returns the value FALSE f 10 Test Arguments arcsin 10 The testargs function also allows you to switch to the argument checking mode In this mode MuPAD checks arguments of all procedures regardless of how a procedure is called This mode can slow down your computations Use this mode only for debugging your code To switch to the argument checking mode set the value of testargs to TRUE testargs TRUE In the argument checking mode the procedure p checks its argument during interactive and internal calls p 10 Error invalid number Choose a value from the interval 1 1 p f 10 Error invalid number Choose a value from the interval 1 1 p Always restore testargs to its default value FALSE after you finish debugging testargs FALSE 9 59 5 Programming Fundamentals Verify Options 9 60 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For many standard MuPAD procedures you can use different options If a MuPAD pr
279. ction cannot replace a part of the branch in the expression tree subs a b c b c d subs a b c lla D C I I d ad a b c l After substitution subs does not evaluate the resulting expression although it can simplify the expression You can enforce evaluation of the modified subexpressions by using the EvalChanges option subs ln X x E subs l1n X x E EvalChanges Infe 1 subs replaces both free and dependent identifiers In some cases replacing dependent identifiers can cause invalid results subs int f x x 0 1 f x x 100 l f 100 J f 100 d100 0 subsex analyzes associative system operators and can replace part of the branch in the expression tree subsex a b c b c d subsex a b c 1 b c d 9 153 5 Programming Fundamentals 9 154 subsex does not evaluate the resulting expression subsex ln x a 1 xX a E 1 In e Use eval to evaluate results returned by subsex eval subsop replaces only entire branches in the expression tree of an expression the same way as Subs When using subsop you must know the position index of the branch inside the expression in internal order that might differ from the output order used to represent the expression on screen To find the internal index of a particular subexpression use the op function ex sin a x b cos a x b op ex cos 5b a x sin 5 a x op ex 2 sin 5 a x
280. ction3d shading XLinesVisible TRUE FALSE visibility of TRUE Function3d x parameter lines YLinesVisible TRUE FALSE visibility of TRUE Function3d y parameter lines MeshVisible TRUE FALSE visibility of FALSE Function3d the internal triangulation LineWidth 0 35 unit mm physical line 0 35 unit mm Function3d width 6 75 6 Graphics and Animations 6 76 attribute name __ possible values browser entry example LineColor RGB or RGBa color of RGB Black Function3d color parameter lines 0 25 Besides the usual linear plots logarithmic plots are also possible by choosing an appropriate CoordinateType With Scaling Constrained the unit box in model coordinates a square in 2D a cube in 3D is displayed as a unit box With Scaling Unconstrained the renderer applies different scaling transformation in the coordinate directions to obtain an optimal fit of the picture in the display window This however may distort a circle to an ellipse With Scaling Constrained a 2D circle appears on the screen like a circle a 3D sphere appears like a sphere 2D functions are preprocessed by a semi symbolic search for discontinuities to improve the graphical representation near singularities and to avoid graphical artifacts If continuous functions are plotted one may gain some speed up by switching off this search with DiscontinuitySearch FALSE When very time consuming plots are to be created it may be useful to creat
281. ctions SubgridVisible TRUE FALSE visibility of minor grid lines in all directions AdaptiveMesh integer gt 0 depth of the adaptive mesh Axes Automatic Boxed axes type Boxed Frame Origin AxesVisible TRUE FALSE visibility of all axes TRUE AxesTitles string string titles of the axes xm oA string CoordinateType LinLinLin linear linear linear LinLinLin LogLogLog linear logarithmic logarithmic linear log log plot Frames integer gt 0 number of frames of 50 the animation LegendVisible TRUE FALSE legend on off TRUE FillColorType Dichromatic color scheme Dichromatic Flat Functional Monochrome Rainbow Mesh integer gt 2 integer number of major 25 25 gt 2 mesh points Submesh integer gt 0 integer number of minor gt 0 mesh points Easy Plotting Graphs of Functions Scaling Automatic scaling mode Unconstrained Constrained Unconstrained TicksNumber None Low Normal number of labeled Normal High ticks at all axes ViewingBoxZRange zmin zmax restricted viewing Automatic range 1n z direction ZRange zmin zmax restricted viewing Automatic range 1n z direction equivalent to ViewingBoxZRange In the following example the default mesh of 25 x25 sample points used by plotfunc3d does not suffice to create a sufficiently resolved plot plotfunc3d sin x 2 y 2 x 3 3 y 3 3 6 51 6 Graphics and Animations We increase the number of numerical
282. ctly with the new function sin x x cos x However if you implement a function that is not composed of the standard MuPAD objects for example a new special function you must distribute the knowledge about Integrate Custom Functions into MuPAD the mathematical meaning of the new function to standard MuPAD functions such as diff expand float and so on This extra task is necessary for integrating the new function with the rest of the system For example you might want to differentiate an expression that contains both the new function and some built in functions and such differentiation 1s only possible via the MuPAD differentiation routine Therefore this routine must know how to handle the new symbol MuPAD uses function environments domain type DOM FUNC ENV to integrate functions into the system A function environment stores special function attributes slots in an internal table Whenever an overloadable system function such as diff expand or float encounters an object of type DOM FUNC ENV it searches the function environment for a corresponding slot If a system function finds the appropriate slot 1t calls that slot and returns the value produced by the slot All built in MuPAD functions are implemented as function environments domtype sin domtype exp DOM FUNC ENV DOM FUNC ENV You can call a function environment as you would call any MuPAD function or procedure sin 1 7 exp 1 0 0 9916648105 2 7182
283. d 4 dd incr e 9 173 5 Programming Fundamentals 9 174 LA LA The primitives of the plot library use this strategy For example when you execute the following code the domain plot Function2d overloads the slot function f plot Function2d sin x x PI PI f Color RGB Green Context Switching The context function and option hold also let you implement the calling be reference effect in your procedures option hold prevents the procedure from evaluating its arguments before executing the code in the procedure body The context function lets you perform operations as if they occur in the calling procedure For example in this code option hold prevents the incr procedure from evaluating its argument Therefore the system does not copy the value of X to a new memory block incr proc x option hold begin context hold assign x x 1 end proc operator incr Prefix 500 While executing this procedure the system performs the assignment operation in the context of the procedure f the calling procedure for incr Thus incr changes the value of the argument n with which it was called f proc x local n begin n 0 while x gt n do ttn end while Calls by Reference and Calls by Value end proc If you use the operator on an unchangeable object MuPAD throws an error For example you cannot assign the value 2 to the value 1 1 Error The left side is invalid
284. d Systems v6 e coly r a v e sinl 6 t 2 Fa i F Fe a fos fr FE ys fa l x f cos 6 t o e sin 6 t o y t 5 where c C394 e 7 30 siny 11 37 y6 cos 6 il 42 tain 6 1 7 y6 reoaly i l 147 I a D F y i F F 08 1 y 5 e 4374 6 anla 30 sla 6 J4 2teosls 6 1 7 v ramla 1 o C38 AT 4 6 anly 6 1130 co T t coal 6 z 7 y rany 6 t Plot Solutions of Differential Equations Suppose you want to solve the following equation The solver returns the results as a set even if the set contains only one element f ode solve y x x y x y 0 0 y 0 1 3 y x The plotting functions in MuPAD do not accept sets To plot the solution access the elements of a solution set using square brackets or the op command plotfunc2d f 1 x 3 3 3 51 3 Mathematics If you have more than one element of a solution set you can access a particular element For example pick the second element of the solution set for the system of ODEs f ode solve iW X z x 2 X y x 2 2 X y 0 0 z 0 1 1y x z x Fy oa 2 1 m x I4 1 The solver returns results for a system as a set that contains a list To open the set and access the list use square brackets or the op command To access a particular entry of this list use square brackets Tf 1 2 op f 2 3 92 Solve Ordinary Differential Equations and Systems a oxl2
285. d conflicting hints the first hint is used Hints are implemented internally and cannot be switched off by the user Note however that the hints concept only concerns default values for attributes You can always specify the attribute explicitly if you think that a default value or a hint is not appropriate E g we explicitly request Axes Boxed in the following call plot plot Piechart3d 20 30 10 7 20 13 Titles 1 20 2 30 3 10 4 7 5 20 6 13 Axes Boxed Attributes AED 1 0 0 06 4 C2 GO Gs D4 tS 58 1 6 Y The Help Pages of Attributes We have a brief look at a typical help page for a plot attribute to explain the information provided there The item Acceptable Values states the type of the number n that is admissible when passing the attributes UMesh n VMesh n etc The item Attribute type inherited states that these attributes may not only be specified in the generating call of graphical primitives They can also be specified at higher nodes of a graphical tree to be inherited to the primitives in the corresponding sub tree see section Inheritance of Attributes The sections Object types reacting to UMesh etc provide complete listings of all primitives reacting to the attribute s together with the specific default values The Details section gives further information on the semantics of the attribute s Finally
286. d edi E The int and diff functions compute the derivative and the integral of each element of a matrix A matrix 2 2 x x 2 x 3 x 4 int A x diff A x Compute with Matrices 2 Aa r r 2 3 457 r r 4 35 The expand function expands each element of a matrix A matrix 2 2 x x 1 2 x x 1 x x 4 expand A 7 x x 42x41 2 2 ix x x 4x The map function applies the specified function to all operands of each element of a matrix A B matrix 3 3 1 2 3 Diagonal map A sin f sin 1 0 0 0 sinf2 Q0 0 0 sm 3 The float function converts each element of a matrix or numerical subexpressions of each element of a matrix to floating point numbers float B 0 8414709848 0 0 0 0 9092974268 0 0 0 0 1411200081 The evalAt function and its shortcut substitutes the specified object by another specified object and then evaluates each element of a matrix A matrix 2 2 x x 2 x 3 x 4 A x 2 3 185 3 Mathematics 3 186 dq The subs function returns a copy of a matrix in which the specified object replaces all instances of another specified object The function does not evaluate the elements of a matrix after substitution A matrix 2 2 x x 2 x 3 x 4 subs A x exp y The has function determines whether a matrix contains the specified object A matrix 2 2 x x 2 x 3 x 4 has A x 3 has A x 5 TRUE FALSE The
287. d of returning the previous result stored in the remember table the system reevaluates the result and updates the remember table DIGITS 50 f 3 0 33333333333333333333333 333333 3333333333333333333 For further computations restore the default value of DIGITS and delete f delete DIGITS f Clear Remember Tables In some cases the remember mechanism can lead to incorrect results For example if a nested procedure uses the remember mechanism and you redefine the inner procedure MuPAD does not recognize the changes and does not reevaluate the procedure call Create the following procedure f as a wrapper for the MuPAD heaviside function Use prog remember to enable the remember mechanism for the procedure f f proc x begin heaviside x end f prog remember f Now compute the Heaviside function for the values 10 0 and 10 MuPAD uses the value heaviside 0 1 2 f 10 f 0 f 10 0 ba You can define a different value for heaviside 0 First use the unprotect function to be able to overwrite the value of heaviside Then assign the new value to heaviside 0O unprotect heaviside 5 119 5 Programming Fundamentals 5 120 heaviside 0 0 Despite the new value heaviside 0 0 the wrapper procedure f returns the old value 1 2 f 0 ta ho The result of the procedure call f 0 does not change because the system does not reevaluate this result It finds the result in the re
288. d takes advantage of the gt operator However if some users relied on the procedure f to recognize equal complex numbers their code breaks when they use the updated version T I I Error Cannot evaluate to Boolean leequal Evaluating f If you do not create and use a test script for the procedure f you might never realize that the procedure stopped working for the particular choices of arguments Even if you tested this choice of arguments before you might forget to test 1t for the updated version Writing a test script and running it every time when you or somebody else update your code helps to avoid unexpected loss 1n functionality 5 129 5 Programming Fundamentals Write Single Tests 5 130 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The prog test function is the basic testing tool in MuPAD This function compares the actual result of computations with the expected result that you specify For example create the procedure f f proc a Type Numeric b Type Numeric begin if a bor a b then return a else return b end_if end proc To test the procedure use the prog test function If the test does not reveal any problems prog test returns the void object nul1 and does not print anything prog test f I I I If the procedure call tested by prog test errors or if actual results differ from expected results prog test prints infor
289. d the Time Range By default an animation consists of 50 different frames The number of frames can be set to be any positive number n by specifying the attribute Frames n This attribute can be set in the generating call of the animated primitives or at some higher node of the graphical tree In the latter case this attribute 1s inherited to all primitives that exist below the node With a amin amax Frames n the i th frame consists of a snapshot of the primitive with 6 135 6 Graphics and Animations 6 136 Increasing the number of frames does not mean that the animation runs longer the renderer does not work with a fixed number of frames per second but processes all frames within a fixed time interval In the background there is a real time clock used to synchronize the animation of different animated objects An animation has a time range measured by this clock The time range is set by the attributes TimeBegin t0 TimeEnd t1 or equivalently TimeRange t0O t1 where tO t1 are real numerical values representing physical times in seconds These attribute can be set in the generating call of the animated primitives or at some higher node of the graphical tree In the latter case these attributes are inherited by all primitives that exist below the node The absolute value of tO is irrelevant if all animated objects share the same time range Only the time difference t1 tO matters It 1s an approximation of t
290. d x O Use the third parameter in taylor to specify the order of series expansion For example compute the series expansions approx1 specifying the truncation order 3 Compare the result with the series expansion computed for the default order exact exp x approx taylor exp x x approx2 taylor exp x x 2 l x Ol x Control Number of Terms in Series Expansions Plot the exact expression exact and its taylor series expansions approxi and approx2 in the same coordinate system The series expansion with more terms approximates the expression exp X better plot plot Function2d exact x PI PI Legend exp x Color RGB Red plot Function2d approx2 x PI PI Legend approximation of exp x up to O x 6 Color RGB Blue plot Function2d approx1 x PI PI Legend approximation of exp x up to O x 3 Color RGB Green y 20 15 10 5 Ip i a 3 2 1 1 2 3 exp x approximation of exp x up to Ox approximation of exp x up to O x 3 There are two ways to change the truncation order for series expansions Locally by passing the truncation order as the third parameter to taylor By using this parameter you specify the truncation order for a particular series expansion All other series expansions use the default order The parameter is available for the 3 161 3 Mathematics 3 162 following commands taylor mtaylor and series
291. daptive mesh AdaptiveMesh integer gt 0 depth of the Function3d adaptive mesh In 2D pictures generated by plotfunc2d singularities of a function are indicated by vertical lines vertical asymptotes unless DiscontinuitySearch FALSE is set Here 1s a table with the attributes for setting the style of the vertical asymptotes Attributes for Vertical Asymptotes attribute name possible values browser entry example VerticalAsymp TRUE FALSE visibility TRUE Function2d VerticalAsymp RGB color VerticalAsymp RGB color color es RGB Grey50 Function2d VerticalAsymp Dashed a style Dashed Dotted Solid VerticalAsymp 0 2 unit mm physical width 0 2 unit mm Function2d The colors of the functions plotted by plotfunc2d are chosen automatically The property inspector see section Viewer Browser and Inspector Interactive Manipulation allows to change these attributes Attributes for Lines attribute name __ possible values browser entry example LinesVisible TRUE FALSE visibility of lines TRUE Function2d switch this function on off LineWidth a line Function2d width 6 73 6 Graphics and Animations attribute name pee values browser entry example LineColor2 RGBeolr jFunction2d I M drawing style NN Fu as Dotted Solid line objects LineColorType Dichromatic color scheme for Flat Function2d Flat lines Functional Monochrome Rainbow LineColorFunc proced
292. ded minimum number of cells for a sample of n data elements is 2 72 7 The recommended method for defining the cells is to use the stats equiprobableCells function This function creates equiprobable cells when the underlying distribution is continuous q stats normalQuantile 0O 1 2 cells stats equiprobableCells 40 q Now call the stats csGOFT function to test the data sequence x For example compare X with the cumulative normal distribution function with the same mean and variance The stats csGOFT returns a large p value for this test Therefore the null hypothesis X is normally distributed with the mean equal to O and the variance equal to Perform chi square Test 1 2 passes this test Besides the p value stats CSGOFT returns the observed value of the chi square statistics and the minimum of the expected cell frequencies stats csGOFT x cells CDF stats normalCDF O 1 2 PValue 0 7728609833 StatValue 32 16 MintmalExpectedCellFrequency 25 0 The stats csGOFT enables you to test the data against any distribution function For example testing the sequence X against the probability density function gives the same result stats csGOFT x cells PDF stats normalPDF O 1 2 PVahie 0 7728609833 StatValue 32 16 MinmalExpectedCellFrequency 25 0 If you test the same data sequence X against the normal distribution function with different values of the mean and the variance stats
293. default setting of Pref typeCheck is Interactive Pref typeCheck Interactive To perform type checks in all procedure calls including internal calls set the value of Pref typeCheck to Always Pref typeCheck Always Now the system realizes that 2 3 is not a valid argument of the internally called procedure f g 2 3 Test Arguments Error The object 2 3 is incorrect The type of argument number 1 must be DOM INT Evaluating f To disable type checks in all procedure calls including interactive calls set the value of Pref typeCheck to None Pref typeCheck None Now the system does not check argument types in any procedure calls 9 2 3 f 2 3 bn j l ba To restore the default setting of Pref typeCheck use the NIL option Pref typeCheck NIL Check Arguments of Individual Procedures When writing a procedure 1n MuPAD you can include your own tests for the procedure arguments inside the procedure itself You can test types values or any other properties of the arguments of a procedure For example create the procedure that calculates the arcsine function of a real number Suppose you want to limit possible results of this procedure to real numbers In this case an input argument of the procedure must belong to the interval 1 1 To ensure that the procedure accepts only the values from this interval test the value of an input argument inside the procedure p proc x Dom Re
294. dentifier or indexed identifier that is different from the symbols used for the mandatory range specifications such as the names of the independent variables in function graphs The parameter must also be different from any of the protected names of the plot attributes Note Animations are created object by object The names of the animation parameters in different objects need not coincide In the following example different names a b are used for the animation parameters of the two functions plot plot Function2d 4 a x x 0 1 plot Function2d b x 2 x 0 1 b a a IA u Animations 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 0 An animation parameter is a global symbolic name It can be used as a global variable in procedures defining the graphical object The following example features the 3D graph of a bivariate function that 1s defined by a procedure using the globally defined animation parameter Further a fill color functionmycolor is defined that changes the color in the course of the animation It could use the animation parameter as a global parameter just as the function f does Alternatively the animation parameter may be declared as an additional input parameter Refer to the help page of FillColorFunction to find out how many input parameters the fill color function expects and which of the input parameters 1s fed with the animation parameter One finds that for plot Function3d the fill col
295. dialog box 2 23 2 Notebook Interface Format Expressions in Input Regions 2 24 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB You can change font style size and color of mathematical expressions in Text regions in the same way you format regular text See Choosing Font Style Size and Colors for more details For additional formatting of commands and expression in the input regions 1 Select Format gt Calculation in the main menu Format Expressions in Input Regions lantakan t ba OAT JEEDOORL MIUF Al File Edit View Navigation Insert Format Notebook Window Help i4 E daby a f n Characters aT 4 Q e9 ly Generic Manne Math aaa Piecewise solution Paragraph Calculation s The solution of the quadratic Table 0 is piecewise Here a b andc Jfdx f Ia f are symboli meters and x is ame are symbolic parameters and x i Frame fn po fo fi ab EU E iva F Page Piecewise objects often occur if i ymbolic parameters in addition to the variable A Increase Size D ecrease Size L x f x solve na x 2 b x c f b y b tac _ b y b 4 a de 2a 2a xy if Ek P Ud if a 0A b520 gH I Ta C ifa O0Ab 0aAc 0 e if a 0 b 0 cz0 General Math Plot Commands Change calculation format Mem 8 MB TU s 2 Set your formatting preferences You can define indentation spacing at the top and b
296. e 2e 1 Special Types of Ordinary Differential Equations Suppose the equation you want to solve belongs to the Clairaut type 0 7 ode y x x y x y x 8 y x solve o a f 43 2 iF 43 42 i 248 xy 25 xF 3 C33 px J2 Tow j 5 3 47 3 Mathematics 3 48 The solver recognizes the type of the equation and applies the algorithm for solving Clairaut equations To improve performance call the solver with the option Type Clairaut solve o Type Clairaut s gt F 3 2 a F 3 a 2 y 3 7 XJ 2 y 3 7 XJ 3 C333 C33 l t 5 9 The solver tries to recognize and tries to solve the following classes of ODEs Equoion ODE Solver Opin Abel differential equation y x ay x 4 a x y x d Bernoulli differential y x p x y g x v x Bernoulli equation where n 40 andn 1 Chini differential equation y x ay x a x y x Clairaut differential y x 2 x y x g y x Clairaut equation mE i m Exact first order ordinary y x f x y that can ExactFirstOrder differential equation be represented as M x y dx N x y dy 0 where ay ox Exact second order ordinary w x f x v x y x ExactSecondOrder differential equation if a first integral turns this equation into a first order ODE Linear homogeneous Dy O where Disa linear Homogeneous ordinary differential differential operator equation Lagrange differential y x x fly x gly Lag
297. e of 7 do return July of 8 do return August of 9 do return September of 10 do return October of 11 do return November of 12 do return December end case end If you call monthNumberToName with any integer from 1 to 12 the procedure returns the name of a month 9 90 Write Error and Warning Messages monthNumberToName 12 December If you call monthNumberToName with an integer greater than 12 the procedure terminates with the specified error monthNumberToName 13 Error Invalid number The number must not exceed 12 monthNumberToName Warning messages help you inform your users about potential problems in the algorithm These problems are typically minor and do not interfere with the execution of a procedure For example you can warn your users about limited functionality of a procedure or about implicit assumptions made by a procedure The following procedure uses the simplify function to simplify the fraction The function implicitly assumes that the variable x is not equal to a If your procedure uses the simplify function you can add the following warning for your users simplifyW proc a begin warning Assuming x lt gt expr2text a simplify x 2 a 2 x a end Now your procedure informs its users about the assumption simplifyW 10 Warning Assuming x lt gt 10 simplifyW x4 10 9 91 5 Programming Fundamentals Handle Errors 9 92 Note Use only in the MuPAD Noteboo
298. e Edit View Navigation Insert Format BUDHA Ay DIB E Evaluate From Beginning Evaluate To End f lim f Evaluate All I gt a Debug ff dx J L Iaf v Read Commands BE fr Si x54 Abbreviate Output Text Width Start Engine Disconnect Read and execute commands from a source file Mot Connected 5 Select the file you want to run 6 Start the Debugger from the notebook 9 80 Debug MuPAD Code in the Tracing Mode Debug MuPAD Code in the Tracing Mode Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD provides two alternatives for debugging your code First you can use the MuPAD GUI debugger to debug your code interactively observing execution of the code step by step Another alternative is to generate a report showing the steps that were taken while executing your code The mode in which MuPAD generates a report while executing a procedure domain method or function environment is called the tracing mode This mode is helpful for multistep procedures that require a long time to execute Use this approach to debug a particular procedure domain method or function environment for which you want to print a report When debugging you also can use the print and fprint functions for printing intermediate results produced by your code Suppose you want to create a procedure that computes the Lucas numbers The Lucas numbers are a sequence of integers The
299. e Font Style Size and Colors To change the font for a particular piece of text input expression or output expression 1 Select what you want to format 2 Select Format gt Characters from the main menu or use context menu 2 15 2 Notebook Interface 3 Inthe Character Format dialog box choose the font style font size font and background colors and effects The window at the bottom of the dialog box shows a preview of your changes H Character Format Font Generic Sans Serif Effects If you want to experiment with different fonts and see how the formatted text looks in your notebook click the Apply button This button applies formatting to the selected text and leaves the Character Format dialog box open You can change font and color of your text several times without having to open this dialog box for each change When you finish formatting click OK to close the Character Format dialog box 2 16 Format Text h Notebook MuPAD mm EE File Edit View Navigation Insert Format Notebook Window Help T z Command Bar Piecewise solutions f dm pg The solution of the quadratic equation a x bx c 0is piecewise Here a b and c are symbolic parameters and x is a symbolic variable Jfd x fof Taf ayok Ir Fi Ec a b ab the variable at n x f z e Ix if Ek P P General Math Plot Commands Mot Connected To format selected text you also can use the Format toolbar If yo
300. e Mo 7 ve sin pa 15 4 Compute the discrete Fourier transform keeping the data in its exact symbolic form fft numeric fft exactData Symbolic 3 254 Discrete Fourier Transforms g V3 y5 v53 O 3 Compute the inverse discrete Fourier transform of the resulting list Use the numeric invfft function with the Symbolic to prevent the data from the conversion to floating point values numeric invfft fft Symbolic lj F i Fi _ ls 27 V t V 2 w 2 0 sin T sio eee See l i 15 P j N l 3 j 4 Also you can clean results by removing very small terms To discard all entries of the result with absolute values smaller than 1 times the maximal absolute 19 DIGITIS value of all operands of the result use the Clean option This option also removes tiny imaginary terms that often appear as a result of roundoff effects For example without the Symbolic option the inverse Fourier transform from the previous example returns the following list of floating point values 1 numeric invfft fft 0 0 02079116908 1 162988943 10 L 0 4067366431 0 5877852523 1 162988943 10 1 When you use the Clean option the numeric invfft function discards small terms that appear 1n the second and fourth entries of the resulting list 3 295 3 Mathematics numeric invfft fft Clean 0 0 0 2079116908 0 4067366431 0 5877852523 3 256 Use Custom Patterns for Transform
301. e MuPAD Notebook Interface This functionality does not run in MATLAB Three types of mathematical properties are available in MuPAD Basic number domains such as the domain of integers the domain of rational numbers the domain of real numbers the domain of positive real numbers or the domain of complex numbers Intervals in basic number domains Residue classes of integers Often there are several equivalent ways to specify a property For example gt O Type NonNegative and Type Interval 0O infinity are equivalent properties Similarly Type Odd is equivalent to Type Residue 1 2 Some members of the Type library do not correspond to mathematical properties for example Type ListOf This table shows some examples of how to set properties on the 1dentifier or expression expr Note If expr is a list vector or matrix then only the syntax expr set is valid Do not use the syntaxes expr in set or relations such as expr gt Oorexpr lt O for nonscalar expr Property Recommended Way to Specify Alternative Way to Specify a a Property of expr Property of expr Real value R expr R expr Type Real Imaginary value F 1 expr R I or expr expr Type Imaginary in R I Complex value C This is expr C or expr in expr Type Complex a default value for most C MuPAD objects 8 28 Properties Property Recommended Way to Specify Alternative Way to Specify a a Prop
302. e current value of DIGITS is larger than 15 Compute Determinant Numerically The input data or computed data involves numbers that are larger than 10 or smaller than 10 Hardware floats cannot represent such numbers The precision of hardware and software arithmetic can differ Therefore the results obtained with the HardwareFloats and SoftwareFloats options also can differ For example compute the determinant of the 25 x25 Pascal matrix using each of the options Both numeric results are several orders larger than the correct answer because of the roundoff errors However the result obtained using software arithmetic 1s several orders closer to the correct answer P linalg pascal 25 detP det P float detP numeric det P SoftwareFloats numeric det P HardwareFloats 1 0 1669339685 0 1039468525 10 Another example of numerically ill conditioned matrices is the Hilbert matrices For example create the 20x20 Hilbert matrix compute its determinant symbolically and then approximate the result numerically H linalg hilbert 15 detH det H float detH 1 058542743 10 1 Now use the numeric det function to compute the determinant numerically numeric det H 3 822215463 1071 3 211 3 Mathematics 3 212 The numeric result obtained with the Sof twareFloats option is closer to the correct result numeric det linalg hilbert 15 SoftwareFloats 3 277553006 10 17
303. e expression a x to the first evaluations level a b b 2 level a x 1 delete a b x For more examples of incomplete evaluations and information about enforcing such evaluations see Enforcing Evaluation Level of Evaluation To detect and prevent infinite loops MuPAD implements another environment variable MAXLEVEL The default value of MAXLEVEL for all computations is MAXLEVEL 100 When evaluation level reaches the value of MAXLEVEL MuPAD assumes that the evaluation is infinite and issues an error MAXLEVEL 2 a b b 3 c c di a Error Recursive definition the maximal evaluation level is reached delete MAXLEVEL a b c d If the value of MAXLEVEL 1s greater than the value of LEVEL the global variable MAXLEVEL does not affect that evaluation Otherwise the value of MAXLEVEL limits the number of evaluation steps For example the default values of LEVEL and MAXLEVEL are equal both values are 100 If an evaluation reaches the level 100 MuPAD uses the global variable MAXLEVEL and therefore issues an error Error Recursive definition the maximal evaluation level is reached delete x Control Evaluation Levels You can change the values of the environment variables LEVEL and MAXLEVEL For example the following equations define the identifiers x recursively X k x 10 k 1 x k 1 k 1 9 10 Using the level function evaluate the identifier x to the levels from 1 to 10 For t
304. e fp package may be exported After calling use fp fixedpt the function f ixedpt is also directly available 1 e fixedpt f may also be called If a variable with the name fixedpt already exists then use raises an error Functional Programming The value of the identifier fixedpt must then be deleted in order to be exported With use fp all methods of the fp package are exported 8 More Information About Some of the MuPAD Libraries Grobner bases 8 10 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The groebner package contains some functions dealing with ideals of multivariate polynomial rings over a field In particular Gr bner bases of such ideals can be computed An ideal is given by a list of generators They must all be polynomials of the same type 1 e for all of them the coefficient ring third operand and list of unknowns second operand must be the same The generators may also be expressions all of them must be if any of them is Grobner bases and related notions depend on the monomial ordering also called term ordering under consideration MuPAD knows the following orderings the lexicographical ordering denoted by the identifier LexOrder the ordering by total degree with the lexicographical ordering used as a tie break it is denoted by the identifier DegreeOrder the ordering by total degree with the opposite of the lexicographical ordering for the
305. e plot library knows how many specifications of type range it has to expect For example a univariate function graph in 2D such as plot Function2d sin x x 0 2 PI expects one plot range for the x coordinate whereas a bivariate function graph in 3D expects two plot ranges for the x and y coordinate plot Function3d sin x 2 y 2 x 0 2 y 0 2 A contour plot in 2D expects 2 ranges for the x and y coordinate plot Implicit2d x 2 y 2 1 x 2 2 y 2 2 A contour plot in 3D expects 3 ranges for the x y and z coordinate plot Implicit3d x 2 y 2 2 2 1 x 2 2 y 2 2 Z 2 2 A line in 2D does not expect any range specification 6 129 6 Graphics and Animations plot Line2d O 0 1 1 Note Whenever a graphical primitive receives a surplus range specification by an equation such asa amin amax the parameter a is interpreted as an animation parameter assuming values from amin to amax Thus it 1s very easy indeed to create animated objects Just pass a surplus range equation a amin amax to the generating call of the primitive All other entries and attributes of the primitive that are symbolic expressions of the animation parameter will be animated In the following call both the function expression as well as the x range of the function graph depend on the animation parameter Also the ranges defining the width and the height of the rectangle as well as t
306. e shortened further Simplify returns a simpler form f cos x 2 sin x 2 sin x cos x simplify f Simplify f 2 cos x 1 ERA 2 coti 2 x cos x smi x Use Options to Control Simplification Algorithms By default in order to find the simplest form of an expression the Simplify function takes one simplification step This function can simplify some expressions further by taking more simplifications steps F exp cos x 2 sin x 2 sin 2 x exp 2 x 2 exp x 1 exp 2 x 1 Use General Simplification Functions Simplify F sin 4 x sin 4 x e ee oe 2 Tt You can change the number of internal simplification steps through the option Steps This option is not available for simplify Simplify F Steps 250 sin 4 x 2 1 2 e 1 By default the general simplifiers return only one form of an expression the form that MuPAD considers to be simplest To return all forms found by Simplify use the option All X 1 x 2 x 1 x 2 1 Simplify x 1 X 1 x 4 x 2 1 All x 2 O 12 r 2 P sor x 1 lx 1 x 1 x41 o o i _ x 1 x 1 Sa Ix 1 x 1 0 0 P F Ta F x ix li iix l c c o c fh gU v8 where While transforming an expression MuPAD simplifiers keep all forms of an expression mathematically equivalent to the initial expression For example the simplifiers do 3 91 3 Mat
307. e system of differential equations or i x x m x xj m x 4 4 6 153 6 Graphics and Animations 6 154 which is nothing but the equations of motions for two planets with masses m m at positions x1 y1 xs Y2 revolving in the x y plane around a sun of mass m positioned at Xs Vs We specify the mass ratios The first planet is a giant with a mass m4 that is 4 of the sun s mass The second planet is much smaller ms 1 m1 0 04 m2 0 0001 As we will see the motion of the giant is nearly undisturbed by the small planet The small one however is heavily disturbed by the giant and finally kicked out of the system after a near collision We solve the ODEs via the MuPAD numerical ODE solve numeric odesolve2 that provides a solution vector Y t x x y y CE x 0 x Y y x4 x Y x The initial conditions are chosen such that the total momentum vanishes 1 e the total center of mass stays put at the origin Y numeric odesolve2 numeric ode2vectorfield xs t m1 xs t x1 t sqrt xs t x1 t 2 ys t y1 t 2 8 m2 xs t x2 t sqrt xs t x2 t 2 ys t y2 t 2 8 ys t m1 ys t y1 t sqrt xs t x1 t 2 ys t y1 t 2 8 m2 ys t y2 t sqrt xs t x2 t 2 ys t y2 t 2 8 x1 t Animations ms x1 t xs t sqrt x1 t xs t 2 yt t ys t 2 8 m2 x1 t x2 t sqrt x1 t x2 t
308. e the approach that works best for solving your problem 9 148 Visualize Expression Trees Visualize Expression Trees Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB You can create mathematical expressions using MuPAD objects and operators For example the following equation presents a MuPAD expression X ty 1 1 5 sin 5 z Precedence levels determine the order in which MuPAD evaluates an expression Operators in MuPAD expressions have precedences similar to the precedences of regular mathematical operators For example when you compute the expression a b c you calculate b c and then add a To change the evaluation order use parentheses i 2 9 1 2 3 P D A useful model for visualizing a MuPAD expression is the expression tree It reflects the internal representation of an expression The operators or their corresponding functions are the vertices and the arguments are sub trees The lowest precedence operator 1s always at the root of an expression tree For example you can represent the expressiona b c d e sin f gusing this expression tree 9 149 5 Programming Fundamentals 9 150 The following expression tree represents the expression int exp x 4 x 0 1 MuPAD internally represents the differencea basa b 1 Therefore MuPAD represents the difference using this expression tree Similarly a quotient a b has the internal re
309. e the appropriate simplification function See Choosing simplification Functions Besides specific simplifiers MuPAD offers two general ones Simplify searches for a simpler form by rewriting the terms of an expression This function uses an internal set of rules for rewriting an expression You cannot modify this set of rules Simplify performs more extensive search for a simple form of an expression For some expressions this function can be slower but more flexible and more powerful 3 89 3 Mathematics 3 90 than Simplify Simplify uses a wider set of rules to search for a simpler form of an expression Simplify lets you extend the set of simplification rules and also accepts a number of options allowing you more control over the simplification algorithm If you do not need a particular form of expressions expanded factored or expressed in particular terms use simplify and Simplify to shorten mathematical expressions For example use these functions to find a shorter form for a final result The general simplifiers also can help you in verifying the result Choose simplify or Simplify Use the simplify command to simplify elementary expressions such as simplify x 1 X 3 X T7 simplify cos x TO ORBTIIX RS 19 17 a For elementary expressions simplify is an effective and fast simplifier For more complicated expressions simplify might be less effective The returned form of the following expression can b
310. e the integral around x 0 series F x 0 3 P TA x X ei m x 3 3 a If you know in advance that the integral cannot be found in a closed form skip calculating the symbolic form of the integral To use the system more efficiently call the series command to expand the integrand and then integrate the result int series cos x sqrt 1 x 2 x 0 x 3 3 e jm x cX 42 als cae i m Lh Approximate Definite Integrals If int cannot compute a definite integral 1n a closed form 1t returns an unresolved integral F int cos x sart 1 x 2 x 0 10 To approximate the result numerically use the float function float F 0 375 706283 3 149 3 Mathematics If you know in advance that the integral cannot be found in a closed form skip calculating the symbolic form of the integral Use the system more efficiently by calling the numeric int function This command applies numeric integration methods from the beginning numeric int cos x sqrt 1 x 2 x 0 10 0 375706283 3 150 Compute Symbolic Sums Compute Symbolic Sums Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Indefinite Sums on page 3 151 Definite Sums on page 8 152 Sums Over Roots of a Polynomial on page 3 153 Suppose you have an expression with a set of discrete values of a variable Computing a sum of this expression over the set of variables
311. e the plots in batch mode With the attribute OutputFile filename the graphical output is not rendered to the screen An external file with the specified name containing the graphical data is created instead It may contain xml data that may be viewed later by opening the file with the MuPAD graphics tool VCam Alternatively bitmap files in various standard bitmap formats such as bmp jpg etc can be created that may be viewed by other standard tools See section Batch Mode for further details Various Attributes attribute name possible values browser entry example CoordinateTyp LinLin linear LinLin Coord Sys 2d linear linear LogLin LogLog logarithmic logarithmic linear log log CoordinateTyp LinLinLin linear linear LinLinLin Coord Sys 3d LogLogLog linear log log log Easy Plotting Graphs of Functions attribute name pee values browser entry example Scaling Automatic scaling mode Unconstrained Coord Sys 2d 8d Constrained Unconstrained positive real aspect ratio 1 Scene2d 3d value y X only for Scaling Unconstrained positive real aspect ratio 2 3 Scene3d value zZ X only for Scaling Unconstrained Discontinuitys TRUE FALSE enable disable TRUE Function2d semi symbolic search for discontinuities OutputFile string save the plot data in a file 6 77 6 Graphics and Animations Advanced Plotting Principles and First Examples 6 78 Note Use only in the Mu
312. e the solutions are complex numbers To limit the number of the solutions to some specific ones the solvers provide a number of options For information about the options accepted by a particular solver see the page for that solver For example for the list of options provided by the general solver see the solve help page The following equation has five solutions solve x 5 1 x where af 8 8 NU y Ww oc 1 4 4 ROS V2 545i If you need a solution in real numbers use the Real option The only real solution of this equation 1s 1 3 62 If Results Look Too Complicated solve x 5 1 x Real pate e r For the following standard quadratic equation the solver returns the solutions for all possible values of symbolic parameters a b and C solve a x 2 b x Cc x ff bea b o n 1 L if a 0 2a ig lt if a 0A50 C if a20 520 c20 e if a204520 cs0 where g b 4ac To disregard special cases use the IgnoreSpecialCases option solve a x 2 b x c x IgnoreSpecialCases b y b 4ac b b 4ac 2a l 2a For the following equation the solver returns a complete but rather long and complicated solution solve x 5 2 1 x 5 2 1 x 3 63 3 Mathematics 3 64 C il mc bajm kewl iaa pL tz CI Ea m a Lam be iaa _ be LA oft us 5i g M l y s 3 4 4 4 s it usus j vw Lo i Y 4
313. e type of the object such as Function2d Curve2d etc is used for the legend text Here are all attributes relevant for legends Attributes for Legend Legend J sets LegendText to the given string LegendEntry to TRUE and LegendVisibl to TRUE LegendEntry TRUE add this object TRUE for function primitive FALSE to the legend graphs curves and surfaces FALSE otherwise LegendVisible TRUE legend on off TRUE for Scene2d 3d FALSE plotfunc2d 3d FALSE otherwise LegendPlacement Top vertical Bottom Scene2d 3d Bottom placement LegendAlignment Left horizontal Center Scene2d 3d alignment LegendFont see section font for the sans serif 8 Scene2d 3d Fonts legend text 6 167 6 Graphics and Animations Fonts Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The plot attributes allow to specify the fonts AxesTitleFont FooterFont HeaderFont LegendFont TextFont TicksLabelFont and TitleFont Each such font is specified by a MuPAD list of the following form lt family gt size Bold Italic color alignment The parameters are family the font family name a string The available font families depend on the fonts that are installed on your machine For example typical font families available on Microsoft Windows systems are Times New Roman of type serif Arial of type sans serif or Courier New of type monospace To find out
314. e variables and expressions after a particular function call Watch the changing intermediate values of the variables View the name of the currently running procedure Debug MuPAD Code Using the Debugger Open the Debugger To open the Debugger window from a notebook 1 Select Notebook gt Debug from the main menu File Edit View Navigation Insert Format nm Ld mR L gh A f my Evaluate gt icone Monospace Evaluate From Beginning DIA Evaluate To End a S Evaluate All ax I gt a Jfdx fof Maf Read Commands stop j 1 i a 5 2 Debug xc a 6 Typeset Math Abbreviate Output Pretty Print Text Width Start Engine Disconnect EA AT Ta General Math Plot Commands Debug the execution of a procedure call Not Connected 2 Inthe Debug Procedure Call dialog box enter the procedure call you want to debug 9 65 5 Programming Fundamentals 9 66 fl Debug Procedure Call E i T Enter procedure call to debug 8 and dick OK Call factor x 2 1 3 Click OK to open the Debugger for this procedure call You also can open the Debugger directly from the command line using the debug command for example debug factor x 2 1 If you debug several lines of code place the debug command in a separate input region This allows you to avoid reevaluating the code every time you open the Debugger proc x begin x x 1 end proc proc n begin g 10 n end proc B 4
315. e vector y defines the right sides of equations Gu ca bet LA 2 un La un aa C y matrix 1 2 3 2 3 325 To solve a system given by a Toeplitz matrix use the linalg toeplitzSolve special solver This special solver is more efficient than Linalg matlinsolve This solver accepts a vector or a list of diagonal elements t of a Toeplitz matrix instead of a Toeplitz matrix itself t i O d 5 3 0 x linalg toeplitzSolve t y Solve Algebraic Systems de ei i LF ro bal ti Os CI La For the list of special solvers available in MuPAD see Choosing Solver For information on linear algebra functions see Linear Algebra Nonlinear Systems To solve a system of nonlinear equations symbolically use the general solver For example solve the following system of trigonometric equations solve 4 cos x 2 cos y 3 2 sin x sin y 1 x yl ce 16 L7 q 2 arctan o rae 727 keZ leZ 2 arctan o amp 42mn1i L 13 where l 48 3 J 23 2 13 When you use the VectorFormat option the solver returns the solutions as a set of vectors If you want the solver to return one solution from the set use the PrincipalValue option When you use PrincipalValue the solver still returns a set although that set contains only one solution 3 41 3 Mathematics 3 42 solve 4 cos x 2 cos y 3 2 sin x sin y 1 X y VectorFormat PrincipalValue 3 23 16
316. e y and the independent variable x is linear y a bxi Here a is the offset and b is the slope of the linear relationship For linear regression of a data sample with one independent variable MuPAD provides the stats linReg function This function uses the least squares approach for computing the linear regression Stats linReg chooses the parameters a and b by minimizing the quadratic error 2 i 3 PEN z a x gt jy a Bx I The function also can perform weighted least squares linear regression that minimizes yY w i y a bxl I with the positive weight w By default the weights are equal to 1 Besides the slope a and the offset b of a fitted linear model stats linReg also returns the value of the quadratic deviation y For example fit the linear model to the following data X i 1 2 3 4 5 6 7 8 9 10 y ser B 1S 5o 10 Sly ay 2 27 BS stats linReg x y The linear model y 9 2 x fits this data perfectly The quadratic error for this model 1s zero To visualize the data and the resulting model plot the data by using the plot Scatterplot function The plot shows the regression line y 9 2 x computed by stats linReg 3 299 3 Mathematics 3 300 plot plot Scatterplot x y 28 When you work with experimental data samples the data almost never completely fits any linear model The value of the quadratic error indicates how far the actual data deviate from the fitted
317. ebook lVar 10 10 To declare a local variable use the local command inside a procedure lProc proc x Procedures local lVar begin lVar 10 lVar lVar 2 x 2 1 end proc When you call this procedure the value of the variable 1Var changes only inside a procedure Outside the procedure the variable does not change its value lProc 5 lVar 10 If you declare a local variable it does not inherit the value of a global variable with the same name Local variables are not identifiers of type DOM_IDENT They belong to a special domain type DOM_VAR Therefore you cannot use a local variable as a symbolic variable Before performing computations with a local variable you must assign a value to that variable For example without the assignment 1Var 10 the procedure call 1Proc returns an error message lProc proc x local lVar begin War lVar 2 x 2 1 end proc iProc 5 Warning Uninitialized variable lVar is used Evaluating lProc Error The operand is invalid power Evaluating lProc Local variables cannot have assumptions Restore Values and Properties of Global Variables Modified in Procedures When you use global variables 1nside a procedure you can save their original values and properties and recover them after the procedure Suppose you want to use more decimal 4 23 4 Programming Basics 4 24 digits for calculations with floating point numbers inside a procedu
318. ect View Wrap To Window Wrap Expressions in Input Regions To wrap the contents of the input regions to a notebook window size 1 Select Format gt Defaults 2 104 Wrap Long Lines 2 Inthe resulting dialog box click the Calculations tab 3 From the drop down menu Format select Input Paragraph 4 Select the Word wrap check box Select this option i M pates aaa re ue SIIT inrma E Format Input Paragraph e Defines the paragraph format for the input of a new calculation Left 0 00 First 0 00 Right 0 00 Word wrap Keep Lines together Now MuPAD wraps all new expressions and commands in the input regions to a notebook window size If you use wrapping for input regions and then resize your notebook MuPAD automatically adjusts expressions and commands to a new window size 2 105 2 Notebook Interface Uy Notebookl MuPAD File Edit View Navigation Insert Format Notebook Window Help d s al A f v x T Q Tl 4l X 9 n Generic Monospace The vertical dashed gray line shows the right margin of the printed page When you print this notebook MuPAD offers you to scale it down to fit the printer setting for a page size If you use the actual page size only the part of the notebook to the left of the vertical line appears on printed pages solve 300000 x 4 123456 x 3 x 2 l000 x 123456789 0 x MaxDegree 4 3 go g 59533531 0 Jg ai TM t
319. ed cell If you inserted a column it appears to the left from the selected cell 2 40 Use Tables File Edit View Wavigation Insert Format Notebook Window Help m Ld s lal A f aj al E Q TU 4 m Generic Sans Serif The solution of the quadratic equation a x b x c 0 is piecewise Here a b and c are symbolic parameters and x is a symbolic variable Piecewise objects often occur if an equation contains symbolic parameters in addition to the variable solve a x 2 b x ce x biyi 4as b Vy E l eae _b ye sacl x pao 2a 2a D a ifa204b520 C if a 0Ab 0aAc 0 e if a 0 4b5 20 cze0 BH IM se General Math Plot Commands Mem 8 MB TOs Format Tables You can change the appearance of a table in a MuPAD notebook To format a table 1 Click the table you want to format 2 Select Format gt Table from the main menu 2 41 2 Notebook Interface File Edit View Navigation Ld Eal lal geh A f ms Characters The solution of the quadratic equ are symbolic parameters and x i Paragraph E Calculation i I gt a Y Piecewise objects often occur if a Table iboli ters i i Jf x rf Iaf Iu r o f y f E the variable soh Frame Page solve a x 2 b x c f be b 4ac _ b yb 4ad lA Increase Size Teee lt Decrease Size Defaults if a O0Ab 0aAc 0 if a O0Ab 0acez0 Change table format Mem amp
320. ed easily as HSV colors For example the color violet 1s given by the HSV values 290 0 4 0 6 whereas dark green 1s given by the HSV specification 120 1 0 4 Hence a semitransparent violet sphere intersected by an opaque dark green plane may be specified as follows plot plot Sphere 1 0 O 0 Color RGB fromHSV 290 0 4 0 6 0 5 plot Surface x y 0 5 x 1 1 y 1 1 Mesh 2 2 Color RGB fromHSV 120 1 0 4 6 175 6 Graphics and Animations Save and Export Pictures Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Save and Export Interactively on page 6 176 Save in Batch Mode on page 6 176 Save and Export Interactively The MuPAD kernel uses an xml format to communicate with the renderer Usually a plot command in MuPAD sends a stream of xml data directly to the viewer which renders the picture After double clicking on the picture the viewer see section Viewer Browser and Inspector Interactive Manipulation provides a menu item Edit Export that opens a dialog allowing to save the picture in a variety of graphical formats The VCam Graphics format indicated by the file extension xvz This is a compressed version of the xml ascii data used by MuPAD The Uncompressed VCam Graphics format indicated by the file extension xve saves these xml data in an uncompressed ascii file the re
321. ee Scalable Format for Copying Graphics on page 2 74 Highlight matched and mismatched delimiters parentheses brackets and braces in input regions When you type a parenthesis a bracket or a brace MuPAD highlights the matched delimiter in the pair If a delimiter is missing or if a pair includes delimiters of different types for example a bracket and a brace MuPAD uses a different color to highlight the delimiters In addition to highlighting mismatched delimiters MuPAD underlines them To make the display of highlighting and underlining disappear move the cursor away from a delimiter Change Default Formatting To specify default formatting for the elements of all new MuPAD notebooks Aa O N Select View gt Configure In the left pane of the Configure MuPAD dialog box click Notebook In the right pane of the dialog box click Default Formats In the Default Formats dialog box use tabs to select the required element You can specify default formatting for text regions input and output regions calculations tables frames and links by clicking the corresponding tab Specify default formatting for the element you selected For example set the default font size style and color for the text regions 2 73 2 Notebook Interface 2 74 J All new Notebooks Default Formats Format Characters vi Defines the normal character format for a new Notebook Font Generic Sans Serif T 11 Effects
322. eee eS x4 4 19 Return Multiple Results eee 4 20 Return Symbole Calls sais he Ae ww unie dos 4 20 Use Global and Local Variables 4 21 Restore Values and Properties of Global Variables Modified in PlOCCOUMES 52 td aded Aot HU oe eas Bie RURAL arabo un 4 23 Funcions ERR TTETESESTEESERETSIUOTLOTOTIC LL ee hae 4 26 Call Existing Functions 2e ER RE EWa e E 4 26 Create FUNCTIONS 2 o gogo d 5 dedo cR caro QE D dira 4 26 Evaluate Expressions While Creating Functions 4 27 Use Functions with Parameters 0 4 28 Shortcut for Closing Statements 4 29 Programming Fundamentals 2 Data Type Definition esee 5 3 Domain Types dcs x nce duc EU ees eee RUE A Es Bes es 5 3 Expression Types wake beoe ek b EE ES AO LE e AES 5 3 Sequelee S auo sor dA AP S a De dort xor Bb a ee dot 5 6 Create Sequences celeres 5 6 Access Sequence Entries 00000 cee eee eee 5 1 Add Replace or Remove Sequence Entries 5 8 II ENE PEEN EE EAEE EE EATER EE TAES PEN 5 10 Create Lile iat ik et beatae ee us Be ek Oe r Eae 5 10 Access List Entries 0 ccc eee 5 11 Operate OS S Jerri derr dra ides eas hat ae e E ed 5 12 Add Replace or Remove List Entries 5 16 DOES 62 5 Lore ao ue do g E doceat aos due li am pus uteris a date Ee tem 5 18 Create SIUE baie On Sa eas Gla ee eS eee ee as 5 18 Access Set Elements
323. eel and a blue point outside the wheel WheelRadius 1 WheelCenter x WheelRadius WheelRim plot Circle2d WheelRadius WheelCenter x 0 4 PI LineColor RGB Black WheelHub plot Point2d WheelCenter x O 4 PI PointColor RGB Black WheelSpoke plot Line2d WheelCenter WheelCenter 1 1 5 WheelRadius sin x WheelCenter 2 1 5 WheelRadius cos x X 0 4 PI LineColor RGB Black color RGB Red RGB Green RGB Blue r 1 5 WheelRadius 1 0 WheelRadius 0 5 WheelRadius for i from 1 to 3 do 6 85 6 Graphics and Animations Point i plot Point2d WheelCenter 1 r i sin x WheelCenter 2 r i cos x X 0 4 PI PointColor color i PointSize 2 0 unit mm Cycloid i plot Curve2d y r i sin y WheelRadius r i cos y y O X X O A4 PI LineColor color i end for plot WheelRim WheelHub WheelSpoke Point i i 1 3 Cycloid i i 1 3 Scaling Constrained Width 120 unit mm Height 60 unit mm Example 3 We wish to visualize the solution of the ordinary differential equation ODE y x yxy cos x with the initial condition y 0 0 The solution shall be drawn together with the vector field Tix y 1 y cos x associated with this ODE along the solution curve the vectors of this field are tangents of the curve We use numeric odesolve to generate the solution as a function plot Since the numerical integrat
324. efinition Animation Annotation Calculation and Style with the latter split into the sub categories Style of Lines Style of Points Style of Asymptotes Opening one of these categories one finds the attributes and their current values that apply to the currently selected object After selection of an attribute with the mouse its value can be changed Viewer Browser and Inspector Interactive Manipulation fj Notebook1 MuPAD E Jol xl File Edit View Tools Window Help emaer raant 1c F Object Browser x E 1 E Canvas El f Scenezd F CoordinateSystem2d p Color RGB Black p PointSize 3 0 unit mm t Color RGB Red t LineWidth 1 0 unit mm plot g p t GridVisible TRUE y ff Select Color MEZ ae Green E os aps e codem Dos 0 EN Opacity as J 1 00 atic 1 i Liness v Zu NN Ey Cancel unestie Sota LineWidth 0 35 jo p LineCol F j a Lineal te LineCal 4 k color af lines Mem7MB TOs op gl INS 4 There is a sophisticated way of setting defaults for the attributes via the object browser and the property inspector The View menu provides an item Hide Defaults Disabling Hide Defaults the object browser changes from 6 99 6 Graphics and Animations fi Notebook1 MuPAD File Edit view Insert Tools Actions Wi
325. elCol faster than calling linalg delCol 8 21 8 More Information About Some of the MuPAD Libraries 8 22 Rnegate R negate faster than using the operator n Mat matdim A 1 faster than calling linalg nrows a array 1 n 1 n for i from 1 to n do Ai delCol A 1 for j from 1 to n do a i j det delRow Ai j if i j mod 2 1 then a i j Rnegate a i jl end if end for end for create a new matrix use Mat create instead of Mat new because the entries of the array are already elements of R return Mat create a end proc We give an example MatZ6 Dom Matrix Dom IntegerMod 6 adjoint MatZ6 1 5 2 4 p d 4mod 1 mod6 E Linear Optimization Linear Optimization Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The linopt library provides algorithms for linear and integer programming The routines in this library can be used in order to minimize and maximize a linear function subject to the set of linear constraints It is possible to get only integer solutions The routines for linear optimization are based on the two phase simplex algorithm The algorithm of Land Doig is used to find integer solutions The library functions are called using the library name linopt and the name of the function E g use c i 3 x 4 y 3 z lt 23 5 x 4 y 3 z lt 10 7 x 4 y 11 Z lt
326. eld generates the required procedure ODE numeric ode2vectorfield IVP fields proc t Y end 0 o 3 Now call numeric odesolve2 to approximate the solution numApprox numeric odesolve2 ODE proc numApprox t end Using the function generated by numeric odesolve2 find the numeric approximation at any point For example find the numeric solutions for the values 1 t 3 and i LT You get the same results as with numeric odesolve but the syntax is al shorter numApprox 1 numApprox 3 numApprox 1 127 0 3983192206 05495737569 11 79725153 30 00571043 0 002624699038 0 3333436668 3 85 3 Mathematics 3 86 Plot the numeric solution using the function generated by numeric odesolve2 The function numApprox returns a list y t y t When plotting the solution y t use brackets to extract the first entry of the solution list plotfunc2d numApprox t 1 t 0 3 0 Sq a A 00 02 04 06 086 10 12 14 16 18 20 22 24 26 28 3 0 Use numeric odesolve to find numeric approximations for the following system of ODEs IVP x t y t x t 2 y It IEEE Fite x 0 1 y 0 1 fields x t y t ODE numeric ode2vectorfield IVP fields numApprox numeric odesolve2 ODE proc numApprox t end Plot the numeric solutions for x t and y t in one graph plotfunc2d numApprox t 1 numApprox t 2 t 0 20 Solve Equations Numericall
327. ent location For example move the Command Bar to the left 2 9 2 Notebook Interface Fille Edit View Navigation Insert Format Notebook Window Help fa fof Tas pao f f lea EE a a ath Mem 1 MB TO s 2 10 Enter Data and View Results Enter Data and View Results Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD notebook has two types of regions for entering data Text regions serve for entering your comments They can contain text tables mathematical formulas and graphics Text regions do not have not bracket markers The default font color for text regions is black To start a new text region click outside the gray brackets and start typing Alternatively you can insert a new text region by selecting Insert gt Text Paragraph or Insert gt Text Paragraph Above You cannot insert a text region inside a region of other type or between adjacent input and output regions Input regions serve for entering your code They can contain MuPAD mathematical expressions and commands in the MuPAD language Input regions have gray bracket markers The default font color for input regions is red When you evaluate an expression in the bottom input region MuPAD inserts a new input region below To insert new input regions in other parts of a notebook select Insert gt Calculation or Insert gt Calculation Above from the main menu Alternatively use the Insert Calculation button
328. eorganizes the expression grouping such terms When calling collect specify the variables or expressions that the function must consider as unknowns The collect function regards the original expression as a polynomial in the specified unknowns and groups the coefficients with equal powers 2 XxX 3 X 2 y z 3 x 3 y 4 Zz 2 collect x y 4 Z Z DN R X y x yore s 2 C o3 2X 08 0 04 3 ee su 2 Iay 42 x yz x ly 45zy cez xeyz collect can consider an expression as the specified unknown For example group the terms of the following trigonometric expression with the equal powers of sin x and cos x f cos x 4 sin x cos x 2 sin x 3 cos x 2 sin x 2 sin x 4 collect f sin x Smix cos x smix cosix smix cos ix smix collect f cos x pe 4 fia gt X s a M E ET sin x cos x lsm x sin x cos x sin x Choose Simplification Functions The collect function also can accept several unknowns for collecting terms If you have several unknowns pass them to collect as a list collect a 2 sin x cos x 2 sin x 3 cos x 2 a a 2 sin x 4 a cos x fone x df z f ae af ae sin x sin x a a li sm xy cos x Combine Terms of Same Algebraic Structures MuPAD also provides a function for combining subexpressions of an original expression The combine function uses mathematical identities for the functions you indicate For example combine the tri
329. er of an integer can be extremely slow To avoid this step use the powermod 3 323 3 Mathematics 3 324 function This function computes the modular power more efficiently especially for large numbers powermod 987 124 12 powermod 987 123456789 12 9 3 Common Modular Arithmetic Operations MuPAD implements a large number of algorithms that enable you to perform various modular arithmetic operations For example you can quickly compute primitive roots orders of residue classes and the Euler s totient function If g 1s a primitive root modulo n then for any integer a there exists an integer k such that g a mod n This congruence has solutions primitive roots exist only if igcd a n 1 To compute the least primitive root modulo n use the numlib primroot function For example compute the primitive roots modulo 19 23 191 and 311 numlib primroot 19 numlib primroot 23 numlib primroot 191 numlib primroot 311 2 5 19 17 The numlib order function computes the order of a residue class For an integer a and a positive integer n this function returns the least number k such that a 1 mod n For example compute the order of the residue class of 3 in the unit group modulo 7 numlib order 3 7 The Euler s totient function of an integer n counts all positive integers that satisfy the following two conditions The integer is coprime to n Modular Arithmetic The integer is sm
330. eraDirection 2 3 4 Transformations 6 163 6 Graphics and Animations Legends Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The annotations of a MuPAD plot may include a legend A legend is a small table that relates the color of an object with some text explaining the object T i Q XUSIBIZT X g 4 x 2 cos x h sin 4 x x plotrunc2d T g h x O PI 2 01 0 2 0 3 0 4 05 06 By default legends are provided only by plotfunc2d and plotfunc3d These routines define the legend texts as the expressions with which the functions are passed to plotfunc2d or plotfunc3d respectively A corresponding plot command using primitives of the plot library does not generate the legend automatically plot plot Function2d f x O PI 2 Color RGB Red 6 164 Legends plot Function2d g x plot Function2d h x 0 PI 2 Color U Fij2 Color RGB Green RGB Blue 01 02 03 04 05 06 OF 0 2 0 9 10 1 1 12 1 3 14 However legends can be requested explicitly plot plot Function2d f x O PI 2 Color RGB Red Legend Function 1 expr2text f plot Function2d g x O PI 2 Color RGB Green Legend Function 2 expr2text g plot Function2d h x O PI 2 Color RGB Blue Legend Function 3 expr2text h 6 165 6 Graphics and Animations 6 166 01 02 03 04 05 05 07 08899 10 11 12 13 14 Wm Function 1 3 x si
331. erface This functionality does not run in MATLAB MuPAD supports creating and operating on vectors and multidimensional matrices Vectors and matrices in MuPAD can contain arbitrary MuPAD objects numbers variables arithmetical expressions and so on The simplest way to create a matrix 1s to use the matrix command matrix 1 2 3 4 5 6 Lay pw Cr Lad C a 12 PE When creating a matrix you can explicitly specify its dimensions If you specify matrix dimensions you can use a flat list to specify all elements of a matrix The matrix command takes the entries from the flat list and generates a matrix row by row For example create the following 2x3 matrix matrix 2 3 1 2 3 4 5 6 Using the same list of elements create the following 3 X2 matrix Lay bw CN La a matrix 3 2 1 2 3 4 5 6 P TE Lay Lag ee M 4 If you specify matrix dimensions and then enter rows or columns shorter than the declared dimensions MuPAD pads the matrix with zero elements matrix 3 3 1 2 3 4 5 6 Create Matrices Co npa 123 matrix 3 3 1 2 3 4 ees 400 000 E To create a matrix of zeros specify matrix dimensions and omit specifying elements matrix 3 2 0 0 o0 iF If you use a flat list MuPAD cannot determine where to put zeros and therefore issues an error matrix 3 3 1 2 3 4 Error The number of list entries does not match m
332. erride previous entries The order of output does not reflect the order of input 9 29 5 Programming Fundamentals 5 26 T1 table 5 a 12 c T2 table a 5 c 12 T3 table 5 b T1 T2 a 6 c 13 Sja 1 c ao c 13 Access Table Elements To access an entry of a table use brackets or index T table a 11 c 12 T al index T c 11 12 To access a value entry of a table by its index also use brackets or index T table a 11 c 12 If an index does not exist you get T b table a 11 c 12 b Tables Before accessing a value entry of a table by its index check that the index is available for the table contains T b contains T a T a FALSE TRUE 11 Operate on Tables MuPAD tables support the following operations Extracting contents of a table as a collection of equations lasting indices and values separately Verifying that a table contains a particular object Searching for an object among the indices and the values a table To extract the contents of a table as a collection of equations use the Op command op T a 11 c 12 You can list indices and values of a table separately leftSide lhs T rightSide rhs T 5 27 5 Programming Fundamentals To check if an object belongs to the indices of a table use the contains command T table a contains T a contains T 11 ii 12 TRUE FA
333. ers use the ilcm function For example compute the least common multiple of the following numbers 1lch 12 By 2 21 420 3 317 3 Mathematics Primes and Factorizations 3 318 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Operate on Primes on page 3 318 Factorizations on page 3 320 Prove Primality on page 3 320 Operate on Primes Prime numbers are positive integers larger than 1 that have only two positive integer divisors 1 and the number itself In MuPAD you can check whether the number is prime by using the isprime function For example 809 is a prime number while 888 and 1 are not primes isprime 809 isprime 888 isprime 1 IRUE FALSE FALSE In rare cases the isprime function can return a false positive result The function performs the Miller Rabin primality test and uses 10 independent random bases For a more accurate and also slower method see Proving Primality The sequence of prime numbers is infinite It starts with 2 3 5 7 11 13 17 and goes on The ithprime function lets you quickly find and display any entry of this sequence For example to find the 100th prime number enter ithprime 100 ithprime 100 541 To find the prime number that appears 1n the sequence before a particular value use the prevprime function To find the prime number that appears after a particular value use Primes and Factorizations the nextprime func
334. ers as the parameters of limit the round off error can completely change the result For example a small error in the following example with the floating point parameter changes the result from a rational number to the floating point infinity limit sin X x x 3 x 0 limit 1 000001 sin x x x 8 x 0 243 6 RD INF Compute Right and Left Limits Compute Right and Left Limits Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If a limit of a function at a particular value of a variable does not exist the Limit command returns undefined For example tan x does not have a bidirectional limit atx F a limit tan x x PI 2 undefmed The plot of this function shows that the function can have two different limits as the variable X approaches the value E from the left and from the right plot tan x x PI PI 2 3 167 3 Mathematics To compute one sided limits of a function use the options Left and Right limit tan x x PI 2 Left limit tan x x PI 2 Right ao If the function has a bidirectional limit at some point one sided limits are equal at this point They also are equal to the bidirectional limit at this point Left limit abs tan x x PI 2 Left Right limit abs tan x x PI 2 Right Bidirectional limit abs tan x x PI 2 Left c Bidirectional c plot abs tan x x O PI 3 168 Compute Right a
335. erty of expr Property of expr Integer value Z uk Z or expr in expr Type Integer oe ae expr Type Negative AE expr gt 0 expr Type NonNegative 20 er 0 expr Type Zero Nonzero value C 0 expr lt gt 0 Even value 2 Z expr 2 Z_ or expr in 2 Z Odd value 2 Z 1 expr 2 Z 1 Positive integer value 7 expr in Z and expr gt O gt 0 Negative integer value expr in Z and expr Z lt 0 lt Nonnegative integer value 20 Positive rational value IN 0 Negative rational value o lt Q Nonnegative rational value z0 expr Type expr Type expr Type expr Type expr Type expr Type expr Type expr Type expr Type NonZero Even Odd PosInt NegInt NonNegInt PosRat NegRat NonNegRat 8 29 8 More Information About Some of the MuPAD Libraries Property Recommended Way to Specify Alternative Way to Specify a a Property of expr Property of expr fexpr lt T a lt expr lt b expr in T and a lt expr expr b Type Interval a b Here a b are expressions T and T is a basic number domain JTexpr e T asexpr lt b expr in T and a lt expr expr b Type Interval a b Here a b are expressions T and T 1s a basic number domain fexpr lt T a lt expr lt h expr in T and a lt expr expr b Type Interval a b Here a b are expressions T and
336. es a factorial of its argument f proc x begin if testtype x Type PosInt then return x else return procname args end_if end_proc If its argument is a positive integer this procedure returns an exact number f 5 f 10 120 3628800 Otherwise it does not error but returns a symbolic call to itself f 1 3 f 1 1 f x f x 1 f FOL fix fle 1 Use Global and Local Variables Inside a procedure all variables fall into two categories global and local Global variables are accessible from everywhere inside a notebook Local variables are accessible only from within a procedure Global Variables Suppose you want to create a procedure gProc and use the global variable gVar inside the procedure gProc proc x 4 21 4 Programming Basics 4 22 begin gVar gVar 2 x 2 1 end proc When you call this procedure the value of the variable gVar changes gVar 10 gProc 5 gVar 126 Multiple calls change the value of the global variable further gProc 5 gVar 15907 Note Avoid using unnecessary global variables Global variables reduce code readability occupy the global namespace and often lead to errors When you use global variables inside a procedure always verify that each call to the procedure changes global variables as intended Local Variables You can access and modify local variables only inside a procedure Suppose you use a variable 1Var in your not
337. es the graphical tree The Full Picture Graphical Trees Canvas Scene 1 CoordinateSystem 1 Primitive 1 Primitive 2 that becomes visible in the object browser 6 97 6 Graphics and Animations Viewer Browser and Inspector Interactive Manipulation 6 98 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB After a plot command is executed in a MuPAD notebook the plot will typically appear below the input region embedded in the notebook To activate the graphic click it once with the mouse cursor The Tool Bar at the top of the window will change and the Command Bar at the right side of the window will be replaced by two sub windows labelled Object Browser and Properties which we will refer to as the object browser and the property inspector If they are not visible you may need to activate them with the 1con In the object browser the graphical tree of the plot as introduced 1n the preceding section is visible It allows to select any node of the graphical tree by a mouse click After selecting an object 1n the object browser the corresponding part of the plot 1s highlighted in some way allowing to identify the selected object visually The property inspector now displays all attributes the selected object reacts to For example for an object of type Function2d the attributes visible in the property inspector are categorized as D
338. est the solver to consider this parameter as a real number Use assumptions to limit the number of solutions to those necessary and to improve code performance When solving an equation inequality or a system you can use assumptions on parameters of the equation and assumptions on the variables you solve for Setting assumptions on parameters and variables affects performance of the solver in different ways Assumptions on parameters tend to narrow the area in which the solver tries to find the solutions thereby improving performance of the solver If you can identify mathematical properties of the parameters in your equation inequality or system use these properties to set as many assumptions on parameters as possible Assumptions on variables can narrow the returned results MuPAD applies assumptions on variables after the solver finds the solutions The solver verifies the results against the assumptions and returns only those solutions that agree with the assumptions Adding this extra task can slow down the solver Use assumptions on variables sparsely Alternatively you can simplify already returned complicated results by using assumptions See Using Assumptions There are two types of assumptions you can set Permanent assumptions hold true for all calculations MuPAD performs after you set the assumptions If you want MuPAD to stop using a permanent assumption you must explicitly delete the assumption Permanent assumptio
339. etails 6 19 6 Graphics and Animations The following picture shows Klein s bottle a famous topological object This surface does not have an orientation there is no inside and no outside of this object See the examples on the help page of plot Surface for details 6 20 Gallery The following picture demonstrates the reconstruction of an object with rotational symmetry from measurements of its radius at various points See section Some Examples for details 6 21 6 Graphics and Animations The following picture shows the Lorenz attractor See section Cameras in 8D for an animated version and details 6 22 Gallery The following picture shows a 3D level surface of a function the solution set of z sin z x y See the examples on the help page of plot Implicit3d for details 6 23 6 Graphics and Animations 1 0 4 0 6 24 Easy Plotting Graphs of Functions Easy Plotting Graphs of Functions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB 2D Function Graphs plotfunc2d on page 6 25 3D Function Graphs plotfunc3d on page 6 41 Attributes for plotfunc2d and plotfunc3d on page 6 56 The probably most important graphical task in a mathematical context 1s to visualize function graphs i e to plot functions There are two graphical routines plotfunc2d and plotfunc3d which allow to create 2D plots of func
340. etting Started For multiple functions plotted in one graph you can specify one range for all the functions plot sin k x k 1 5 x 0 2 PI 1 46 se Graphics VAN EET 0 4 LOU VAS 40 FX WZ WU A A To specify different ranges for multiple functions plotted 1n one graph use different variables plot sin k x k t 2 k 1 5 x 0 2 PI t 1 1 J l Getting Started 1 48 UL WO NEUSS gt Plot Piecewise Functions To specify a piecewise function use the piecewise command You can plot a piecewise function even if it is undefined at some points for example you can plot the following function although the function is not defined for 2 lt x lt 1 plot piecewise x lt 2 1 1 lt x and x O x 2 O0 lt x and x lt 1 x 2 x gt 1 1 Use Graphics 0 6 0 6 0 4 5 E 3 g 4 Format Plots Enable Plot Formatting Mode In MuPAD you can format your graphic results interactively when working in plot formatting mode To switch to graphics formatting mode click any place on a plot In this mode the Object Browser pane appears 1 49 l Getting Started 213 A OAT pes L P s M AF AL L WHT File Tools Actions Window Help s a eee AP BOOV Bt Ft S0G6A2QRWe Object Browser plet sqrt 1l x 2 y 2 x 1 1 3D Scene3d 4 d CoordinateSystem3d Function3d If you do not see the Object Browser and Proper
341. evertheless you can encounter some problems when using this mechanism Remember tables are efficient only if the access time of the remember table is significantly less than the time needed to evaluate the result If a remember table is very large evaluation can be computationally cheaper than accessing the result stored in the remember table Storing large remember tables requires a large amount of memory Especially remember tables created with the option remember can grow very large and significantly reduce available memory The number of entries in remember tables created by prog remember is limited When the number of entries in a remember 9 121 5 Programming Fundamentals 9 122 table created by prog remember reaches the maximum number the system removes a group of older entries Using prog remember or the option remember for nonrecurring procedure calls can significantly decrease code performance Avoid using the remember mechanism for nonrecurring procedure calls especially if the arguments are numerical If you change the properties of input arguments or modify the variables DIGITS or ORDER the remember mechanism ignores these changes by default See Remembering Results Without Context In some cases you must clear the remember table of a procedure to enforce reevaluation and avoid incorrect results For example clearing the remember table can be necessary when a procedure changes global variables or if globa
342. ew Results on page 2 11 View Status Information on page 2 13 Save Custom Arrangements on page 2 14 Format Text on page 2 15 Format Mathematical Expressions on page 2 21 Format Expressions in Input Regions on page 2 24 Change Default Format Settings on page 2 28 Use Frames on page 2 32 Use Tables on page 2 38 Embed Graphics on page 2 45 Work with Links on page 2 48 Export Notebooks to HTML PDF and Plain Text Formats on page 2 59 Save and Export Graphics on page 2 61 Set Preferences for Notebooks on page 2 71 Set Preferences for Dialogs Toolbars and Graphics on page 2 75 Set Font Preferences on page 2 79 Set Engine Preferences on page 2 82 Get Version Information on page 2 86 Use Different Output Modes on page 2 87 Set Line Length in Plain Text Outputs on page 2 94 Delete Outputs on page 2 95 Greek Letters in Text Regions in MuPAD on page 2 96 2 Notebook Interface 2 2 Special Characters in Outputs on page 2 97 Non Greek Characters in Text Regions on page 2 98 Use Keyboard Shortcuts on page 2 99 Use Mnemonics on page 2 101 Wrap Long Lines on page 2 102 Hide Code Lines on page 2 110 Change Font Size Quickly on page 2 113 Scale Graphics on page 2 116 Use Print Preview on page 2 118 Change Page Settings for Printing on page 2 122 Print Wide Notebooks on page 2 123 Notebook Overview Notebook Overview Note Use only in the MuPAD No
343. example the text2expr function does not evaluate the returned results text2expr 2 2 a 2 The last function and its shortcut which return the previously computed object also do not evaluate the results 6 a J at For such cases MuPAD provides the eval function This function enables you to enforce evaluation of an expression For example enforce evaluation of the previously returned expression eval 4 Another example of the function that does not automatically evaluate returned results is the subs function This function can simplify expressions that contain only purely arithmetical operations subs x 2 1 x 0 l However the subs function does not evaluate expressions For example substitute the variable x with the value 0 in the following expression that contains the sine function Enforce Evaluation subs sin x 2 1 x 0 sini 0 1 You can use the eval function to enforce evaluation of the results returned by subs In this case MuPAD evaluates the whole expression eval Alternatively the subs function provides a more efficient method to evaluate its results The EvalChanges option enforces evaluation of the modified parts of the expression leaving the unchanged parts out of the evaluation process subs sin x 2 1 x 0 EvalChanges Most efficiently evaluate an expression at a particular value of a variable by using the evalAt function See Evaluation at a
344. f F 1s f The expression F is an antiderivative of f Integration is a more complicated task than differentiation In contrast to differentiation there is no general algorithm for computing integrals of an arbitrary expression When you differentiate an expression the result is often represented in terms of the same or less complicated functions When you integrate an expression the result often involves much more complicated functions than those you use in the original expression For example if the original expression consists of elementary functions you can get the result in terms of elementary functions int x JTIIX 2 xX L an 4 ed The following integrand also consists of standard trigonometric functions but here the integrator cannot return the result in terms of elementary functions The antiderivative involves a special function int sin x x xX Si x When you compute an indefinite integral MuPAD implicitly assumes that the integration variable is real The result of integration is valid for all real numbers but can be invalid for complex numbers You also can define properties of the integration variables by using the assume function The properties you specify can interfere with the assumption that the integration variable 1s real If MuPAD cannot integrate an expression using your assumption the int function 1ssues a warning Use the intlib printWarnings function to switch the warnings on and off For exam
345. f the Fourier transform By default c 1 and s 1 Pref fourierParameters lets you specify other values for these parameters For the inverse Fourier transform IFT MuPAD uses the following definition f t Al 5 gisvt dw 2T7cC n To compute the Fourier transform of an arithmetical expression use the fourier function For example compute the Fourier transforms of the following exponential expression and the Dirac delta distribution fourier exp t 2 t w fourier dirac t t w ba _ Integral Transforms If you know the Fourier transform of an expression you can find the original expression or its mathematically equivalent form by computing the inverse Fourier transform To compute the inverse Fourier transform use the ifourier function For example find the original exponential expression and the Dirac delta distribution ifourier PI 1 2 exp w 2 4 w t ifourier 1 w t 5 f Lu E d a e amp f Suppose you compute the Fourier transform of an expression and then compute the inverse Fourier transform of the result In this case MuPAD can return an expression that is mathematically equivalent to the original one but presented in a different form For example compute the Fourier transforms of the following trigonometric expressions Cosine fourier cos t t w Sine fourier sin t 2 t w zx S w 1 8 w 1 Now compute the inverse Fourier transforms of the resul
346. f the standard library exist The corresponding functions of the numeric package are not exported Further if the identifier f solve say already has a value then use returns a warning and does not export numeric fsolve The value of the identifier f solve must be deleted before it can be exported successfully from the numeric package Orthogonal Polynomials Orthogonal Polynomials Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The orthpoly package provides some standard orthogonal polynomials The package functions are called using the package name orthpoly and the name of the function E g use orthpoly legendre 5 x to generate the fifth degree Legendre polynomial in the indeterminate x This mechanism avoids naming conflicts with other library functions If this is found to be inconvenient then the routines of the orthpoly package may be exported via use E g after calling use orthpoly legendre the function orthpoly legendre may be called directly legendre 5 x All routines of the orthpoly package are exported simultaneously by use orthpoly If the identifier Legendre already has a value then use returns a warning and does not export orthpoly legendre The value of the identifier Legendre must be deleted before it can be exported successfully from the orthpoly package 8 27 8 More Information About Some of the MuPAD Libraries Properties Note Use only in th
347. f the sum command cannot compute a sum MuPAD returns an unresolved sum For example try to compute the following sum sum exp x x x O infinity z 1 e J The reasons MuPAD cannot compute the closed form of a particular sum are the same as the reasons for not computing an integral The antidifference does not exist in a closed form The antidifference exists but MuPAD cannot find it MuPAD can find the antidifference on a larger computer but runs out of time or memory on the available machine If MuPAD cannot compute a definite sum try to approximate it numerically S sum exp x x x O infinity float S X 2 EOS x 1 386318602 If you know in advance that the antidifference cannot be computed in a closed form skip trying to calculate this sum symbolically For such expressions call the numeric sum function to perform numeric summation directly Trying to calculate a symbolic sum 3 154 Approximate Sums Numerically and then approximating it numerically can be much slower than applying numeric summation from the beginning numeric sum exp x x x O infinity 1 386318602 3 155 3 Mathematics Compute Taylor Series for Univariate Expressions 3 156 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Taylor series expansions serve for approximating an arbitrary expression by a polynomial expression around some value of a variable Ta
348. fDigits numdivisors numdivisors 21 sumOfDigits 21 To export all functions of a library pass the library name to the uSe command If some of the library functions have name conflicts with other objects the use command issues a warning for each name conflict use numeric Warning Identifier product already has a value It is not exported use Warning Identifier int already has a value It is not exported use Warning Identifier indets already has a value It is not exported use Warning Identifier det already has a value It is not exported use Warning Identifier linsolve already has a value It is not exported use Warning Identifier rationalize already has a value It is not exported use Warning Identifier inverse already has a value It is not exported use Warning Identifier solve already has a value It is not exported use Warning Identifier sum already has a value It is not exported use Warning Identifier sort already has a value It is not exported use These library functions have the same names as the standard library functions You cannot delete standard library functions and resolve the name conflicts Use the full function names such as numeric product to call these functions 1 67 Notebook Interface Notebook Overview on page 2 3 Debugger Window Overview on page 2 5 Arrange Toolbars and Panes on page 2 8 Enter Data and Vi
349. fied explicitly As an example we consider the attribute LinesVisible that is used by several primitives such as plot Box plot Circle2d plot Cone plot Curve2d plot Raster etc Although they all use the same attribute named LinesVisible its default value differs among the different primitive types The specific defaults are accessible by the slots plot Box LinesVisible plot Circle2d LinesVisible etc plot getDefault plot getDefault plot getDefault plot getDefault plot Box LinesVisible plot Circle2d LinesVisible plot Cone LinesVisible plot Raster LinesVisible TRUE TRUE TRUE FALSE If any of the default values provided by the MuPAD system do not seem appropriate for your applications change these defaults via plot setDefault plot setDefault plot Box LinesVisible FALSE TRUE The return value is the previously valid default value Several defaults can be changed simultaneously plot setDefault plot Box LinesVisible FALSE plot Circle2d LinesVisible FALSE 6 109 6 Graphics and Animations 6 110 plot Circle2d Filled TRUE FALSE TRUE FALSE plot getDefault plot Box LinesVisible FALSE Inheritance of Attributes The setting of default values for attributes is quite sophisticated Assume that you have two scenes that are to be displayed in one single canvas Both scenes consist of 51 graphical points each points1 plot Point2d i 50 PI p
350. for the toolbars graphics units of measurements used in dialog boxes and other options 2 76 Set Preferences for Dialogs Toolbars and Graphics Preferences for Toolbars Specify the following preferences for the toolbars J Icon Size Specify the size of icons in the toolbars Show Labels Select this option to display labels on the buttons of the toolbars mo 1 F ge a Ld m i i L j 1 gt E Mew Notebook New Editor Open Save Print Undo Redo Cut Copy Paste Back Forward Preferences for Graphics You can specify the following preferences for graphics Resolution Specify the dpi value for the resolution you want to use when displaying graphical results Enable OpenGL Select this option to use OpenGL Accelerate OpenGL Select this option to use accelerated OpenGL Mac OS platforms always use accelerated OpenGL Preferences for Dialog Boxes You can specify the following preferences for dialogs Units of measurement displayed Specify the units of measurement you want to use in the MuPAD dialog boxes For example you can use millimeters Dialogs Units of measurement displayed imm Hide Help buttons Hide Welcome dialog in Now all dialog boxes in MuPAD except those displaying the font sizes use millimeters as the units of measurement For example the Paragraph Format dialog box shows the indentation and spacing sizes in millimeters 2 77 2 Notebook Interface i P
351. function returns the parameters of the model and the quadratic error as a nested list To access the parameters separately use the following commands a fit 1 1 b fit 1 2 chi2 fit 2 87 35956975 Univariate Nonlinear Regression 0 9696856368 266012 75899 Now plot the data and expression that you used to fit the data on the same plot This plot shows how the model expression fits the data plot2 plot Function2d a b 2 exp x x x 1 9 plot plot1 plot2 300 800 700 600 500 400 gt 300 200 100 3 305 3 Mathematics Multivariate Regression 3 306 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The stats reg function also performs linear and nonlinear regressions with two or more independent variables The following example demonstrates how to perform regression and fit the data to a function of two variables Suppose you have three data lists that contain coordinates X y and z of discrete points sampleX 0 9612553839 0 329576986 0 7544749248 0 7339191669 0 294101483 0 9809519422 0 6251624775 0 1885706545 0 4729466504 0 4402179092 0 1883574567 0 6260246367 0 0274947885 0 01843922645 0 02687538212 0 03682895886 0 009212115975 0 04956242636 sampleY 0 02185415496 0 9146217269 0 5792023459 0 5440822742 0 8848317212 0 03925037966 0 02360776024 0 5657632266 0 3461422332 0
352. further computations If you know that a particular command returns memory consuming results avoid writing that command and its results to the history table To avoid writing a command and its result to the history table set the value of HISTORY to 0 The disadvantage of this approach is that you delete all previous results from the history table For example set the value of HISTORY to 0 before creating a sequence of 1 000 000 random numbers HISTORY 0 random i 1 10 0 For further computations restore the default maximum number entries in the history table delete HISTORY HISTORY 20 If the history table already contains a memory consuming result to release the memory you also can clear the history table by setting the value of HISTORY to 0 Alternatively you can wait until the MuPAD fills the history table with new entries Also you can select Notebook gt Disconnect to restart the MuPAD engine 5 127 5 Programming Fundamentals Why Test Your Code 9 128 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB After you debug and optimize your code you might still need to test 1t Debugging lets you catch run time errors that appear in your code Testing lets you catch bugs that appear when users provide unexpected combinations of input arguments or when they run your code on different platforms or MuPAD versions It also helps to catch bugs that can appear when
353. fying a range both for x and a plotfunc2d cos a x x 0 2 PI a 1 2 6 31 6 Graphics and Animations 6 32 Y 101 0 8 06 0 4 02 0 0 02 0 4 06 D 8 1 0 Once the plot 1s created the first frame of the picture appears as a static plot After clicking on the picture the graphics tool starts playing the animation There are the usual controls to stop start and fast forward rewind the animation The default number of frames of the animation 1s 50 If a different value 1s desired just pass the attribute Frames n where n is the number of frames that shall be created plotfunc2d sin a x sin x a x O PI a O 4 PI Colors RGB Blue RGB Red Frames 200 Easy Plotting Graphs of Functions 0 5 1 0 Apart from the color specification or the Frames number there is a large number of further attributes that may be passed to plotfunc2d Each attribute is passed as an equation AttributeName AttributeValue to plotfunc2d Here we only present some selected attributes See the section on attributes for plotfunc for further tables with more attributes attribute name possible values example Height 8 unit cm physical height of 80 unit mm the picture Width 12 unit cm physical width of the 120 unit mm picture TitlePosition real value real coordinates of the value lower left corner of the title 6 33 6 Graphics and Animations 6 34 attribute name possible values
354. g xY xY xX x x To create a new sequence using the entries of an existing sequence use the sequence generator with the keyword in or the equivalent command _seqin For example x y y in a b c d f x x in a D c dl _seqin f x x a b c d b c d eke a ie fla JE Fle Fla Fla fib fle Fla You cannot create nested sequences because MuPAD automatically flattens them sequence a b c d a b 10 1 10 f a b cd n pn 10 1 10 f Access Sequence Entries To access particular entries of a sequence by their indices use index you can use square brackets as a shortcut or Op sequence a b c dj sequence 2 index sequence 2 4 op sequence 2 op sequence 2 4 9 7 5 Programming Fundamentals 9 8 Note index uses the order in which the entries appear on the screen and Op uses the internal order of the entries Although for sequences these orders are the same for many other data structures they are different For details see the index help page To access an entry counting numbers from the end of a sequence use negative numbers sequence a b c d sequence 2 If you use an indexed assignment without creating a sequence MuPAD generates a table instead of a sequence S11 X 9 i Ix Add Replace or Remove Sequence Entries To add entries to a sequence list the sequence and the new entries separating them with commas sequence
355. g function with respect to its first variable x Then integrate the function with respect to its second variable y 3 132 Differentiate Functions x y gt 3y The list of indices accepted by the operator D refers to the order in which you provided the variables when creating a function f X y gt x 2 y 3 D 1 f f y X gt x 2 y 3 D 1 f x y 2x y X 3 y To find second and higher order partial derivatives of a function use the same index two or more times For example compute the second order partial derivatives with respect to x and with respect to y Xx y gt x 8 sin y f D 1 1 f D I2 2 f x y 6x sin y x y x sin y To compute second and higher order derivatives with respect to several variables mixed derivatives provide a list of indices of differentiation variables f i x V gt x 3 sini y D 1 2 f 3 133 3 Mathematics X y 3x cosiy Note To improve performance MuPAD assumes that all mixed derivatives commute For example D f 2D f This assumption suffices for most engineering and l 7 e F 1 1 e 7T a scientific problems 3 134 Compute Indefinite Integrals Compute Indefinite Integrals Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To integrate a mathematical expression f means to find an expression F such that the first derivative o
356. ght to left 2 18 Format Text i Paragraph Format Indention Left 0 00 First 5 00 Right 0 00 Alignment Background Word wrap Writing Direction Left To Right Keep Lines together If you want to experiment with different paragraph settings and see how the formatted text looks 1n your notebook click the Apply button This button applies formatting to the selected text and leaves the Paragraph Format dialog box open You can change paragraph settings several times without having to open this dialog box for each change When you finish formatting click OK to close the Paragraph Format dialog box 2 19 2 Notebook Interface File Edit View Navigation Insert Format Motebook Window Help Bowes are 0 002 800692 Piecewise solutions The solution of the quadratic equation a x bx c 0is piecewise Here a b and c are symbolic parameters and x is a symbolic variable Piecewise objects often occur if an equation contains symbolic parameters in addition to the variable Not Connected 2 20 Format Mathematical Expressions Format Mathematical Expressions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB You can change font style size and color of mathematical expressions in text regions in the same way you format regular text See Choosing Font Style Size and Colors for more details For additional formatting of mathematical expressions Selec
357. gn a value to any of these identifiers For example assign the value 10 to the identifier a Now MuPAD recognizes that a is equal to 10 Therefore the system evaluates the value a x of the identifier y to the expression X 10 a i 10 y x4 10 Note The value of an identifier 1s the value computed at the time of assignment 3 9 3 Mathematics 3 6 The value of the identifier y is still x a If you assign any other value to a MuPAD evaluates y using this new value a 15 y x 15 Now assign the value 10 to the identifier a and then assign the expression X a to y As in the previous example MuPAD evaluates the identifier y and returns the expression X 10 a 10 V 2 7 x2 y x 10 Although the evaluation returns the same result as in the previous example the value of y is different Here the value of y is the expression X 10 This value does not depend of the identifier a a 15 y x 10 For further computations clear the identifiers a x and y delete a x y The value of an identifier can be any MuPAD object For example the value of an identifier can be a list list x k k 1 10 7 B 9 i d A amp i PX uh xe qu ue ou wi S db el If later you assign the value to x the evaluation of the identifier list changes accordingly X 1 2 list Evaluations in Symbolic Computations a m nn c MuPAD applies the same evalu
358. gonometric expression combine 2 sin x cos x sincos sin 2 x If you do not specify a target function combine uses the identities for powers wherever these identities are valid e b d a eg af b a b if c is an integer a yY a if c is an integer For example by default the function combines the following square roots combine sqrt 2 sqrt x m V 2x The function does not combine these square roots because the identity is not valid for negative values of variables combine sqrt x sqrt y 3 95 3 Mathematics 3 96 To combine these square roots use the IgnoreAnalyticConstraints option combine sqrt x sqrt y IgnoreAnalyticConstraints Z As target functions combine accepts arctan exp gamma ln sincos and other functions For the complete list of target functions see the combine help page Expand Expressions For elementary expressions the expand function transforms the original expression by multiplying sums of products expand x 1 x 2 x 3 3 A x 6x 11x 6 expand also uses mathematical identities between the functions expand sin 5 x E d o r 4 TP eo JAEN l sm x cos x 12 sm x cos x smix expand works recursively for all subexpressions expand sin 3 x 1 cos 2 x 1 2 smix 2 cos x 10 cosix sm x S cos x sm x 2 To prevent the expansion of particular subexpressions pass these subexpressions to expand as arguments
359. gral MuPAD restores the assumptions set for integration variable If you do not want the assumptions to affect further computations use the unassume function unassume x MuPAD also makes implicit assumptions on the specified interval Suppose you use the integration range as a b The system assumes that both a and b represent real numbers and that a lt b unless you clearly specify otherwise If you set the value of intlib printWarnings to TRUE MuPAD displays the warning about using implicit assumptions int heaviside x a x a b Warning Cannot decide if a lt b is true will temporarily assume it is true int rp signfa 5 _ 1 To avoid this implicit assumption specify that a gt bora lt b int heaviside x a x a b assuming a gt b int heaviside x a x a b assuming a b D da 3 139 3 Mathematics For further computations disable the warnings intlib printWarnings FALSE 3 140 Compute Multiple Integrals Compute Multiple Integrals Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To compute multiple integrals use nested calls to int For example compute the surface area and the volume of a sphere using spherical coordinates Compute the expression for the surface area of a sphere The distance from the center of a sphere to the surface remains constant r R The angle changes its value from O to u The
360. he complete solution for all possible values of parameters including complex values t solve h g t 2 2 t pu v2 ed if gx D VE VE t C if g 0ah 0 e if g 0 A5s0 If you do not consider the special case where no gravitational forces exist you can safely assume that the gravitational acceleration 1s positive This assumption removes the special zero gravity cases from the solution assume g gt 0 t solve h g t 2 2 t Use Permanent Assumptions The variable h in the equation represents the height from which the object falls If you do not consider that someone initially throws the object upward and that the object reflects from the ground the height h is always positive Therefore you can assume that both gravitational acceleration g and height h are positive assume g gt 0 and h gt QO t solve h g t 2 2 t Assuming that the time of the drop is a positive value you get the expected result When you set assumptions on variables the solver compares the obtained solutions with the specified assumptions This additional task can slow down the solver assume g gt O and h gt O and t gt 0 t solve h g t 2 2 t The solver returns the solutions as a set even if the set contains only one element To access the elements of a solution set use square brackets or the op command time t 1 h i2 time so WE Clear the variable t for further computations delete t If you set se
361. he system displays can differ from the actual result The simplest example of this behavior is that MuPAD does not display all computed results You can suppress outputs by terminating commands with colons For example the evaluation of the following expression returns 4 However MuPAD does not display any output because the expression is terminated with a colon 2 23 The function call last 1 returns the previously computed value Alternatively you can use the operator to return that value 6 MuPAD also suppresses intermediate results obtained within loops and procedures For example the evaluation of the following for loop returns five numbers However the output contains only the final result for x from 1 to 5 do hold power x 2 x 2 end for uh ll a Ln To display intermediate results obtained in loops and procedures use the print function inside a loop or a procedure For example to display all five numbers obtained in the for loop enter for x from 1 to 5 do print hold power x 2 x 2 end for 3 21 3 Mathematics 3 22 P ed ms 4 16 295 Alternatively use the fprint function This function typically writes results to a file indicated by one of the arguments of f print When this argument is 0 the function displays the results on screen for x from 1 to 5 do fprint Unquoted 0 hold power x 2 x 2 end for eo 4 ges 4 2 2 g 42 T5 5 2 25 The print and fp
362. he arithmetic average of each list by using the stats mean function meanL stats mean L means stats mean S 12 0 89 0 Calculate the first four central moments of the list L stats moment O meanL L stats moment 1 meanL L stats moment 2 meanL L stats moment 3 meanL L 1 0 0 0 968 0 74536 0 The zero and first central moments are the same for any data sample The second central moment is the variance computed with the divisor n stats variance L Population 968 0 Now calculate the first four central moments of the list S stats moment O means stats moment 1 means stats moment 2 means stats moment 3 means NNUNU 1 0 0 0 968 0 74536 0 Compute Measures of Shape Again the zero central moment is 1 the first central moment is 0 and the second central moment is the variance computed with the divisor n stats variance S Population 968 0 The obliquity skewness is a measure of the symmetry of a distribution If the distribution 1s close to symmetrical around its mean the value of obliquity 1s close to zero Positive values of obliquity indicate that the distribution function has a longer tail to the right of the mean Negative values indicate that the distribution function has a longer tail to the left of the mean For example calculate the obliquity of the lists L and 9 stats obliquity L stats obliquity S 2 474873734 2 4748737
363. he element x of a sorted data sample x xs X2n The stats geometricMean function calculates the geometric mean x a ae E of a data sample x xs Xn The stats harmonicMean function calculates the harmonic mean 1 of a data sample x xs Xp The arithmetic average is a simple and popular measure of central tendency It serves best for data samples that do not have significant outliers Unfortunately outliers for example data entry errors or glitches exist 1n almost all real data The arithmetic 3 267 3 Mathematics 3 268 average and quadratic mean are sensitive to these problems One bad data value can move the average away from the center of the rest of the data by an arbitrarily large distance For example create the following two lists of entries that contain only one outlier The outlier is equal to 100 in the first list and to 1 in the second list L 1 1 1 1 1 100 0 S 100 100 100 100 100 1 0 The stats modal function shows that the most frequent entry of the first list 1s 1 The most frequent entry of the second list 1s 100 A most frequent entry appears in each list five times modalL stats modal L modalS stats modal S modalL 1 5 modalS 100 5 If the value of the outlier is large the outlier can significantly move the mean and the quadratic mean away from the center meanL stats mean L quadraticMeanL stats quadraticMean L meanl
364. he end point of the line depend on it plot plot Function2d a sin x x 0 a PI a 0 5 1 plot Rectangle O a PI 0 a a 0 5 1 LineColor RGB Black plot Line2d 0 0 PI 8 a a 0 5 1 LineColor RGB Black Yio 09 0 8 0 7 0 8 0 5 0 4 0 3 02 0 1 0 0 00 02 04 06 06 10 12 14 16 18 20 22 24 26 28 3 0 6 130 Animations Additional range specifications may enter via the graphical attributes Here is an animated arc whose radius and angle range depend on the animation parameter plot plot Arc2d 1 a 0 0 AngleRange O a PI a O 1 2 0 1 5 1 0 0 5 0 0 0 5 1 0 1 5 2 0 Here the attribute AngleRange is identified by its attribute name and thus not assumed to be the specification of an animation parameter with animation range Note Do make sure that attributes are specified by their correct names If an incorrect attribute name is used it may be mistaken for an animation parameter In the following examples we wish to define a static semicircle using plot Arc2d with AngleRange O PI However AngleRange is spelled incorrectly A plot is created It is an animated full circle with the animation parameter AngelRange plot plot Arc2d 1 0 0 AngelRange O PI 6 131 6 Graphics and Animations 6 132 Y 101 0 9 0 8 07 0 6 0 5 0 4 0 3 02 0 1 0 0 00 01 02 03 04 05 06 07 08 09 10 X The animation parameter may be any symbolic parameter i
365. he first starts with a rectangular strip that is deformed to an annulus in the x y plane c i a gt 1 2 1 1 sin PI 2 a Animations mycolor u V X y Z gt u 0 8 0 4 O 1 2 u O 4 rectangle2annulus plot Surface c a u c a cos PI v u c a sin PI v 0 u 0 8 1 2 v a a a 1 10 10 1 FillColorFunction mycolor Mesh 3 40 Frames 40 plot rectangle2annulus Axes None CameraDirection 11 3 3 The second animation twists the annulus to become a Moebius strip annulus2moebius plot Surface u 1 cos a v PI 2 1 cos PI v u 1 cos a v PI 2 1 sin PI v u 1 sin a v PI 2 u 0 8 1 2 V 1 1 a D T FillColorFunction mycolor Mesh 3 40 Frames 20 plot annulus2moebius Axes None CameraDirection 11 3 3 6 151 6 Graphics and Animations 6 152 Note that the final frame of the first animation coincides with the first frame of the second animation To join the two separate animations we can set appropriate visibility ranges and plot them together After 5 seconds the first animation object vanishes and the second takes over rectangle2annulus VisibleFromTo 0 5 annulus2moebius VisibleFromTo 5 7 plot rectangle2annulus annulus2moebius Axes None CameraDirection 11 3 3 Animations Example 3 In this example we consider the planar celestial 3 body problem We solve th
366. he following illustration 2 5 2 Notebook Interface File Edit View Step Greakpoints Watches Help ili av SAREN Local procedure contains 42 43 contains lt Procedure 44 proc 1 zx 45 local i n E factor 46 begin E 47 i 1 n nops 1 43 while i n do 45 if specfunc aba l il x l10 DIGITS 50 return i 51 end 52 i i 1 53 end B 54 return 0 55 end 56 57 f local procedure round2zera 58 r aundzzera 58 Proc x eps l10 DIGITS 20 begin el if type x DOM COMPLEX then ez roundzzerno opi x 1 eps t I roundzzera op x z eps else if abs x absleps le Z then else C Evaluate Mem 7 MB TU s A Perform common tasks from the toolbar B View the code that you debug Debugger Window Overview C Type an expression and evaluate it in the Output pane anytime during the debugging process D Use the Status bar to view memory and time usage for the current or most recent debugging step E Use the Watch pane to view values of variables during the debugging process F Use the Call Stack pane to view the names of the procedures participating in the debugging process For information about the Debugger mode see Tracing Errors with the Debugger 2 7 2 Notebook Interface Arrange Toolbars and Panes View Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB
367. he number 27648 has 44 divisors and 2 of them are prime numbers The prime divisors of 27648 have multiplicities the total sum of these multiplicities is 13 numlib numdivisors 27648 numlib numprimedivisors 27648 numlib Omega 27648 You can factor the number 27648 into prime numbers to reveal the multiplicities To factor an integer into primes use the ifactor function ifactor 27648 510 33 To compute the sum of all positive integer divisors of an integer number use the numlib sumdivisors function For example compute the sum of positive divisors of the number 12345 numlib sumdivisors 12345 19776 Compute Greatest Common Divisors The largest nonnegative integer that divides all the integers of a sequence exactly without remainders is called the greatest common divisor of a sequence To compute the greatest common divisor of a sequence of integers use the igcd function For example compute the greatest common divisor of the following numbers igcd 12345 23451 34512 45123 51234 Divisors The icontent function computes the greatest common divisor of the coefficients of a polynomial All coefficients must be integers icontent 12 x 2 16 x 24 A Compute Least Common Multiples The smallest integer that is exactly divisible without remainders by all integers of a sequence is called the least common multiple of a sequence To compute the least common multiple of a sequence of integ
368. he original matrix P testeq P L linalg transpose L TRUE 3 203 3 Mathematics Note MuPAD returns a lower triangular matrix as a result of Cholesky factorization MATLAB returns an upper triangular matrix which 1s the transpose of the result returned by MuPAD When MuPAD cannot determine whether a matrix is Hermitian linalg factorCholesky throws an error A matrix a b c b c a c a b linalg factorCholesky A Error A Hermitian matrix is expected linalg factorCholesky If you know that the matrix is Hermitian you can suppress this error The NoCheck option suppresses the error and lets the linalg factorCholesky function continue the computation linalg factorCholesky A NoCheck a 0 0 T E E 0 Y V ZI M 84 yes al b 0 Ibl e 84 va Pon Fs ARRIUS 5 a 05 Tiai v b where m 2 s IB e lai 5 j o clb5l a5 lal i eo 94 A c lal Ibl If you know that the matrix is real and symmetric use the Real option to avoid complex conjugates implied by a a in the result 3 204 linalg factorCholesky A NoCheck Real ae ac b D V a 7 j gt be a La d 3abctb e E 4 ige hb ac b a I Compute Cholesky Factorization 3 205 3 Mathematics Compute LU Factorization 3 206 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The LU factorization expresses an mxn
369. he outer loops for i from 1 to 3 do for j from 1 to 2 do if i j then print Unquoted break with i j 1 break end_if print Unquoted i i j j end for Loops end for break with i II i H 172 1 break with 1 j 2 1 3 j 1 i 3 j 2 Suppose you want to stop executing the statements and exit the nested loops as soon as the condition i j is true Use the additional variable for the break state of the inner loop Use this variable to exit the outer loop breakAll FALSE for i from 1 to 3 do for j from 1 to 2 do if 1 j then print Unquoted break with i j 1 breakAll TRUE break end if print Unquoted i 1 j j end for if breakAll then break end Tj end for break with 1 j 1 Skip Part of Iteration To skip the commands from a particular point to the end of a loop and start the next iteration use the next command for i from 1 to 3 do 4 15 4 Programming Basics for j from 1 to 2 do if 1 j then print Unquoted i j expr2text 1 next end if print Unquoted i expr2text i j expr2text j end for end for i j 1 i 1 j 2 i 2 j 1 i j 2 i 3 j 1 1 3 J 2 Return Value of a Loop All MuPAD commands produce some return values Loops in MuPAD return the result of the last executed statement for i from 1 to 3 do X 1 2 i y i 3 i end for 9 Suppress the output of the return value with a colo
370. he physical time in seconds that the animation will last Note The parameter range amin amax in the specification of the animation parameter a amin amax together with Frames n defines an equidistant time mesh in the time interval set by TimeBegin tO and TimeEnd t1 The frame with a amin is visible at the time tO the frame with a amax is visible at the time t1 Note With the default TimeBegin O the value of the attribute TimeEnd gives the physical time of the animation in seconds The default value is TimeEnd 10 1 e an animation using the default values will last about 10 seconds The number of frames set by Frames n does not influence the time interval but changes the number of frames displayed in this time interval Here 1s a simple example plot plot Point2d a sin a a O 2 PI Frames 100 TimeRange 0 5 Animations Y 40 0 8 0 6 0 2 0 0 0 2 X 0 4 0 6 0 8 1 0 The point will be animated for about 5 physical seconds in which it moves along one period of the sine graph Each frame is displayed for about 0 05 seconds After increasing the number of frames by a factor of 2 each frame is displayed for about 0 025 seconds making the animation somewhat smoother plot plot Point2d a sin a a O 2 PI Frames 200 TimeRange 0 5 6 137 6 Graphics and Animations 6 138 Y 40 0 8 0 6 0 2 0 0 0 2 X 0 4 0 6 0 8 1 0 Note that the human
371. he pivot leading coefficient of each nonzero row always occurs to the right of the leading coefficient of the row above If the component ring of the original matrix 1s a field the reduced row echelon form is unique and each pivot 1s 1 To find the reduced row echelon form of a matrix use the linalg gaussJordan function This function performs Gauss Jordan elimination on a matrix A matrix 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 linalg gaussJordan A 14 1 9 012 3 00 0 0 00 0 0 Compute Rank of a Matrix Compute Rank of a Matrix Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The rank of a matrix 1s the number of independent rows of a matrix For a matrix in its reduced row echelon form the rank is the number of nonzero rows To compute the rank of a matrix use the linalg rank function For example compute the rank of the following square matrix A matrix 9 10 1 linalg rank 15 2 3 4 5 6 l 8 1 12 18 14 15 16 A 2 Now compute the reduced row echelon form and the rank of the following 3x4 matrix OriginalMatrix matrix 1 2 3 5 6 7 9 10 11 13 14 15 RREF linalg gaussJordan OriginalMatrix Rank linalg rank OriginalMatrix 1 2 3 5 6 7 9 10 11 13 14 15 10 1 01 2 meet ag Oo 0 3 195 3 Mathematics Compute Bases for Null Spaces of Matrices 3
372. he statements written under the first valid condition use the break command See Exiting a Conditional Statement for more details Note MuPAD executes the case statements differently from MATLAB MATLAB executes only the first matching case statement and skips the following case statements In MuPAD you must use the break command to stop execution of the following statements Exit a Conditional Statement To exit a conditional statement after executing the statements written under the first valid condition use the break command For example select the meaning of the traffic hght signals trafficLight yellow 4 Programming Basics 4 6 case trafficLight of red do print Stop break of yellow do print Caution break of green do print Go break end_case Caution Return Value of a Conditional Statement All MuPAD commands produce some return values Conditional statements return the result of the last executed command mapColor blue if mapColor blue then water else land end if water Use the return value of a conditional statement like any other value For example assign the return value to a variable By default MuPAD does not allow conditional statements in assignments To create a valid assignment enclose conditional statements in parentheses Suppress the output of the return value of a conditional statement with a colon mapColor blue terrain if mapColor blue then water else
373. hem has the following disadvantages Your users can access utility functions If they rely on a particular implementation of the utility function changing that implementation might affect their code The utility function cannot access local variables of the procedure that uses that utility function The workaround 1s to pass these local variables as arguments to the utility function The utility function does not have privileged access to the arguments of the procedure that uses that utility function Utility Functions Defining the utility function far from the code line where you call it reduces readability of the code Be careful when defining utility functions in slots of a function environment because MuPAD uses these slots for overloading Do not define utility functions with such names as f print f diff f evaluate or f simplify unless you want to use these utility functions for overloading Utility Functions in Closures You can define a utility function and all procedures that use it inside one procedure In this case you must also define the utility function as a local variable of that outer procedure The outer procedure can be anonymous For example create the anonymous procedure that has a local variable helper and includes the utility function helper and two other procedures f and g that use the utility function proc local helper option escape begin helper DroG sis end f i proc arg
374. hematics 3 92 not combine logarithms The rule for combining logarithms does not hold for arbitrary complex arguments and therefore combining logarithms can be incorrect for some parameters Simplify ln x 2 In x 2 4 x 4 In x 2 ln x 2y Potential division by zero 1s the only exception of this rule Simplify x x 1 x xl To apply more simplification rules that are not generally correct but which can return simpler results use the option IgnoreAnalyticConstraints This option is available for both simplify and Simplify For example simplifying an expression with IgnoreAnalyticConstraints you get the result with combined logarithms Simplify ln x 2 In x 2 4 x 4 IgnoreAnalyticConstraints In x 2 For the list of all options available for the general simplifiers see simplify and Simplify Choose Simplification Functions Choose Simplification Functions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Collect Terms with Same Powers on page 3 94 Combine Terms of Same Algebraic Structures on page 8 95 Expand Expressions on page 3 96 Factor Expressions on page 3 97 Compute Normal Forms of Expressions on page 3 98 Compute Partial Fraction Decompositions of Expressions on page 3 99 Simplify Radicals in Arithmetic Expressions on page 3 99 Extract Real and Imaginary Parts of Complex Expressions on page 3 100 Rew
375. here it refers to simplification rules such as max a max b c max a b c Quick Reference function number numerical expression Typically functions are represented by a procedure or a function environment Also functional expressions such as sin exp id 2 x sinfe x represent functions Also numbers can be used as constant functions For example the call 3 X yields the number 3 for any argument X A number may be an integer of type DOM INT or a rational number of type DOM RAT or a real floating point number of type DOM FLOAT or a complex number of type DOM COMPLEX The type DOM COMPLEX encompasses the Gaussian integers such as 3 7 I the Gaussian rationals such as 3 4 7 4 1I and complex floating point numbers such as1 2 3 4 I This is an expression that does not contain any symbolic variable apart from the special constants Mathematical Constants Available in MuPAD on page 3 227 Mathematical Constants Available 1n MuPAD on page 3 227 Mathematical Constants Available in MuPAD on page 3 227 and Mathematical Constants Available in MuPAD on page 3 227 A numerical expression such as I 1 3 sqrt PI exp 17 is an exact representation of a real or a complex number it may be composed of numbers radicals and calls to special functions It may be converted to a real or complex floating point number via float overloading polynomial polynomial expre
376. hese additional parameters but enables you to access them The args function lets you access the arguments of a current procedure call The call args i where i is a positive integer returns the ith argument of the current procedure call The call args 0 returns the total number of arguments in the current procedure call For example the following procedure computes the sum of its arguments in each procedure call f proc begin _plus args i i 1 args 0 end proc The procedure works for any number of arguments Tijs T f a b 0 100 15 a 5 e 500500 Also you can access the whole sequence of arguments or any subsequence of that sequence For example the following procedure prints all arguments used in the current Access Arguments of a Procedure call If the current call uses three or more arguments the procedure also prints its first three arguments g proc begin print Unquoted all arguments args if args 0 gt 2 then print Unquoted first three arguments args 1 3 else print Unquoted not enough arguments end if end proc Call the procedure g with five arguments g 10 20 30 40 50 all arguments 10 20 30 40 50 first three arguments 10 20 30 When you pass arguments to a procedure MuPAD evaluates these arguments Then the system creates a local variable for each formal parameter specified 1n the procedure definition The system assigns evaluated argu
377. his identifier the level 10 returns the complete evaluation for 1 from O to 10 do 3 11 3 Mathematics print level 1 hold x 1 level x 1 1 end for level 0 x X level 1 x Ir level 2 x 6 X level 3 x 24 Xy level 4 x 120x level 5 x x 720 x level 6 x 5040 Xj level 7 x 40320 Xy level 8 x 362880 x level 9 x 3628800 X10 level 10 x 36288000 Since the default value of the environment value LEVEL 100 is greater than 10 in interactive computations MuPAD returns the completely evaluated identifier x x 1 Level of Evaluation 36288000 Delete the identifiers x delete x Set the value of the environment variable LEVEL to 2 LEVEL 2 Now MuPAD evaluates the identifier x only up to the second level X k k 1 x k 1 k 1 9 X 10 10 x 1 x The new value of LEVEL affects all interactive evaluations except for evaluations in arrays matrices tables and polynomials For example use the following recursive definition for the 1dentifiers a b and c Evaluation of the identifier a proceeds only to the second level For further computations delete the identifiers delete x a b c The new value of LEVEL does not affect evaluations that happen in procedures The evaluation level in procedures remains equal to 1 For example create the procedure myProc that defines the values of the identifiers a b
378. i MuPAD notebook has a special type of region for viewing results Output regions serve for viewing results These regions automatically appear when you evaluate input regions The results can include graphics and error messages The default font color for output regions is blue You cannot edit data in the output regions To change the results edit the associated input region and evaluate it by pressing Enter Also you can copy results from the output regions to the text and input regions When you copy outputs to the input regions MuPAD inserts ASCII equivalents of the results 1n the input regions If you want to change the default text color font or the appearance of brackets for the current notebook see Changing Default Format Settings If you want to change preferences for all notebooks see Setting Preferences for Notebooks 2 11 2 Notebook Interface Note Most preferences affect only new notebooks They do not affect existing notebooks 2 12 View Status Information View Status Information Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The status bar shows the current status information Mem 12 MB T9 Cmd LP INS A B C A Displays memory and time usage for the current or most recent computation B Indicated the type of the currently active region e C Indicates insert or overwrite mode View the current engine state at the far left end of the status bar
379. i epsilon zeta theta iota lambda nu omicron varpl piv sigma tau straightphi phi chi omega Beta Delta Zeta Theta Kappa Pi Sigma Upsi upsih Upsilon Chi co 3 E A eoa I d mou Mon c C d u oO varepsilon epsiv eta thetasym thetav vartheta kappa mu micro xl pi rho sigmaf sigmav varsigma upsilon upsi phiv varphi psi Alpha Gamma Epsi Epsilon Eta Iota Lambda Nu Omicron Rho Tau Phi Psi Oo Open Face Letters Omega ohm Typeset Symbols in MuPAD A Aopf E Bopf C Copf In Dopf Eopf IF Fopf m Gopf H Hopf Iopf J Jopf K Kopf L Lopf Mopf IN Nopf D Oopf Popf Qopf IE Ropf T Sopf T Topf im Uopf WV Vopf W Wopf X Xopf Yopf Z Zopf Arrows T uarr UpArrow ff Uparrow DoubleUpArrow uArr 4 darr DownArrow l Downarrow dArr DoubleDownArrow LeftArrow larr DoubleLeftArrow leftarrow Leftarrow lArr 5 leftrightarrow harr Leftrightarrow LeftRightArrow DoubleLeftRightArrow iff hArr 8 33 8 More Information About Some of the MuPAD Libraries 8 34 Operators I cp Ico im RightArrow rarr rightarrow ldsh plus PlusMinus plusmn pm Hat circ prod ast bull bullet cir compfn SmallCircle oplus CirclePlus bigoplus xoplus bigodot xodot CircleDot Dagger div divide Element isin isinv in wedge and Wedge xwedge
380. ialog box click Notebook 2 71 2 Notebook Interface J Configure MuPAD New Motebooks Settings Choose default settings for NEW notebooks These Motebook z User Interface Output Settings Typeset math Abbreviate output Fretty Print Text width for plain text outputsis 75 characters Engine General Preferences E Evaluate on Shift enter Save Notebook backup every 10 i minutes Global Settings Embed scalable graphics for plots in clipboard RTF Highlight matching parentheses in input regions The right pane of the dialog box lets you change two types of settings the settings that affect the new notebooks only and the global settings that affect all notebooks including existing ones For new notebooks you can do the following Change the default formatting settings of all new notebooks For details see Changing Default Formatting for Notebook Elements 2 12 Set Preferences for Notebooks Change the default mode for displaying results For details on output modes see Using Different Output Modes Change the default line length for displaying results in plain text format Change key sequence for evaluation of input regions to Shift Enter The default key is Enter Specify how often MuPAD automatically saves a backup document For all notebooks including existing ones you can do the following On Windows platforms copy graphics using scalable Windows Metafile WMF format For details s
381. iance 1 Both p values are much smaller than the significance level The null hypothesis states that the sequence X has a normal distribution with the mean 1 and the variance 1 This hypothesis must be rejected stats ksGOFT x CDF stats normalCDF 1 1 PValuel 1 7315647 Nu StatValuel 4 377042911 PValue2 2 761005529 10 1 StatValue2 3 938439155 Perform Shapiro Wilk Test Perform Shapiro Wilk Test Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The Shapiro Wilk goodness of fit test asserts the hypothesis that the data has a normal distribution For the Shapiro Wilk goodness of fit test MuPAD provides the Stats SwGOFT function For example create the normally distributed data sequence X by using the stats normalRandom function fx stats normalRandom O 1 2 X fx k 1 1000 Also create the data sequence y by using the stats poissonRandom function This function generates random numbers according to the Poisson distribution fy stats poissonRandom 10 y fy k 1 1000 Now use the stats SwGOFT function to test whether these two sequences are normally distributed Suppose you use the typical significance level 0 05 For the first sequence X the resulting p value 1s above the significance level The entries of the sequence X can have a normal distribution For the second sequence y the resulting p value 1s below the significance leve
382. identally If you create a new MuPAD procedure it 1s recommended to protect the procedure and all its options especially if you often use that procedure For example MuPAD does not provide a function for computing Lucas numbers You can write your own procedure for computing Lucas numbers and then protect the procedure name The Lucas numbers are a sequence of integers The recursion formula that defines the nth Lucas number 1s similar to the definition of the Fibonacci numbers L l 3 b d f L r Create the following procedure that computes the nth Lucas number lucas proc n Type PosInt option remember begin if n 1 then 1 elif n 2 then 3 else lucas n 1 lucas n 2 end if end proc lucas i i 1 5 1 3 4 7 1 Now protect the procedure name lucas using protect with the ProtectLevelError option Protect Function and Option Names protect lucas ProtectLevelError ProtectLevelError lets you set full protection for the identifier Now trying to assign any value to lucas results in error lucas 0 Error The identifier lucas is protected assign Alternatively you can use the ProtectLevelWarning option In this case you can still assign a value to the protected identifier but a warning appears for example protect lucas ProtectLevelWarning You can assign any value to lucas now but such assignment triggers a warning lucas 0 Warning The protected variable lucas
383. ight in a tea cup The rim of the cup regarded Animations as a mirror is given by the function f x 4 1 x x 1 1 a semicircle Sun rays parallel to the y axis are reflected by the rim After reflection at the point x f x Fd Y of the rim a ray heads into the direction 1 R fx if x 1s positive It heads f PO yY into the direction 1 f lx if xis negative Sweeping through the mirror from left to right the incoming rays as well as the reflected rays are visualized as lines In the animation they become visible after the time 5 x where x 1s the coordinate of the rim point at which the ray 1s reflected f x gt sqrt 1 x 2 plot The static rim plot Function2Qd f x x 1 1 Color RGB Black The incoming rays plot Line2d x 2 x f x VisibleAfter 5 x x in 1 i 20 i 1 39 The reflected rays leaving to the right plot Line2d x f x 1 f x 1 x f x 1 f x 2 Color RGB Orange VisibleAfter 5 x xin 1 1 20 i 1 19 The reflected rays leaving to the left plot Line2d x f x Phy TUR AXPIR IT Reds Color RGB Orange VisibleAfter 5 x x in 1 1 20 i 21 39 ViewingBox 1 1 1 1 6 147 6 Graphics and Animations SS SW WL S rr ee ee ee A Ti LL INL ee b L LES ood d d AIR i ee Pon L d MIN 9 8 11 d Mn ee a o8 0 0 1 0 a ak a e erm o
384. illates wildly near the origin plotfunc2d sin 1 x x 0 5 0 5 6 35 6 Graphics and Animations 6 36 0 4 0 5 Clearly the default of 121 sample points used by plotfunc2d does not suffice to create a sufficiently resolved plot We increase the number of numerical mesh points via the Mesh attribute Additionally we increase the resolution depth of the adaptive plotting mechanism from its default value AdaptiveMesh 2toAdaptiveMesh 4 plotfunc2d sin 1 x x 0 5 0 5 Mesh 500 AdaptiveMesh 4 Easy Plotting Graphs of Functions 0 4 0 5 The following call specifies a header via Header The function sin x 2 The distance between labeled ticks 1s set to 0 5 along the x axis and to 0 2 along the y axis via XTicksDistance 0 5 and YTicksDistance 0 2 respectively Four additional unlabeled ticks between each pair of labeled ticks are set in the x direction via XTicksBetween 4 One additional unlabeled tick between each pair of labeled ticks in the y direction 1s requested via YTicksBetween 1 Grid lines attached to the ticks are switched on by GridVisible TRUE and SubgridVisible TRUE plotfunc2d sin x 2 x O 7 Header The function sin x 2 XTicksDistance 0 5 YTicksDistance 0 2 XTicksBetween 4 YTicksBetween 1 GridVisible TRUE SubgridVisible TRUE 6 37 6 Graphics and Animations 6 38 The function sin x 2 EEEH EEEE s UE A LAL i epr When
385. indicate where the procedure spends most of its execution time time g 62023 876 To obtain the complete profiling report that shows timings for all inner function calls use prog profile prog profile g percent usage of all time self per single call time self time children per single call 5 101 5 Programming Fundamentals time children calls normal exit calls remember exit calls errors index function name 100 0 109982 9 109982 9 1 0 procedure entry point 45 9 50467 2 i 27149 6 3019825 1 Dom Matrix Dom Integer index intern 19 7 21689 3 5460 3 3019825 2 Dom Integer coerce 16 7 18373 1 77616 9 3019825 3 Dom Matrix Dom Integer 127 14 0 13984 8 96 0 95990 0 1000 4 f 5 0 5460 3 i 3019825 5 Dom Integer convert 8 0 8 0 109974 9 109974 9 1 6 g 5 102 Profile Your Code index et ime self children called index name 0 100 0 109982 8 0 1 procedure entry point 8 0 109974 8 1 6 g 50467 24 27149 65 3019825 3 Dom Matrix Dom Integer index 1 45 9 50467 24 27149 65 3019825 Dom Matrix Dom Integer index im 21689 30 5460 346 3019825 2 Dom Integer coerce 21689 30 5460 346 3019825 1 Dom Matrix Dom Integer index intern 2 19 7 21689 30 5460 346 3019825 Dom Integer coerce 5460 346 0 3019825 5 Dom Integer convert 18373 13 77616 89 3019825 4 f
386. ing and naming the target in advance 1 Open the notebook in which you want to insert a link 2 Select the part of a notebook where you want to insert the link 3 From the context menu select Insert link interactively 2 51 2 Notebook Interface Help about first Undo Redo Cut Copy Paste Select Contents Select Region Delete Output Create link Insert link interactively s Link target Characters Paragraph Frame The following dialog box appears To continue creating a link click OK Interactive mode Navigate to any MuPAD notebook and select a point to link to Use the right mouse button to select a link target mm 2 52 Open the notebook where you want to insert the link target If you create a new notebook save it before proceeding Select the part of the notebook to which you want to link Work with Links 7 Right click the selected part From the context menu select Interactive link to this point Second_Notebook MuPAD o File Edit View WNavigation Insert Format Notebook Window Help La E E jet E i ag a T Qe TL 4 Y o 9 le Generic Sans Serif liv The solver detects the type of the differential equation and chooses an algorithm according to the Command Bar ca detected equation type If you know the type of the equation you can use the option Type tf mf pf OdeType to pass the equation type to the solver Passing the equation type to the
387. ion MuPAD evaluates the identifier x to the 100th evaluation level which is the default value of the environment variable LEVEL MAXLEVEL 112 X k k 1 x k 1 k 1 110 x 111 1 x 1 9475947759838359472085162312448293067495673127947072543768327889353416977599310221470 50308 7861521808346211625420003542522585302706302003264000000000000000000000000x 5 delete x To evaluate x to the 111th evaluation level you must change both LEVEL and MAXLEVEL variables Also you can use the level function instead of changing the value of LEVEL MAXLEVEL 112 X k k 1 x k 1 k 1 110 x 111 t 1 level x 1 111 17629525510902446638721610471070757887614095 360265655 16041574063347346955087248316 43655557459846231577319604766283797891314584749719987162332009625414533120000000 0000000000000000000 Increase the value of MAXLEVEL only when you know that your code requires it Do not increase this value for computations where you can avoid it If your code has infinite loops the increased level of MAXLEVEL can significantly decrease performance Always restore the default value for further computations delete x MAXLEVEL 3 Mathematics Enforce Evaluation 3 16 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD automatically evaluates results returned by most of the system functions However a few functions can return unevaluated results For
388. ion About Some of the MuPAD Libraries Functional Programming 8 8 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The functions of the fp package are higher order functions and other utilities useful for functional programming Some other functions useful for functional programming are already contained in the MuPAD standard library like map select and zip 2 66 For a more detailed description of concepts like higher order function currying and fixed points see for example the textbook Computability Complexity and Languages by M Davis R Sigal and E J Weyuker Academic Press 1994 Most of the functions of the fp package take functions as arguments and return other functions In this context a function may be a functional environment a procedure a kernel function or any other object which may be regarded as a function i e applied to arguments Note that almost all MuPAD objects are functions in this sense The rational integer 2 3 for example may be regarded as a constant function returning the value 2 3 2 3 x had ba The list sin cos 2 3 may be regarded as a unary function mapping x to sin x cos x 2 3 sin cos 2 3 x sin x cos x The library functions are called in the form fp fixedpt f By this mechanism naming conflicts with other library functions are avoided If this 1s found to be too awkward the methods of th
389. ion into the original equation testeq subs equation x op solution 1 assuming op solution 2 1 in op solution 3 1 TRUE Solutions Obtained with IgnoreAnalyticConstraints If you verify solutions of an equation or a system solved with the IgnoreAnalyticConstraints option testeq can return FALSE or UNKNOWN for example 3 99 3 Mathematics 3 60 equation ln x ln x 10 l1n y solutions solve equation x IgnoreAnalyticConstraints testeq subs equation x solutions 1 testeq subs equation x solutions 2 FALSE When you solve an equation inequality or a system using the IgnoreAnalyticConstraints option the solver uses an additional set of simplified mathematical rules These rules intentionally trade off mathematical strictness and correctness for simplicity of the results Although this option often leads to the most practical and expected results it also can lead to incorrect results For the set of rules IgnoreAnalyticConstraints applies see the help page of the solve command To verify such solutions try using the same IgnoreAnalyticConstraints option for testeq When you use this option the testeq command does not guarantee that the solutions are correct everywhere on the complex plane The command checks that the solutions are correct for the values of the parameters for which the rules applied by IgnoreAnalyticConstraints are valid testeq subs equation x solutions 1
390. ions O ode y X x y x 2 x y x x y x L solve o Type Chini T i 3 2 sca _y_v3i _1 vV3i v3 tan 3 1 9 2 7 3 2 2 Specifying the type of the same ordinary differential equation as Riccati gives you two separate solutions M solve o Type Riccati _Vv3i p 1 93i t a i ba 3 69 3 Mathematics When you specify the equation type as Riccati the solver returns a more general result This result combines the second and third elements of the set returned for the Chini type The additional solution for the Chini equation appears at a particular value of the integration constant for the Riccati equation Find the value of the constant at which the more general solution for the Riccati equation turns to the second solution for the Chini equation solve L 2 M 2 C5 vite c e Use evalAt to verify that if the integration constant is 0 the solution for Riccati equation gives the additional solution that you see for Chini type evalAt M 2 C5 0 v3 1 tna H You can find the dependency between the constants in the solutions returned for Riccati and Chini types As a first step rewrite the results using similar terms For example rewrite the expression with exponents in terms of tangents m2 rewrite M 2 tan Define the constant C5 in terms of C4 C5 simplify solve L 3 m2 C5 IgnoreSpecialCases _ vs SnC 3 C4 cos VF C4 i
391. ipK are now function environments you can call them as you would call any other MuPAD function ellipE O ellipE 1 2 ellipK 12 17 ellipK x 2 1 ZORO The third argument funcenv is a table of function attributes It tells the system functions such as float diff expand and so on how to handle symbolic calls of the form ellipE x andellipK x You can update this table specifying the rules for the new function For example specify the new differentiation rules by assigning the appropriate procedures to the diff slot of the function environments ellipE diff proc f x local Z begin zZz op f ellipE z ellipK z 2 z diff z x 9 179 5 Programming Fundamentals 5 180 end_proc ellipK diff proc f x local z doa f Z 1 z ellipK z z diff z x op elipti 24 1 Z end proc Now whenever f ellipE z and z depends on x the call diff f X uses the procedure assigned to eLlipE diff diff ellipE z z diff ellipE y x x diff ellipE x sin x x E z K z Jz E v x K y x amp yi EA YU AJ gz JA 2 y x ww oy B gy E x sm x K x sm x sin x x cos x 2 x sin x The new differentiation routine also finds higher order derivatives diff ellipE x x x E x E x A Elx E x x 1 21I 2x x 1 E x K x 2x Ix Since the taylor function internally calls diff the new differentiation routine also lets
392. irectly if you know that a particular problem cannot be solved symbolically This technique has a significant disadvantage for nonpolynomial equations numeric solvers return only the first solution that they find Try using options Many MuPAD functions accept options that let the system reduce computation efforts For information about the options of a particular MuPAD function see the Options section of the function help page Limit complexity of the expressions that you use Use shorter data structures when possible For example converting a sequence with 10 entries to a list takes longer than converting 1000 sequences with 1000 entries each Avoid creating large symbolic matrices and dense matrices when possible For details about improving performance when working with matrices see Using Sparse and Dense Matrices 9 109 5 Programming Fundamentals 9 110 Avoid using for loops to create a sequence a flat list a string and similar data structures by appending new entries Instead use the sequence generator Use for loops as outer loops when creating deep nested structures Use the sequence generator for inner loops Use the remember mechanism 1f you call a procedure with the same arguments more than once The remember mechanism lets you avoid unnecessary reevaluations See Remember Mechanism At the same time avoid using the remember mechanism for nonrecurring procedure calls especially if the arguments are nume
393. iscussed in the next section we need to know the structure of a MuPAD plot as a graphical tree The root is the canvas this is the drawing area into which all parts of the plot are rendered The type of the canvas object is plot Canvas Its physical size may be specified via the attributes Width and Height Inside the canvas one or more graphical scenes can be displayed All of them must be of the same dimension 1 e objects of type plot Scene2d or plot Scenesd respectively The following command displays four different 3D scenes We set the BorderWidth for all objects of type plot Scene3d to some positive value so that the drawing areas of the scenes become visible more clearly plot plot Canvas plot Scene3d plot Sphere 1 0 0 0 Color RGB Red BackgroundStyle LeftRight plot Scene3d plot Box 1 1 1 1 1 1 Color RGB Green BackgroundStyle TopBottom plot Scene3d plot Cone 1 0 O 0 0 O 1 Color RGB Blue BackgroundStyle Pyramid plot Scene3d plot Cone 1 0 O 1 0 O 0 Color RGB Orange BackgroundStyle Flat BackgroundColor RGB Grey Width 80 unit mm Height 80 unit mm Axes None BorderWidth 0 5 unit mn plot Scene3d BorderWidth 0 5 unit mm 6 93 6 Graphics and Animations 6 94 See section Layout of Canvas and Scenes for details on how the layout of a canvas containing several scenes is set Coordinate s
394. isors and Number of Divisors on page 3 315 Compute Greatest Common Divisors on page 3 316 Compute Least Common Multiples on page 3 317 Compute Divisors and Number of Divisors Studying divisibility of integers by other integers is a common task 1n number theory The MuPAD numlib library contains the functions that support this task These functions return all divisors the sum of all divisors the number of divisors and the number of prime divisors For example to find all positive integer divisors of an integer number use the numlib divisors function numlib divisors 12345 1 3 5 15 823 2469 4115 12345 To find only prime divisors of an integer use the numlib primedivisors function numlib primedivisors 12345 3 5 823 To compute the number of all divisors of an integer use the numlib numdivisors function To compute the number of prime divisors use the numlib numprimedivisors function For example the number 123456789987654321 has 192 divisors Only seven of these divisors are prime numbers numlib numdivisors 123456789987654321 numlib numprimedivisors 123456789987654321 3 315 3 Mathematics 3 316 192 7 The numlib numprimedivisors function does not take into account multiplicities of prime divisors This function counts a prime divisor with multiplicity as one prime divisor To compute the sum of multiplicities of prime divisors use the numlib Omega function For example t
395. istabsatilegisticRandom distribution Lognormal stats Lognormat Ds Lognormata ads LognormatatantidgnormalRandom distribution Normal stats normalPSHEats normalCitats normalQsm ats LenormalRandom distribution Name Student s t distribution Uniform distribution Weibull distribution Supported Distributions PDF stats stats stats CDF gt tPDF Stats uniformeD amp ts Wweibull D amp ts Random Generator stats tQuantidtats tRandom Quantile StCDF uniform amp D amp ts uniformSuansi iiweniformRandom Wweibull D amp ts weibull SuatbsiiiweibullRandom The following discrete distributions are available in MuPAD Name Binomial distribution Empirical distribution Distribution of a Finite Sample Space Geometric Distribution Hypergeometric Distribution Poisson Distribution PF stats stats stats stats stats stats CDF binomiadP ts empiricst sts finiteP tats geometrst ts poisson tats Random Generator binomiasdtS9Es binomiastOaresiildenomialRandom Quantile empiricst D empiricstiguantanjinricalRandom finiteCHtats finiteQseats lef initeRandom geometrst D geometrscatsanigdenetricRandom hypergestnetts oPypergestets icbybernrgestets 1i cyraergdenet rich poisson D ts poissonStuabnsiiilpoissonRandom 3 261 3 Mathematics Import Data 3 262 Note Use only in
396. itions The while loop continues while the execution conditions are valid The loop starts with while and ends with end_while 4 10 Loops or just end MuPAD executes all the statements between these commands repeatedly as long as the execution conditions are true In the while loop MuPAD evaluates the conditions before each iteration When the condition becomes false the loop terminates without executing the statements of the current iteration i 23 while i lt 16 do i i 2 print i end while a 16 Termination Condition at the End repeat Loops The repeat loop continues until the termination condition becomes valid The loop starts with repeat and ends with end repeat MuPAD executes all the statements between these commands repeatedly while the conditions are false The repeat loop tests a termination condition at the end of each iteration When the condition becomes true the loop terminates after executing the statements of the current iteration i is 2 repeat i 1 23 print i until i 16 end repeat 4 11 4 Programming Basics Avoid Infinite Loops Set a Counter The while and repeat loops do not operate for a fixed number of steps If the execution or termination conditions of such loops never become true MuPAD can execute the statements within these loops infinitely For example if the termination condition is not valid during the first iteration and it does not change inside the loop the loo
397. ividing a list according to particular properties of its entries Arithmetical operations on lists To check if an object belongs to a list use the contains command The command returns the position of the first occurrence of the object in the list If the object does not belong to the list contains returns 0 list i E i 10 20 contains list 1 contains list 1 6 18 9 10 11 12 13 5 15 n us Lists If you use a list as the function in a function call MuPAD returns the list of appropriate function calls sin cos tan f x sin cos tan f 0 1 sin x cos x tan x f x 0 09983341665 0 9950041653 0 1003346721 f 0 1 To apply a function to all entries of a list use the function map map x map x 1 5 PI sin y Usl 0 1 1 5 PI 5 8 1 E sin x 0 09983341665 sin L o ja x 1 a 11 a a n To extract entries with particular properties from a list use the select command select i i 1 20 isprime 2 3 5 7 11 13 17 19 To divide a list into three lists according to particular properties use the split command split i i 1 10 isprime 5 Programming Fundamentals The resulting three lists contain Entries with the required properties Entries without the required properties Entries for which the required properties are unknown MuPAD supports the following arithmetical operations on li
398. ixSize i i 1 1000 end proc This algorithm is very inefficient for the specified task The function f performs 10 computation steps to find out that an integer does not occur in the matrix M Since you call the function f 1000 times executing this algorithm takes a long time time g 62435 902 In this example the bottleneck of the chosen approach 1s obviously the algorithm that accesses each matrix element To accelerate the computation rewrite the procedure f using the bisection method Before using this method convert the matrix M to a list and sort the list Then select the first and last elements of the sorted list as initial points Each step in this algorithm divides the list of elements at the midpoint f proc M n x begin if M 1 x M n x gt O then return FALSE elif M 1 x M n x O then return TRUE else a 1 b n while b a gt 1 do if is b a Type Odd then c a b a 1 2 else c a b a 2 end if if M c x O then return TRUE elif M a x M c x lt O then b C else a i C 5 97 5 Programming Fundamentals 9 98 end if end while end if return FALSE end proc Use the op function to access all elements of the matrix M This function returns a sequence of elements Use brackets to convert this sequence to a list Then use the sort function to sort the list 1n ascending order Finally call the procedure f for each intege
399. ize and avoid incorrect results When possible use symbolic computations Switch to floating point arithmetic only if you cannot obtain symbolic results See Use Symbolic Computations When Possible on page 3 235 Numeric computations are sensitive to the DIGITS environment variable that determines the numeric working precision Increase the precision of numeric computations and check if the result changes significantly See Increase Precision on page 3 235 Compute the value of a special function symbolically and then approximate the result numerically Also compute the value of a special function using the floating point parameters Significant difference 1n these two results indicates that one or both approximations are incorrect See Approximate Parameters and Approximate Results on page 3 237 Plot the function See Plot Special Functions on page 3 238 Floating Point Arguments and Function Sensitivity Use Symbolic Computations When Possible By default MuPAD performs computations in exact symbolic form For example standard mathematical constants have their own symbolic representations in MuPAD Using these representations you can keep the exact value of the constant throughout your computations You always can find a numeric approximation of a constant by using the float function pi float PI 3 141592654 Avoid unnecessary conversions to floating point numbers A floating point number approxima
400. k Interface This functionality does not run in MATLAB Typically when a MuPAD procedure encounters an error caused by evaluation of an object the procedure terminates the system returns to an interactive level and displays an error message If you want to avoid terminating a procedure use the traperror function to catch an error The traperror function returns the error number instead of the error itself Later you can reproduce the error by using the lasterror function This function produces the last error that occurred in the current MuPAD session If you call Lasterror inside a statement or a procedure it terminates that statement or procedure If you want to display the error message without throwing the error itself save the error number returned by traperror and then retrieve the message by using the getlasterror function For example the function f throws an error when sin n k is equal to zero f k gt 1 sin PI k k a s sini 7 Ac T 1 Error Division by zero invert Evaluating f Suppose you want to compute f for the values n k n increasing the value of k by in each step To call the function f for all required values create the for loop When you try to execute this statement it terminates as soon as the function f encounters division by zero for the first time To avoid terminating the for statement use the traperror function to catch the error To display the text of that error
401. k Interface This functionality does not run in MATLAB Although MuPAD does not let you declare a method as private you can create private methods by using closures MuPAD uses a fundamentally simple object and name lookup model Objects are data that belong to a particular domain type and domains have named entries called s ots If the value of a slot 1s a function this entry is called a method Therefore MuPAD lets you use the same techniques for hiding method calls as you use for hiding utility functions For details see Utility Functions 1n Closures This example creates the private method f of the domain d This method is not accessible from methods in inherited domains and from category methods domain d local f inherits Dom BaseDomain g proc begin print g f end begin f proc begin print f end 5 167 5 Programming Fundamentals T 9 168 Calls by Reference and Calls by Value Calls by Reference and Calls by Value Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Calls by Value When calling a procedure with some arguments you expect the procedure to assign these values for its local variables and perform some computations with those variables For example this procedure divides any number that you pass to it by 10 f x gt x 7 x 10 In this example x is a local variable of f When you call f with any value the procedure
402. king with Multiple Input Regions 1 5 Shortcut to Access Standard MuPAD Functions 1 7 Access Help for Particular Command 1 15 Autocomplete Commands eere 1 15 Use Tooltips and the Context Menu 1 16 Use Help Commands i24 d kb p da bad dk ae Rede Rm 1 18 Perform Computations 0 000000 eee eee 1 19 Compute with Numbers 0 0 0 0 0000 ce uee 1 19 Differentiation ou d wack ook x tome ede tate eek EDUC e RU d 1 23 EntesratiOH sioe d woe ue SER SS CE BER ORS ee SER ERGs 1 26 Linear Algebra 22426254 hes Dare Eth dhe he a 1 27 Solve BquatiolS 454a s vocc aeo Exe ee ee SES 1 31 Manipulate Expressions eee 1 33 Use Assumptions in Your Computations 1 36 Use Graplies orere der dono dots et be Go GI debe Be ws ah 1 39 Graphic Options Available in MuPAD 1 39 Basic PIOCCIBBE iw rack ER TCR SCR ADAC EROR ROC enn 1 40 Bt OM TMA OCS mud aco xe eels oe egos Madea Hats ow Ieee aa 1 49 Present Gray ais irse xd de e Ree dota aha an Pee Ae ado eer 1 56 Create Animated Graphics 0 0000000 0a 1 59 Use the MuPAD Libraries 0 1 62 Overview of Libraries 0000000 cee eee eee 1 62 PbaAndard DEAE 3 56 udine d Bae Sees Ge ae ew Coed 1 63 iii lv Contents 2 Find Information About a Library ls 1 64 Avoid Name Conflicts Between M
403. knowns linsolve x y a 3 x 2 y b x y a b x 5 n Cei 20 a Del Providing the unknowns in different order affects the solution linsolve x y a 3 x 2 y b a b x yl L oo a x y b 3x 2y Linear Systems in a Matrix Form To state the problem of solving the system of linear equations 1n a matrix form use the following steps 1 Create a matrix A containing the coefficients of the terms of linear equations Each equation contributes to a row in A Create a column vector 5 containing the right sides of the equations gt The matrix form of the linear system is 4 X b When solving a system in a matrix form you provide a matrix A and a vector 5 The solver returns the solutions of the En system as a vector x The dimensions mxn of the coefficient matrix define the following types of linear systems m n Square system m gt n Owverdetermined system If the determinant of A is not a zero a unique solution of the system exists Otherwise the system has either infinitely many solutions or no solutions The system includes more equations than variables The system can have one solution infinitely many solutions or no solutions 3 99 3 Mathematics 3 36 m n Underdetermined The system includes more variables than equations system The system has either infinitely many solutions or no solutions To solve a linear system in a matrix for
404. l Therefore reject the hypothesis that the entries of this sequence are normally distributed stats swGOFT x stats swGOFT y P Value 0 4388845871 StatValue 0 9983128403 PValue 0 0000000004748026729 StatValue 0 9812478768 3 313 3 Mathematics Perform t Test 3 314 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The t Test compares the actual mean value of a data sample with the specified value m The null hypothesis for this test states that the actual mean value 1s larger than m For the t Test MuPAD provides the stats tTest function For example create the normally distributed data sequence of 1000 entries by using the stats normalRandom function ats normalRandom 1 2 7 3 t X f k 1 1000 S Now use the stats tTest function to test whether the actual mean value of X is larger than 1 Use the significance level 0 05 The returned p value indicates the hypothesis passes the t Test since the p value exceeds the significance level stats tTest x 1 PValue 0 1353274218 StatValue 1 102166281 With the same significance level 0 05 the hypothesis that the actual mean value is larger than 2 does not pass the t Test stats tTest x 2 PValue 6 722832021 10775 StatValue 23 50521869 Divisors Divisors Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Compute Div
405. l Math Plot Commands Mem 12 MB Ts Outp In the Graphics Size dialog box set the height and width of the graphics The option Keep Aspect Ratio lets you conserve the height to width ratio 2 116 Scale Graphics Width Height 80 01 Keep Aspect Ratio 2 117 2 Notebook Interface Use Print Preview 2 118 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB View Documents Before Printing on page 2 118 Print Documents from Print Preview on page 2 118 Save Documents to PDF Format on page 2 119 Get More Out of Print Preview on page 2 120 View Documents Before Printing Before printing a notebook that displays long lines 1n the input or output regions or wide graphics that might not fit the page use the Print Preview window to see how the document will look when printed The dialog box lets you view and fix page layout problems print your document or save it to PDF format Previewing documents before you print them helps to avoid printing unnecessary pages and thereby reduces paper waste To see how the document looks when printed select File gt Print Preview Alternatively press Alt tF V to open Print Preview Print Preview uses the properties of your current printer If you print the document using any other printer or save it to PDF format the result can differ from what you see in the Print Preview windo
406. l terms In each rational term the degree of the numerator 1s smaller than the degree of the denominator For some expressions partfrac returns visibly simpler forms for example partfrac x 6 15 x 5 94 x 4 316 x 3 599 x 2 602 x 247 x 6 14 x 5 80 x 4 238 x 8 887 x 2 324 x 108 x The denominators in rational terms represent the factored common denominator of the original expression factor x 6 14 x 5 80 x 4 238 x 3 387 x 2 324 x 108 F 5 F Z fa 5 3 x lix 2r x 3 Simplify Radicals in Arithmetic Expressions As an alternative to the general simplifiers simplify and Simplify use the radsimp function to simplify arithmetic expressions involving square roots or other radicals For example simplify the following numeric expression f 3 sqrt 7 sqrt 7 2 radsimp f C 4 a 3 99 3 Mathematics Extract Real and Imaginary Parts of Complex Expressions When working with complex numbers you might need to separate the real and imaginary part of a symbolic expression To extract the real and imaginary part of a complex number you use the Re and Im functions For symbolic expressions these functions return Re tan x Im tan x R tan x Ss tan x Use the rectform function to split a symbolic expression into its real and 1maginary parts y rectform tan x mh 2 5x L i oof cosh 2 S x cos 2 WH x cosh 2 S x cos 2 R x sin 2 8
407. l variables affect the results of a procedure See Clearing Remember Tables Many predefined MuPAD functions have special values stored in their remember tables Therefore clearing the remember tables of predefined MuPAD functions 1s not recommended Note that the forget function does not error when you call it for a predefined MuPAD function History Mechanism History Mechanism Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Access the History Table on page 5 123 Specify Maximum Number of Entries on page 5 126 Clear the History Table on page 5 127 Access the History Table MuPAD implements the internal history mechanism The history mechanism lets you access a limited number of previously computed results with or without the commands that generated the results The history mechanism also helps you reduce the number of additional identifiers commonly used for storing the results of intermediate computations Instead of assigning results of such computations to auxiliary identifiers you can access the entries of the history table and get the previously computed result To access the entries of the history table use the last and history functions The last function returns previously computed results without the command that generated the results The history function returns the previously computed results along with the commands that generated those results For the last fu
408. les 4 25 4 Programming Basics Functions 4 26 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Call Existing Functions on page 4 26 Create Functions on page 4 26 Evaluate Expressions While Creating Functions on page 4 27 Use Functions with Parameters on page 4 28 Call Existing Functions If you want to execute the same code repeatedly create a procedure and use it As a shortcut for simple procedures create and use functions Compared to procedures functions require less complicated syntax Like procedures functions let you use the same code for different arguments as many times as you need For example you can always calculate sine and cosine of a particular value sin 0 5 sin 30 0 sin 1 0 8 cos 3 0 1 cos 10 0 cos O 0 9880310741 0 8414709848 0 4794255386 0 8390715291 0 6967067093 0 9899924966 Create Functions To define your own functions in MuPAD use the arrow operator f x gt x 2 2 X X Functions After defining a function call it in the same way you call system functions f 1 f x f sin x L x sin x The arrow operator also can create a multivariate function g i X y gt x 2 y 3 E z 3 x y X y Call the multivariate function with numeric or symbolic parameters g 5 2 g x 2 x g a b 33 5 x x ai 5b Evaluate Expressions While Creating Functio
409. les Radius 0 3 3 291 3 Mathematics 3 292 5 08 2 57 I 0 08 2 45 7 59 5 08 infinity 7 59 12 49 15 0 12 49 Create Box Plots Create Box Plots Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Box plots reduce data samples to a number of descriptive parameters Box plots are very useful for a quick overview and comparison of discrete data samples To create a box plot use the plot Boxplot function For example create a box plot for the data samples data1 and data2 that contain random floating point numbers from the interval 0 0 1 0 and the value 2 the outlier data1 frandom i 1 10 datali append datai 2 data2 frandom i 1 10 data2 append data2 2 p plot Boxplot datal data2 plot p 0 2505346935 0 7671696761 0 3879781556 0 6800823524 0 09165554125 0 6105917364 0 6165219703 0 08539849696 0 8255921764 0 1102019865 2 0 9646295764 0 9636463557 06686584004 0 07436099118 0 4239603781 0 3171767607 0 1045730269 0 004271391317 0 04522333971 08062151715 2 3 293 3 Mathematics Y 50 E 1 6 1 6 1 4 1 2 1 0 wy a ZZ y 7 1 4 B 22 2d x g z This plot demonstrate the following features The tops and bottoms of each box are the 25th and 75th percentiles of the data samples respectively The distances between the tops and bottoms are the interquartile ranges The
410. line in the middle of each box is the sample median A median is not always in the center of the box The median shows the sample obliquity skewness of the sample distribution The lines extending above and below each box are the whiskers Whiskers extend from the ends of the interquartile ranges to the furthest observations within the maximum whisker length The maximum whisker length is 3 2 of the height of the central box measured from the top or bottom of the box The data points that lay beyond the whisker lengths are the outliers Outliers are values that are more than 3 2 times the interquartile range away from the top or bottom of the box The Notched option enables you to create a box plot with notches Notches display the variability of the median between samples p plot Boxplot data data2 Notched TRUE 3 294 7 ullo dil 3 Mathematics Create Quantile Quantile Plots 3 296 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Quantile quantile plots help you determine whether two samples come from the same distribution family Quantile quantile plots are scatter plots of quantiles computed from each sample together with a reference line along the diagonal of the plot If the data forms the line it is reasonable to assume that the two samples come from the same distribution family If the data falls near the reference line you also can assume that the two samples have the
411. lines First we define the data sample consisting of a list of points xi yi xo ye Suppose they are equidistant sample points from the graph of the function f x 2 sin 5 x g f x gt x exp x sin 5 x data i 3 f i 3 i 0 9 We use numeric cubicSpline to define the cubic spline interpolant through these data S numeric cubicSpline op data The plot shall consist of the function f x that provides the data of the sample points and of the spline interpolant S x The graphs of f x and S x are generated via plot Functiona2d The data points are plotted as a plot PointList2d plot plot Function2d f x x 0 3 Color RGB Red LegendText expr2text f x plot PointList2d data Color RGB Black plot Function2d S x x 0 3 Color RGB Blue LegendText spline interpolant GridVisible TRUE SubgridVisible TRUE LegendVisible TRUE Advanced Plotting Principles and First Examples 0 3 0 2 0 1 0 0 012 4 2628 30 1 X 0 2 0 3 Wn x sin 5 x exp x aW spline interpolant Example 2 A cycloid is the curve that you get when following a point fixed to a wheel rolling along a straight line We visualize this construction by an animation in which we use the x coordinate of the hub as the animation parameter The wheel is realized as a circle There are 3 points fixed to the wheel a green point on the rim a red point inside the wh
412. list of all scene attributes Note that there are camera objects of type plot Camera that can be placed in a 3D scene These camera objects can be animated and allow to realize a flight through a 3D scene See section Cameras in 8D for details None of the attributes of 2D coordinate systems and 3D coordinate systems can be animated This includes viewing boxes axes axes ticks and grid lines rulings in the background See the help pages of plot CoordinateSystem2d and plot CoordinateSystem3d for a complete list of all attributes for coordinate systems Although the ViewingBox attribute of a coordinate system cannot be animated the user can still achieve animated visibility effects in 3D by clipping box objects of type plot ClippingBox None of the attributes that are declared as Attribute Type inherited on their help page can be animated This includes size specifications such as PointSize LineWidth etc RGB and RGBa values cannot be animated However it is possible to animate the coloring of lines and surfaces via user defined procedures See the help pages LineColorFunction and FillColorFunction for details The texts of annotations such as Footer Header Title legend entries etc cannot be animated The position of titles however can be animated There are special text objects plot Text2d and plot Text3d that allow to animate the text as well as their position Fonts cannot be animated
413. lve To find numerical approximations of other solutions specify intervals that contain the solutions You can use the command numeric solve that internally calls numeric fsolve However to speed up your calculations call numeric fsolve Solve Equations Numerically directly Note that numeric Solve returns a set of solutions and numeric fsolve returns a list numeric solve sin x y 2 1 cos x y X 2 5 3 5 y 1 5 0 5 numeric fsolve sin x y 2 1 cos x y X 4 5 y 0 2 0 2 x 3 141592653 y 1 0 x 4 71238898 y 0 0000000003741742246 The MultiSolutions option also serves to find more than one numeric approximation Without this option the numeric solver looks for a solution inside the specified interval and disregards any solutions it finds outside of the interval When the solver finds the first solution inside the interval it stops and does not look for other solutions If you use MultiSolutions the solver returns the solutions found outside of a specified interval Note If you use the option MultiSolutions and do not specify any interval the numeric solver returns only the first solution it finds With the MultiSolutions option the solver also stops after it finds the first solution inside the specified interval For example find several numeric approximations for the following system eqs x sin 10 x y 3 y 2 exp 2 x 3 plot x sin 10 x y
414. lve commands also handle these types of equations and systems except systems presented in a matrix form Define ordinary differential equations with the ode command before calling the general solver Equation Type Symbolic Solvers General system of linear equations linsolve numeric linsolve General system of linear equations given in linalg matlinsolnumeric matlinsgalve a matrix form 4 x 5 System of linear equations given in linalg vandermo 7 a matrix form 4 x b where Aisa Vandermonde matrix For example 3 290 3 Mathematics E Symbolic Solvers Numeric Solvers l e 7 7 df See linalg vandermonde for the definition and details System of linear equations given in a matrix form L LY x The lower triangular matrix L and the upper triangular matrix U form an LU decomposition System of linear equations given ina t toeplitzS matrix form 4 X b where Ais a Toeplitz matrix For example E a L M7 07 j See linalg toeplitz for the definition and details 3 26 Choose a Solver Equation Type Symbolic Solvers Univariate polynomial equation Call these polylib realrootinumeric polyroots functions to isolate the intervals containing numeric realroots real roots Bivariate polynomial equation for which series the general solver returns RootOf Try calling solve with the option MaxDegree If the option does not help to get an explicit solution compute the serie
415. ly in the MuPAD Notebook Interface This functionality does not run in MATLAB The discrete Fourier transform DFT is an equivalent of the Fourier transform for discrete data The one dimensional discrete Fourier transform of N data elements L L4 Ly is defined as the list F F Fy such that j Le 2ig 1 6 N p_y oN The inverse discrete Fourier transform is defined as the list L of the following elements N PIT 7 1 k 1 N j N m k l MuPAD uses a fast Fourier transform FFT algorithm to compute the discrete and the inverse discrete Fourier transforms For any N the computing costs are O N logs N To compute the discrete Fourier transforms use the following functions numeric fft to compute the Fourier transform numeric invfft to compute the inverse Fourier transform These functions accept lists domain type DOM LIST arrays domain type DOM ARRAY hardware floating point arrays domain type DOM HFARRAY and matrices category Cat Matrix The accepted data structures except for lists can be one or multidimensional You can use arbitrary arithmetical expressions as entries The discrete Fourier transform is often used in signal processing It allows you to decompose a signal into a set of periodic signals with different frequencies and to analyze those frequencies Suppose you have a discrete set of values of a signal sampled at a fixed rate The signal might be periodic b
416. m is used With 2 a embedded bitmap is created The default value is 0 nz Positive integer setting the frames per second for the avi to be generated Has an effect for avi export only The default value 1s 15 l List of real values between TimeBegin and TimeEnd which determines the times at which pictures should be saved from an animation Import Pictures Import Pictures Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB MuPAD does not provide for many tools to import standard graphical vector formats yet Presently the only supported vector type is the stl format popular in Stereo Lithography which encodes 3D surfaces It can be imported via the routine plot SurfaceSTL In contrast to graphical vector formats there are many standard bitmap formats such as bmp gif jpg ppm etc that can be imported One can read such a file via import readbitmap thus creating a MuPAD array of RGB color values that can be manipulated at will In particular 1t can be fed into the routine plot Raster which creates an object that can be used 1n any 2D MuPAD plot Note however that the 1mport of bitmap data consumes a lot of memory 1 e only reasonably small bitmaps up to a few hundred pixels in each direction should be processed In the following example we plot the probability density function and the cumulative density function of the standard normal Gaussian distribution Paying
417. m Footer C F Gauss FooterFont 8 Layout Relative Yao 0 9 0 8 0 7 0 6 6 180 Cameras in 3D Cameras in 3D Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The MuPAD 3D graphics model includes an observer at a specific position pointing a camera with a lens of a specific opening angle to some specific focal point The specific parameters position angle and focal point determine the picture that the camera will take When a 3D picture is created in MuPAD a camera with an appropriate default lens is positioned automatically Its focal point is chosen as the center of the graphical scene The interactive viewer allows to rotate the scene which in fact is implemented internally as a change of the camera position Also interactive zooming in and zooming out 1s realized by moving the camera closer to or farther away from the scene Apart from interactive camera motions the perspective of a 3D picture can also be set in the calls generating the plot One way is to specify the direction from which the camera is pointing towards the scene This is done via the attribute CameraDirection plot plot Function3d sin X y 3 X 1 1 y 1 1 CameraDirection 25 20 30 6 181 6 Graphics and Animations plot plot Function3d sin x y 3 x 1 1 y 1 1 CameraDirection 10 40 10 6 182 Cameras in 3D Is Is U4
418. m use the linalg matlinsolve command For example solve the following system of linear equations eqni 2 x O y 4 eqn2 3 x 2 y 1 To convert the system to a matrix form use the matrix command to create a matrix of coefficients and a vector containing right sides of equations A b matrix 2 3 3 21133 matrix 4 1 233 3 22 1 As a shortcut for converting a system of linear equations to a matrix form use linalg expr2Matrix Ab linalg expr2Matrix eqn eqn2 x y f2 3 4 3 217 Now use linalg matlinsolve to solve the system linalg matlinsolve Ab p zd zl 3 10 13 i Solve Algebraic Systems Alternatively split the matrix Ab into a matrix of coefficients A and a vector b containing the right sides of equations Use linalg matlinsolve to solve the system A Ab 1 2 1 2 b f Ab 1 2 3 3 linalg matlinsolve A b u 3 13 If your linear system is originally defined by a matrix equation using the matrix form to solve the system is more intuitive Also the matrix form is convenient for solving equations with many variables because it avoids creating symbols for these variables For example the following matrices define a linear system A linalg hilbert 10 b matrix i 2 i 1 10 1211 11 1 1 1 1 1 2 3 4 5 6 7 amp 9 IO 11 11 1 11 1 1 1 2 3 4 5 6 7 8 9 10 ll 111 11 11 11 1 3 4 5 6 7 amp 9 10 ll 1
419. m 2 To approximate an expression with exact values use the f loat command float 1 0 3 exp 1 sin 2 0 8239088907 or use floating point numbers as arguments 1 0 3 exp 1 0 sin 2 0 0 8239088907 You also can approximate the constants n and e DIGITS 30 float PI float E delete DIGITS 3 1415926535897937238406204338328 1 21 l Getting Started 1 22 2 71828182845904523536028747135 Work with Complex Numbers l l zu f In the input regions MuPAD recognizes an uppercase I as the 1maginary unit V In the output regions MuPAD uses a lowercase 1 to display the imaginary unit sqrt 1 I 2 L 1 Both real and imaginary parts of a complex number can contain integers rationals and floating point numbers 1 0 2 1 1 2 I 0 1 I 2 3 0 0988 0 1144 i If you use exact expressions for example 2 MuPAD does not always return the result in Cartesian coordinates 1 sqrt 2 I l v2 T i To split the result into its real and imaginary parts use the rectform command rectform 1 sqrt 2 I od 3 3 The functions Re and Im return real and imaginary parts of a complex number Re 1 2 1 2 I 3 Perform Computations Im 1 2 1 2 I L 3 The function conjugate returns the complex conjugate conjugate 1 2 1 2 I l The function abs and arg return an absolute value and a polar angle of a complex number abs 1 2 1 2 I arg 1 2 1 2
420. m3d 7 Function3d Property b Points 4 Surface Fil iGreen H 0 5 Fi FillCol Im 7 00 FillCol Opacity 1 00 FillCol aT FillCo a FillCal Shading Smooth TitleFont Arial li pt color of areas and surfaces Mot Connected Outp A INS Present Graphics When you present graphic results in MuPAD you can move zoom and rotate your graphics You also can select different components of a plot When presenting graphic results switch to the plot formatting mode You can use the following toolbar to manually rotate move zoom your plot and show coordinates of any point on your plot 1 56 Use Graphics rotate Zoom i en ee A ete select move show graphics coordinates component To see the coordinates for a point on your plot click the point and hold the mouse button You can move the cursor while holding the mouse button and see the coordinates of all the points on the path of the cursor 1 57 l Getting Started File Edt View Insert Tools Actions Window Help e e ee NP BOOR kaSe RARA plot x 2 y 2 x 2 2 pee 4 i CoordinateSystem3d w Function3d E 1 4642 0 59186 2 5058 Press space bar to add the current query to the coordinate list Mem 6 MB TU s Outp You can use the toolbar to rotate and zoom your plot automatically You also can change the speed for rotation and zooming leo o ag 1 58 Use Graphics Create Animated Graphics
421. main constructor of the domain to which you want to convert an object This approach typically works but 1t can fail in some cases Calling the conversion methods of a domain directly To use this approach you must know which conversion methods are implemented for the participating domains This alternative is not recommended Use the coerce or expr function instead Convert Data Types Note If you implement a new domain consider implementing the conversion methods for that domain Use the coerce Function To convert a MuPAD object to an element of a specified domain use the coerce function For example convert the following element of the domain DOM LIST to an element of the domain DOM_SET L 4 o 1 1 2 3 4 5 6 coerce L DOM SET domtype L domtype S DOM LIST DOM SET Results of the conversion can depend on the original domain type For example create an array and a matrix with the same number of elements and equal dimensions M A matrix 2 3 1 2 3 4 5 6 array 1 2 1 3 1 2 3 4 5 6 1 45 45 Verify that matrix M belongs to the domain Dom Matrix and array A belongs to the domain DOM_ARRAY Li ba a Lay pa domtype M domtype A 9 43 5 Programming Fundamentals 9 44 Dom Matrix DOM ARRAY Use the coerce function to convert both objects to elements of the domain DOM LIST The coerce function converts matrix M to a nested list where the inner lists rep
422. mation about the test execution For example if your test compares two different complex numbers prog test returns the following message pPog test T 2 I I I Error in test 2 Input f 2 I I Expected I Got TrapError 1003 message symbolic kernel NotBoolean Near line 1 If the error is expected you can rewrite the test using the TrapError option Write Single Tests prog test f 2 I I TrapError 1003 When you call prog test MuPAD evaluates actual and expected results before comparing them progistest iT x 2 X 92 5 2 2 Error in test 4 Input T x 2 X 2 5 Expected 4 Got 5 Near line 1 Evaluation of actual and expected results can take a long time To avoid long evaluations the prog test function lets you specify the time limit for evaluation of the test To limit the evaluation time for a particular test use the Timeout option of the prog test function For example set the time limit to 2 seconds prog test f i i 1 1000000 i i 1 1000000 i i 1 1000000 Timeout 2 Error in test interactive 5 Input f i i 1 100000 i i 1 100001 Expected FAIL Got TrapError 1320 Error Execution time exceeded Timeout 2 0 5 106 prog ntime In this example the time limit measurement depends on your hardware configuration The test report also shows the hardware independent time in terms of the prog ntime function
423. mations DIGITS 45 float B besselJ 53 2 float PI 6 90014560772087465957327665452188601038351877 10 6 9001456069172794165785003948591349704494668 10 delete DIGITS Now you can see that using the floating point parameter to compute the Bessel function produces the correct result within working precision Approximation of the exact symbolic expression for that Bessel function returns the wrong result because of numerical instability Plot Special Functions Plotting the function can help you recognize incorrect floating point approximations For example the numeric approximation of the following Bessel function returns B besselJ 53 2 PI float B Plot the function J x for the values of x around 53 2 The function plot shows that the floating point approximation is incorrect plot besselJu x PI x 26 27 Floating Point Arguments and Function Sensitivity Y 40 0 8 0 8 0 4 02 0 0 26 1 262 2763 754 2755 2766 257 768 759 270 0 2 u X 0 4 0 6 0 8 1 0 Sometimes to see that the floating point approximation is incorrect you must zoom the particular parts of the function plot For example the numeric solver finds the unexpected zero of the Zeta function numeric solve zeta 1000000001 2000000000 I y y 14 15 14 13472514 To investigate whether the Zeta function actually has a zero at that point or whether the result appears because of the roundoff error plot the absol
424. me solve a x 2 b x f b yb 4ac _ b 4 Line Break la File Path if a204520 Ctrl Ctrl Shift I Ctrl T Ctrl Shift T Here a b and c are eters in addition to Tables Ctrl Enter if a O0Ab 0ac 0 if a204b5b20 cse0 Insert table at the current cursor position Mem 8 MB TOs Use Tables J Inthe resulting dialog box select the number of columns and rows and click OK Number of rows I 2 39 2 Notebook Interface Add and Delete Rows and Columns To add a row or column to an existing table or delete an existing row or column 1 Click a cell where you want to add or delete a row or column 2 Select Edit gt Table from the main menu and select the required action Ctrl Z I Q TU dL Y i o le Generic Sans Serif Ctrl a Command Bar Cut Ctrl X hm f ax f roar dnl Copy Ctrl C Paste Ctrl V f x fof Mf Paste As fx f of fr f ee Select Contents FF xc ab Select Region Shift F7 x f x Select All Ctrl A Ix if cy Delete Output LOADS 0 Delete All Outputs Onab O0ac 0 Find and Replace Ctrl F Find Again F3 amp b 2 cs Link General Math Link Target Plat Commands Table Insert Row Coordinate List incest coul Complete Word Ctrl Space Delete Row Toggle Greek Ctrl iG Delete Column Insert a row into the table at the current cursor position Mem 8 MB TOs If you inserted a row 1t appears above the row with the select
425. member table of the procedure f and returns that result To display the content of the remember table call the wrapper procedure f with the Remember option as a first argument and the Print option as a second argument The value 10 in the second column is the value of MAXEFFORT used during computations f Remember Print f 0 0 2 1000000 0 Lf 10 0 0 1000000 0 LF 10 0 1 1000000 0 To force reevaluation of the procedure calls of f clear the remember table of that procedure To clear the remember table call f with the Remember option as a first argument and the Clear option as a second argument f Remember Clear Now f returns the correct result f 0 If you use the option remember you also can clear the remember table and force reevaluation For example rewrite the procedure f as follows Remember Mechanism f proc x option remember begin heaviside x end f 0 Now restore the heaviside function to its default definition heaviside 0 1 2 To clear a remember table created by the option remember use the forget function forget f f 0 ba Use the protect function with the ProtectLevelError option to prevent further changes to heaviside Also delete the procedure f protect heaviside ProtectLevelError delete f Potential Problems Related to the Remember Mechanism The remember mechanism is a powerful tool for improving performance of MuPAD procedures N
426. ments on page 5 22 Create Sets Sets represent unordered mathematical structures Sets can contain arbitrary MuPAD objects For example numbers symbols strings or functions can be elements of a set To create a set separate MuPAD objects with commas and enclose the structure in braces seti ia Ja b C d 180 15 f 15 3 180 a b c d Also you can create a sequence and convert it to a set To convert a sequence to a set enclose the sequence in braces As a shortcut for creating a sequence use the sequence generator or its functional form _seqgen Enclose the sequence in braces it i 1 i 1 10 be 10 2 6 12 20 30 42 56 72 90 The order of the elements in a set does not depend on the order in which you insert them If an order of elements is important use a list instead of a set ay 3 Dy c d 180 15 a 3 5 c d 180 15 Sets MuPAD does not necessarily sort the elements of a set alphabetically set2 cos tan sin itan sin cos A set cannot contain duplicate elements When creating a set MuPAD automatically removes duplicates set3 2 6 7 a 6 2 2 a b 12 6 7 a b A set can be empty empty set a Access Set Elements The position of an element of a set in an output region can differ from the internal position of the element in a set To access an element in a set by its internal position use the op command set2 c a b b c
427. ments to these local variables Parameters outside the procedure do not change For example assign a new value to a formal parameter inside the procedure h proc a begin a b print args end proc Assigning a new value to a formal parameter inside a procedure does not affect the parameter itself This assignment affects the result returned by args For example if you pass any argument to the procedure h that argument changes to a variable b inside the procedure h 100 The formal parameter a does not change its value outside the procedure 9 508 5 Programming Fundamentals a For further computations delete the procedures f g and h delete f g h 9 54 Test Arguments Test Arguments Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Check Types of Arguments on page 5 55 Check Arguments of Individual Procedures on page 5 57 Check Types of Arguments When writing a MuPAD procedure you can specify the type of arguments accepted by the procedure To define a procedure that accepts only particular types of arguments specify the expected types when defining the formal parameters of a procedure For example the formal parameter of the following procedure accepts only those arguments that belong to the domain DOM_INT f proc k DOM INT begin sin PI k 4 end proc Therefore only an integer number is a valid first argument for this procedure
428. message without interrupting execution of the for statement use getlasterror for k from 1 to 1 step 1 4 do Handle Errors err traperror f k if err 0O then print Unquoted k expr2text k f expr2text f k else print Unquoted k expr2text k getlasterror end if end for 1 1025 Error Division by zero invert Evaluating f 8 4 f 2 1 2 1 2 f 1 1 4 f 2 1 2 0 1025 Error Division by zero invert Evaluating f 1 4 f 2 1 2 1 2 f 3 4 f 2 1 2 1 1025 Error Division by zero _invert Evaluating f For errors created with the error function including your custom error messages traperror always returns the error code 1028 If an error message with the code 1028 is the last error message that occurred in a MuPAD session you can retrieve that error message by using lasterror or getlasterror For example create the procedure g that computes the factorial of any number less than 10 If you pass a number greater than 10 to this procedure the procedure reduces the number to 10 and then computes the factorial 9 93 5 Programming Fundamentals 9 94 g proc n Type PosInt local test begin test proc begin if n 10 then error The number must not exceed 10 end if end proc if traperror test n O then g n 1 else n end if end proc Call the procedure with the number 100 During run
429. meters p r b As a dynamic system for Y x y z we have to solve the ODE f t Y with the following vector field f proc t Y local x y zj begin 6 y z sys 6 187 6 Graphics and Animations 6 188 p y X x Z r x y x y b z end proc Consider the following parameters and the following initial condition YO p 10 r i 28 b i 1 YO 1 1 1 The routine plot Ode3d serves for generating a graphical 3D solution of a dynamic system It solves the ODE numerically and generates graphical data from the numerical mesh The plot data are specified by the user via generators procedures that map a solution point t Y to a point x y z in 3D The following generator GXyz produces a 3D phase plot of the solution The generator Gyz projects the solution curve to the y z plane with x 20 the generator GXZ projects the solution curve to the x z plane with y 20 the generator Gxy projects the solution curve to the x y plane with z 0 Gxyz t Y gt Y Gyz t Y gt 20 Y 2 Y 3 Gxz t Y gt Y 1 20 Y 3 Gxy t Y gt Y 1 Y 2 0 With these generators we create a 3D plot object consisting of the phase curve and its projections The following command calls the numerical solver numeric odesolve to produce the graphical data It takes about half a minute on a 1 GHz computer object plot Ode3d f i 10 i 1 500 YO Gxyz Style
430. metic By default remember tables contain only arguments and results of procedure calls They do not store context information For example create the function f that computes the reciprocal of a number Use prog remember to enable the remember mechanism for this function T x gt 1 0 x f prog remember f The default number of significant digits for floating point numbers 1s 10 Use the function f to compute the reciprocal of 3 The system displays the result with the 10 digits accuracy f 3 0 3333333333 Now increase the number of digits to 50 Then call the function f with the argument 3 again By default MuPAD does not realize that you increased the required accuracy The system accesses the remember table finds the entry that corresponds to the argument 3 and returns the result previously computed for that argument Since MuPAD must display the output with 50 digits the last digits in the displayed result are incorrect DIGITS 50 f 3 9 117 5 Programming Fundamentals 9 118 0 333333333333333333 442127540038654842646 7925310135 For further computations restore the default value of DIGITS and delete f delete DIGITS f Remember Results and Context Although by default the remember mechanism in MuPAD disregards all context information you can extend the prog remember function call and take into account the properties of arguments and current accuracy of floating point arithmetic For e
431. ming supports manipulating lists supports manipulating polynomials supports manipulating strings supports number theory operations provides algorithms for numeric mathematics supports manipulating and solving ordinary differential equations provides a set of standard orthogonal polynomials supports setting and restoring user preferences provides programming utilities for analyzing functions and tracing errors provides methods for statistical analysis supports checking types of MuPAD objects supports typesetting symbols Functions included in libraries are written 1n the MuPAD language The calling syntax for functions from all the libraries except for the standard library includes both the library name and the function name library function Standard Library The standard library presents the set of most frequently used functions including diff int simplify solve and other functions For example diff x 2 x 1 63 l Getting Started 1 64 2x Find Information About a Library You can get information about the libraries using the info and help commands The info command gives a list of functions of a particular library For example the numlib library presents a collection of functions for number theory operations info numlib Library numlib the package for elementary number theory Interface numlib Lambda numlib Omega numlib checkPrimalityCertificate numlib contfrac numlib contfra
432. mmand Bar select View gt Command Bar 1 7 l Getting Started The buttons on the Command Bar display the function labels To see the name of the function that the button presents hover your cursor over the button Command Bar i E r3 a A z nf f 4X Derivative Hat in rol i Hi f Ire a Ec ab a Y Y ath n x fix Y Y Y 2 a if ema p Ix ifc Y Y Y General Math Plot Commands To insert a function Point the cursor at the place in an input region where you want to insert a function Click the button corresponding to the function Insert the parameters instead of the symbols You can switch between the parameters by pressing the Tab key 1 8 Shortcut to Access Standard MuPAD Functions Jy Notebookl MuPAD File Edit View Wavigation Insert Format Notebook Window Help Ld A A ag Ld E C3 C TU 4L LJ 9 Generic Monospace Command Bar ditt iq x ME fax fof General Math w Plot Commands Mem 8 MB TOs Most of the buttons on the Command Bar include a drop down menu with a list of similar functions The buttons display a small triangle 1n the bottom right corner Click the button to open the list of functions l Getting Started General Math Plot Commands Using the Command Bar you also can create the following e Vectors and matrices 1 10 Shortcut to Access Standard MuPAD Functions File Edit View Navigation Insert Form
433. n for i from 1 to 3 do Xie y 3 1 4 16 Loops end for Display Intermediate Results By default MuPAD does not display intermediate results obtained inside a loop even if you use semicolons after commands To see intermediate results use the print command inside a loop 1 13 while i lt 3 do i i 14 1 print i end while To display results of each iteration in a for loop also use the print command for i from 1 to 5 do dian AT expr2text i expr2text x end for 1 1 pl 3 6 A 24 5 120 4 17 4 Programming Basics Procedures Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create a Procedure on page 4 18 Call a Procedure on page 4 18 Control Return Values on page 4 19 Return Multiple Results on page 4 20 Return Symbolic Calls on page 4 20 Use Global and Local Variables on page 4 21 Restore Values and Properties of Global Variables Modified in Procedures on page 4 23 Create a Procedure If you want to execute a piece of code repeatedly create and use a procedure Define a procedure with the proc command Enclose your code in the begin and end proc commands myProc proc n begin if n 1 or n 0 then 1 else n myProc n 1 end_if end proc Use end as a shortcut for end proc Call a Procedure Now call the procedure 4 18 Procedures myProc 5 120 Control Re
434. n 2 w _ e ta 2 1n 5 inf 2 5 In 2 simplify History Mechanism The Last function does not evaluate results The last function also returns the results for which you used colons to suppress the outputs hold 2 2 6 2 of a The history function displays both the result and the command that produced that result This function counts the entries of the history table from the first result obtained in the current MuPAD session Thus when you use the history function the most recent result is the last entry of the history table In this section the first entry of the history table is the computation of the factorial of 10 history 1 10 3628800 To find the current number of entries in the history table call the history function without an argument history 10 You can use the history function to access the most recent computation and its result a i 2 history history For the following statements the history mechanism depends on whether you call the statement interactively or within a procedure for repeat and while loops e if and case conditional statements procedure definitions 9 125 5 Programming Fundamentals 5 126 These statements are called compound statements At the interactive level MuPAD stores compound statements as one unit In procedures MuPAD stores the statements found within a compound statement in a separate history table of the procedure In this
435. n 2 x E Function 2 4 x 2 cos x Wm Function 3 sin 4 xVx Each graphical primitive accepts the attribute Legend Passing this attribute to an object triggers several actions The object attribute LegendText is set to the given string The object attribute LegendEntry is set to TRUE A hint is sent to the scene containing the object advising it to use the scene attribute LegendVisible TRUE The attributes LegendText and LegendEntry are visible in the object inspector of the interactive viewer see section Viewer Browser and Inspector Interactive Manipulation and can be manipulated interactively for each single primitive after selection 1n the object browser The attribute LegendVisible is associated with the scene object accessible via the object browser At most 20 entries can be displayed in a legend If more entries are specified 1n a plot command the surplus entries are ignored Further the legend may not cover more than 5096 of the height of the drawing area of a scene Only those legend entries fitting into this space are displayed remaining entries are ignored If the attribute LegendText TRUE is set for a primitive its legend entry is determined as follows Legends Ifthe attribute LegendText is specified its value is used for the legend text IfnoLegendText is specified but the Name attribute is set the name is used for the legend text fno Name attribute is specified either th
436. n a x 2 a y 2 x 2 2 y 2 2 a 2 0 1 3D 1 61 Getting Started Use the MuPAD Libraries 1 62 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Overview of Libraries on page 1 62 Standard Library on page 1 63 Find Information About a Library on page 1 64 Avoid Name Conflicts Between MuPAD Objects and Library Functions on page 1 65 Overview of Libraries Libraries contain most of the MuPAD functionality Each library includes a collection of functions for solving particular types of mathematical problems combinat supports combinatorics operations solvelib contains various methods used by the function solve export supports exporting MuPAD data to external formats output supports formatted output of the MuPAD data fp supports functional programming methods generate supports conversion of the MuPAD expressions to C FORTRAN MATLAB and TeX codes groebner supports operating on ideals of multivariate polynomial rings over a field import supports importing external data to MuPAD transform intlib linalg linopt listlib polylib stringlib numlib numeric ode orthpoly Pref prog stats Type Symbol Use the MuPAD Libraries supports integral transformations and the discrete Z transform supports manipulating and solving integrals supports linear algebra operations provides algorithms for linear and integer program
437. n is the square root of the variance and has the desirable property of being in the same units as the data For example if the data is in meters the standard deviation is also in meters Both the standard deviation and the variance are sensitive to outliers A data value that 1s separate from the body of the data can increase the value of the statistics by an arbitrarily large amount For example compute the variance and the standard deviation of the list x that contains one outlier L f 1 1 14 14 d Te Te l variance stats variance L stdev stats stdev L 100 0 Variance 1089 0 3 271 3 Mathematics 3 212 stdev 33 0 The mean deviation is also sensitive to outliers Nevertheless the large outlier in the list X affects the mean deviation less than it affects the variance and the standard deviation meandev stats meandev L meandev 19 55555556 Now compute the variance the standard deviation and the mean deviation of the list y that contains one small outlier Again the mean deviation is less sensitive to the outlier than the other two measures S 100 100 100 100 100 100 100 100 1 0 variance stats variance S stdev stats stdev S meandev stats meandev S Variance 1089 0 stdev 33 0 meandev 19 55555556 Compute Measures of Shape Compute Measures of Shape Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The mea
438. names available in the RGB library via info RGB Alternatively there is the command RGB ColorNames returning a complete list of names optionally filtered For example let us list all the colors whose names contain Red RGB ColorNames Red CadmumRedDeep CadmumRedLight CardinalRed CarmineRed DarkRed EnghshRed IndianRed OrangeRed PermanentRedViolet Red VenetianRed VioletRed VioletRedMedrmum MioletR edPale To get them displayed use RGB plotColorPalette red Colors containing red am 3 CarmineRed CardinalRed CadmiumRedLight Cadmi PermanentRedViolet OrangeRed IndianRed EnglishRed DarkRed VioletRedPale VioletRedlMMedium V ioletRed VenetianRed After loading the color library via use RGB you can use the color names in the short form Black White IndianRed etc In MuPAD the color of all graphic elements can either be specified by RGB or RGBa values RGBa color values consist of lists r g b a containing a fourth entry the opacity value a between 0 and 1 Fora 0 a surface patch painted with this RGBa color is fully transparent 1 e invisible Fora 1 the surface patch is opaque 1 e it hides plot 6 172 Colors objects that are behind it For 0 lt a lt 1 the surface patch is semitransparent 1 e plot objects behind it shine through RGBa color values can be constructed easily via the RGB library One only has to append a fourth entry to the
439. nction igamma Incomplete I function lngamma Logarithmic function psi Polygamma function Zeta Function and Polylogarithms The following MuPAD functions represent the Riemann function and the related dilogarithm and polylogarithm special functions You can use these functions as input for your computations MuPAD can return results in terms of these functions dilog Dilogarithm function polylog Polylogarithm function zeta Riemann function Airy and Bessel Functions The following MuPAD functions represent the Bessel and Airy special functions You can use these functions as an input for your computations MuPAD can return results in terms of these functions airyAi Airy function Ai airyBi Airy function Bi besselI Modified Bessel function of the first kind besselJ Bessel function of the first kind besselK Modified Bessel function of the second kind bessely Bessel function of the second kind Exponential and Trigonometric Integrals The following MuPAD functions represent exponential and trigonometric integrals You can use these functions as an input for your computations MuPAD can return results in terms of these functions 3 231 3 Mathematics 3 232 Ci Cosine integral Chi Hyperbolic cosine integral Ei Exponential integral Si Sine integral osi Shifted sine integral Shi Hyperbolic sine integral Error Functions and Fresnel Functions The following MuPAD functions represent the error functions integrals
440. nction MuPAD also provides the shortcut The function call last n or n returns the nth entry of the history table The last function counts the entries of the history table from the end of the table Thus when you use the Last function the most recent result 1s the first entry of the history table For example compute the factorials of the numbers 10 20 and 30 10 20 30 3628800 24329020081 76640000 9 123 5 Programming Fundamentals 9 124 2652352839812191058630308480000000 To access the computed factorial of 30 use the function call last 3 or the shorter call 969 last 3 3628800 Note When you call the last or history function MuPAD adds the result of that call to the history table Calling the last function or its shortcut inserts a new entry in the history table Thus the history table now contains the results of the following evaluations 10 20 30 and 963 which in this example is equal to 10 If you call the last function with the argument 3 again the system displays the result of evaluation of 20 last 3 24329070081 76640000 To access the most recent entry of the history table you can use the shortcut without parameters For example solve the following equation and then simplify the result Note that using lets you avoid assigning the result of a solution to an identifier solve log 2 x log 2 5 x 5 x n 5 5 nt fl amp In 23 n 5 T4 crs 32 dn 5 t
441. nd Left Limits 0 3 F3 00 02 04 06 08 10 12 14 16 18 20 22 24 26 28 30 3 169 3 Mathematics If Limits Do Not Exist 3 170 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If the Limit command cannot compute a limit of a function at a particular point and also cannot prove that the limit is not defined at this point the command returns an unresolved limit limit gamma 1 x cos sin 1 x x O im r 1 cos sn x 0 X ps So If limit can prove that the limit 1s undefined at a particular point then 1t returns undefined limit exp x cos 1 x x 0 undefined The function exp x cos 1 x also does not have one sided limits at X 0 limit exp x cos 1 x x 0 Left limit exp x cos 1 x x 0 Right undefined undefined The plot shows that as exp x cos 1 X approaches x O0 the function oscillates between e and e p1 plot Function2d exp x cos 1 x x PI 4 PI 4 p2 plot Function2d exp x x PI 4 PI 4 Color RGB Red p3 plot Function2d exp x x PI 4 PI 4 Color RGB Red plot p1 p2 p3 If Limits Do Not Exist ae 2 To get the interval of all possible accumulation points of the function exp x cos 1 x near the singularity X O use the option Intervals limit exp x cos 1 x x 0 Intervals 1 1 3 171 3 Mathematics Create Matrices 3 172 Note Use only in the MuPAD Notebook Int
442. ndition is true else print Unquoted the condition is false end if the condition is false X i i y i 6 if x gt 0 or 1 y gt 0 then print Unquoted the condition is true else print Unquoted the condition is false 4 Programming Basics end if the condition is true Use Nested Conditional Statements MuPAD supports the use of nested conditional statements For example X i 5 if testtype x DOM COMPLEX TRUE then print The Heaviside function is undefined for complex numbers else if x 0 then heavisideX 1 2 else if x lt 0 then heavisideX else heavisideX end if end if end if II O H For nested if else if usethe elif command as a shortcut X 0 if testtype x DOM COMPLEX TRUE then print The Heaviside function is undefined for complex numbers elif x 0 then heavisideX 1 2 elif x O then heavisideX 0 else heavisideX 1 end if l 2 Conditional Control Use case and otherwise Statements To choose between several cases use the case command The case statement looks for the first valid condition After that 1t executes all the statements between this condition and the keyword end if without checking the conditions do do of 3 do print three or less of 4 do print four of 5 do print five otherwise print 6 or more end case 4 case x i 2 four fye 6 or more To exit the case statement after executing t
443. ndow Help 9 nee Status Bar Ji Fit to Contents pior Recalculate R Stop Recalculate I Object Browser Toolbars kp n Hide Defaults h EN 0 5 Hide the default properties in the graphics object browser sidebar 6 100 to Imt aem 6 a 0 P Hr e Canvas El g Scene3d Er d CoordinateSystem3d Function3d maew we A z Xinesi be Meshvis Line Width LineCol Rer uw Reset lot p mn Recalculate view Insert Tools Actions Window Help JW Fit to Contents o Stop Recalaulate E Object Browser g Camera Control Toolbars b v Status Bar Hide Defaults al y 5 Configure Hide the default properties in the graphics object browser sidebar Viewer Browser and Inspector Interactive Manipulation ipix DaRk tE Alee t e aal Object Browser x E 1 f Canvas 2 2 x peram El 2 Scene3d C E a TE H Annotation H Calculation Style j z XLinesVi YlinesVi z MeshVis LineStyle Soli LineWidth LineColor LineCol Camera Control Object Browser Mem7MB T0s ou Ql INS At each node of the graphical tree default values for the attributes can be set via the property inspector These defaults are valid for all primitives that exist below this node unless these defaults are redefined at some other node further down in tree hierarchy This mechanism
444. ng procedure f proc x n local a b c begin a m b aj if x 0 then x i level b 2 else x level b 2 end_if end When you call this procedure it does not error f 42 24 nm To check f for common programming flaws use prog check When calling prog check you can specify how detailed the report must be This setting is called the information level of the report The second argument controls the information level of the report generated by prog check Use options to see specific flaws or call prog check Code Verification without options to see all common flaws that MuPAD finds in the procedure For the procedure f prog check with the information level 3 reports these flaws prog check f 3 Critical usage of level on local variable Critical usage of level on local variable Global idents m in f Unused local variables c in f Function level applied to variables b in f Warnings 3 f For the list of all available options see the prog check help page 9 139 5 Programming Fundamentals Protect Function and Option Names 9 140 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The names of the built in MuPAD functions and options are protected If you try to assign a value to a MuPAD function or option the system throws an error This approach ensures that you will not overwrite a built in function or option acc
445. ns If you use an arrow operator to define a function MuPAD does not evaluate the right side expression fi x gt int x 2 x z X Je dx To evaluate the right side expression when defining a function use the double arrow operator f2 x gt int x 2 x 4 27 4 Programming Basics 4 28 s AX 2 3 Use Functions with Parameters Besides symbolic variables functions can contain symbolic parameters To evaluate such a function for particular values of symbolic parameters use evalAt or the vertical bar as a shortcut fa x gt x 2 a fa 2 fa 2 a 10 14 Functions with symbolic parameters serve best for interactive use 1n a notebook In your regular code avoid unnecessary creation of such functions When using a symbolic parameter you use a global variable even though you do not explicitly declare 1t See Global Variables for information on global variables and recommendations on their use Shortcut for Closing Statements Shortcut for Closing Statements Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB As a shortcut for a closing statement use the end command This command closes e Conditional structures if then else a shortcut for end if e Case Selection Structures case Of a shortcut for end case Loops a shortcut for end for end repeat and end while Procedures a shortcut for end proc For example the following
446. ns and Fresnel Functions Hypergeometric Meier G and Whittaker Functions RElhptie Intesrals zs able GB aw RW a Lambert W Function omega Function Floating Point Arguments and Function Sensitivity Use Symbolic Computations When Possible Increase Precision ss sch 4d aie bel EX OX ee ed Approximate Parameters and Approximate Results Plot Special Functions leeren Integral Transforms lees Fourier and Inverse Fourier Transforms Laplace and Inverse Laplace Transforms Z Transforms ces Discrete Fourier Transforms Use Custom Patterns for Transforms Add New Patterns 0 000 eee unas Overwrite Existing Patterns Supported Distributions huport Data 4st i cet te ae oce e ec t centes Store Statistical Data 52s ta Compute Measures of Central Tendency Compute Measures of Dispersion Compute Measures of Shape 3 228 3 229 3 230 3 230 3 230 3 231 3 231 3 231 3 232 3 232 3 233 3 233 3 234 3 239 3 239 3 237 3 238 3 242 3 242 3 245 3 249 3 252 3 297 3 297 3 259 3 260 3 262 3 266 3 267 3 271 3 273 Compute Covariance and Correlation Handle Outliers Bin Data Create Scatter and List Plots
447. ns and Inequalities If you prefer a solution in a form other than RootOf and want to avoid numeric methods use polylib realroots to find all intervals containing real solutions p x 5 81 x 4 32 32 x 3 33 33 x 2 84 34 x 35 35 36 polylib realroots p i n EL Solve Inequalities solve can solve inequalities Typically the solution set of an inequality is interval ora union of intervals solve x 2 gt 5 x Use solve to solve the following inequality The solution includes the set of all complex numbers excluding 4 7 and 4 7 solve x 2 lt gt 7 x C A 1 wi g vit 3 33 3 Mathematics Solve Algebraic Systems Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Linear Systems of Equations on page 3 34 Linear Systems in a Matrix Form on page 3 35 Nonlinear Systems on page 3 41 Linear Systems of Equations When solving a linear system of symbolic equations the general solver returns a set of solutions S solve x y 1 3 x 2 y 5 x yl Assign individual solutions to variables using the or evalAt operator xSol ySol x S 1 y S 1 J ll oll ba The function linsolve returns a list of solutions linsolve x y 1 3 x 2 y 5 x y 3 34 Solve Algebraic Systems If there are more unknowns than independent equations in a system linsolve solves the system for the first un
448. ns only one solution Using the symbolic solver and post processing its results method requires more time than a purely numeric solver and can significantly decrease performance Solve equations using numeric methods from the beginning This method 1s faster but for nonpolynomial equations the numeric solver returns only the first solution it finds You can use the AllRealRoots option to make the solver look for other real roots Even with this option the solution set can be incomplete Using AllRealRoots can significantly decrease performance Approximate Symbolic Solutions Numerically When you solve an equation symbolically the solver does not always return results in an explicit form For example the solver can represent solutions using RootOf solve x 3 x 1 x 3 73 3 Mathematics RootOf z zal z If you have a symbolic solution that you want to approximate numerically use the float command S float 4 0 6823278038 0 3411639019 1 1615414 1 0 3411639019 1 1615414 1 Assign individual solutions to variables by indexing into S xSol S 3 0 3411639019 1 1615414 1 Use float to approximate the solutions of the symbolic system Ffloat solve x 3 x 2 2 x y y 2 x 2 x yl 4 x 0 5 1 658312395 1 y 0 5 1 658312395 il x 0 5 0 8660254038 1 y 0 5 0 8660254038 1 x 0 5 0 8660254038 1 y 0 5 0 8660254038 il x 0 5 1 6583123951 y 0 5
449. ns serve best when you know that an object holds its property throughout the solution process For more information see Using Permanent Assumptions Temporary assumptions hold true only for the particular evaluation where you set them For example if you use a temporary assumption while solving a single When to Use Assumptions equation the solver applies this assumption only to solve this particular equation Using temporary assumptions to solve problems works best when an object holds its property only during particular calculations Temporary assumptions also help you to keep the object name free and reuse it during the solution process For more information see Using Temporary Assumptions 3 115 3 Mathematics Use Permanent Assumptions 3 116 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Set Permanent Assumptions on page 3 116 Add Permanent Assumptions on page 3 118 Clear Permanent Assumptions on page 3 120 Set Permanent Assumptions Permanent assumptions work best for the mathematical properties that hold true throughout your computations Suppose you want to calculate the time during which a free falling object drops from the height h The kinematic equation for the free fall motion is h gt where g is the free fall acceleration Using this equation calculate the time during which the object falls from a certain height Without assumptions you get t
450. o refer to To select the file enter the file name in the Link to field or choose the file from the history list Alternatively click the Open File button and then browse for the file Display text Solutions of ODEs MuPAD Link to E H Documents ODE Examples mn Document Use absolute path instead of relative path Browse and select Browse files H Documents ODE Examples mn H Dacuments ODE Examples mn Internet Insert Links to Internet Addresses To insert a link to an Internet address Select the part of the notebook where you want to insert a link Select Insert gt Link from the main menu or use the context menu In the Create Hyperlink dialog box select Internet Aa N Type an Internet address and click OK For example insert a link to the Web page 2 54 Work with Links LA Display text Math Works MuPAD Link to t www mathworks com Document 3 Existing File Recent Internet Addresses Internet address y Veb pac ttp www mathworks com Internet To insert a link to an e mail address type mailto before the address 2 55 2 Notebook Interface Display text Provide feedback about this page Link to c mailto name mailbox com Document Existing File Browse and select Recent Internet Addresses Type Internet address E M Web page http www mathworks com Edit Existing Links To edit a link Select the link that you want to edit 2 Select Edit gt Link from the
451. oa yes O 8 40 has arguments O Type Checking and Mathematical Properties Type Singleton yee om Example 1 yes e O e Type Union e yes es testtype performs syntactical tests testtype 1 2 3 Type ListOf Type PosInt TRUE testtype 3 4 I Type Constant TRUE Example 2 Some types depends on parameters and cannot be used without parameters testtype 1 2 3 Type ListOf FALSE testtype x 0 Type Equation Type Unknown Type Zero TRUE An interval must be given with borders otherwise it 1s not a property assume x Type Interval 8 41 8 More Information About Some of the MuPAD Libraries 8 42 Error The second argument must be a property assume assume x Type Interval O infinity Example 3 1S derives mathematical properties assume x gt 0 is sqrt x 2 Type NonNegative TRUE is 2 x 1 lt 0 TRUE Example 4 Type Property and Type Constant are not properties assume x Type Property Error The second argument must be a property assume is x Type AnyType Error The type of the second argument is invalid It must be a property or a goal i
452. oblem that does not require application of strict mathematical rules try using the IgnoreAnalyticConstraints option With this option the simplifier uses a set of mathematical rules that are not generally correct For example if you use the IgnoreAnalyticConstraints option the simplifier returns Simplify h IgnoreAnalyticConstraints ea fete B sd k E 7 F The results obtained with the option IgnoreAnalyticConstraints are most useful for many in engineering and physics problems Note that when you use this option the simplifiers do not guarantee the equivalence of the original and simplified expressions for the entire complex plane 105 3 Mathematics Use Assumptions When transforming an expression the simplification functions apply the rules valid for the entire plane of complex numbers By default MuPAD does not assume any additional mathematical properties on the identifiers For example the identity In e x is not generally valid for all complex numbers simplify ln exp x In amp When you work with real numbers the simplification functions can also use the rules valid for real numbers Use the assume or assuming command to specify that a variable X represents a real number The assume command creates a permanent assumption The assuming command creates a temporary assumption which 1s valid during a single command The simplifier applies the appropriate rule and returns the expected result simplify ln exp
453. obner bases on page 8 10 The import Library on page 8 11 Integration Utilities on page 8 12 Linear Algebra Library on page 8 16 Linear Optimization on page 8 23 The misc Library on page 8 25 Numeric Algorithms Library on page 8 26 e Orthogonal Polynomials on page 8 27 Properties on page 8 28 Typeset Symbols in MuPAD on page 8 31 Type Checking and Mathematical Properties on page 8 39 8 More Information About Some of the MuPAD Libraries Abstract Data Types Library Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB This library contains MuPAD implementations of abstract data types Every instance of these data types is realized as a MuPAD domain The usage of this library is completely different from the rest of the MuPAD library An object of an adt data type is a domain so that by using the methods described here you change the object itself as a side effect No assignment is necessary to keep your changes Compare this to usual MuPAD functions where you have to always use for example f fourier f x y The data types are implemented completely within the MuPAD programming language Keeping this in mind the performance is excellent Example We create an object of the abstract data type stack and perform the standard operations The stack will be initialized with the characters a b and c Gre gd isStack a
454. ocedure accepts options 1t has an embedded mechanism for collecting and verifying these options For example the solve function accepts the Real option The option indicates that the solver must return only real solutions and accepts the values TRUE and FALSE If an option accepts only TRUE and FALSE values you can provide the option name without specifying its value solve x 4 1 O x Real i74 1 If you do not specify the Real option the solver uses the default option value FALSE and returns all complex solutions of the equation solve x 4 1 0 x t eng You can explicitly specify the option value pair for example Real TRUE or Real FALSE solve x 4 1 0 x Real TRUE solve x 4 1 0 x Real FALSE 1 1 11 ILE CLA If you provide an unexpected option for example 1f you spell the option name incorrectly MuPAD issues an error indicating the wrong option If there are several wrong options MuPAD indicates the first wrong option solve x 4 1 O x Rea Rel Verify Options Error The argument number 3 is invalid Evaluating solvelib getOptions You can embed the same option checking mechanism in your own procedures For this task MuPAD provides the prog getOptions function which collects and verifies options used during a procedure call When a user calls your procedure prog getOptions scans all arguments and returns a table that contains all expected options and their values I
455. of Gaussian distribution and Fresnel functions You can use these functions as input for your computations MuPAD can return results in terms of these functions erf Error function erfc Complementary error function erfi Imaginary error function inverf Inverse of error function inverfc Inverse of complementary error function fresnelC Fresnel cosine integral function fresnels Fresnel sine integral function Hypergeometric Meijer G and Whittaker Functions The following MuPAD functions represent the hypergeometric function the more general Meijer G function and related functions You can use these functions as input for your computations MuPAD can return results in terms of these functions hypergeom Hypergeometric function kummerU Confluent hypergeometric KummerU function meijerG Meijer G function whittakerM Whittaker s M function whittakerW Whittaker s W function Elliptic Integrals Special Functions Available in MuPAD The following MuPAD functions represent the elliptic integrals of different kinds You can use these functions as input for your computations MuPAD can return results in terms of these functions ellipticK ellipticCK ellipticF ellipticE ellipticCE ellipticPi ellipticCPi ellipticNome Complete elliptic integral of the first kind Complementary complete elliptic integral of the first kind Incomplete elliptic integral of the first kind Elliptic integral of the second kind Complementary
456. of a notebook to the cursor position Select Evaluate To End to evaluate calculations in the input regions from the cursor position to the end of a notebook Select Evaluate All to evaluate calculations in all input regions in a notebook 1 5 l Getting Started ff A File Edit View Navigation Inset Format Notebook Window Help BOVA SAP y B f Evaluate From Beginning Evaluate To End Evaluate All Read Commands Stop Typeset Math Abbreviate Output Pretty Print Text Width Start Engine Disconnect Mem amp MB TO s Also you can propagate the change throughout multiple input regions by pressing Enter in each input region 1 6 Shortcut to Access Standard MuPAD Functions Shortcut to Access Standard MuPAD Functions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To eliminate syntax errors and to make it easy to remember the commands and functions MuPAD can automatically complete the command you start typing To automatically complete the command press Ctrl space You also can access common functions through the Command Bar i Notebookl MuPAD File Edit View Navigation I4 C gu Ed d g Insert Format Notebook Window Help 3EQ00nutF amp X Generic Sans Serif Command Bar of mf ax kod F fi yj ng of fry Ex Command 3 a Bar General Math Plot Commands Mem 8 MB TOs If you do not see the Co
457. ograms and Pie Charts on page 3 285 Create Scatter and List Plots Create Scatter and List Plots Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Scatter plots can help you identify the relationship between two data samples A scatter plot is a simple plot of one variable against another For two discrete data samples x xs Xn and yr ys Yn a scatter plot is a collection of points with coordinates x yz x ys Xn Yn To create a scatter plot in MuPAD use the plot Scatterplot function For example create the scatter plot for the following data samples X and y x t 0 25 0 295 0 473 0 476 0 512 0 588 0 629 0 648 0 722 0 844 y 0 00102 0 271 0 378 0 478 0 495 0 663 0 68 0 778 0 948 0 975 plot plot Scatterplot x y 1 0 0 0 8 e 0 7 06 0 5 04 M s 03 02 0 1 0 0 0 3 0 4 0 5 0 6 0 7 0 8 3 281 3 Mathematics 3 282 By default the plot Scatterplot function also displays a regression line This line shows the linear dependency that best fits the two data samples To hide the regression line use the LinesVisible option plot plot Scatterplot x y LinesVisible FALSE 1 0 0 9 0 8 0 7 a 0 6 0 5 0 4 0 3 0 2 0 1 0 0 Another plot that can help you identify the relationship between two discrete data samples 1s a list plot List plots are convenient for plotting one data sample with equidistan
458. oint ContourIntegral there4 Therefore therefore ForAll forall emptyv varnothing Re Im image Imaginaryl 11 Type Checking and Mathematical Properties Type Checking and Mathematical Properties Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB This library contains several objects to perform syntactical tests with testtype see Example 1 on page 8 41 Some of the objects in this library depend on arguments that must be given by the user see Example 2 on page 8 41 Some of the objects can be used as mathematical properties within assume and is see Example 3 on page 8 42 Note All other objects that are not properties cannot be used within assume and is see Example 4 on page 8 42 The next tables gives an overview of all objects 1n this library Type AlgebraicConst yes Type AnyType yes Type Arithmetical yes Type Constant yes n n n Type Boolean yes n n Type ConstantIdents yes n n Type Complex yes es yes 8 39 8 More Information About Some of the MuPAD Libraries syntactical test is a property es es bes no es Un D o ye yes o yes NM ye yes yes yes yes yes es O S S S D yes D yes D D S es Sa es O yes D o e um Un O yes yes yes O yes yes D O es o es o Nome iv
459. oint in the list of sample points 6 189 6 Graphics and Animations Point proc a i begin if domtype float a lt gt DOM FLOAT then procname args else Y round a 1 end if end proc In the a th frame of the animation the camera 1s positioned at the a th sample point of the Lorenz attractor pointing toward the next sample point Setting TimeRange 0 n 10 the camera visits about 10 points per second n nops timemesh 1 plot plot Scene3d plot Camera Point a i i 1 3 Point a 1 i i 1 3 PI 4 a 1 n Frames n TimeRange 0 n 10 plot Polygon3d Y LineColor RGB Red PointsVisible TRUE plot Polygon3d Yxy LineColor RGB DimGrey plot Polygon3d Yxz LineColor RGB DimGrey plot Polygon3d Yyz LineColor RGB DimGrey plot Box box 1 box 2 box 3 box 4 box 5 box 6 LineColor RGB Black Filled TRUE FillColor RGB Grey 0 1 BackgroundStyle Flat 6 190 Cameras in 3D 6 191 6 Graphics and Animations Possible Strange Effects in 3D 6 192 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Starting with the MuPAD Release 3 0 the rendering engine for 3D plots uses the OpenGL library The OpenGL is a widely used standard graphics library and almost any computer has appropriate drivers installed in its system By default the MuPAD Graphics Tool uses a software OpenGL driver provided by the o
460. oints2 plot Point2d 1i 50 PI 1 plot Scene2d points1 S2 plot Scene2d points2 plot S1 S2 Y 10 0 9 0 8 0 7 0 8 0 5 0 4 0 3 0 2 0 1 0 0 sin i 50 PI i 0 50 cos i 50 PI i 0 50 0 0 0 2 0 4 Attributes If we wish to color all points in both scenes red we can set a default for the point color in the plot command plot S1 S2 PointColor RGB Red Yao Y 40 0 9 0 8 0 8 06 0 7 0 4 0 6 02 0 5 0 0 i 0 4 1 5 3 0 3 0 2 X LI 0 2 4 LI 0 1 0G IRI a 08 X 1 0 If we wish to color all points in the first scene red and all points in the second scene blue we can give each of the points the desired color in the generating call to plot Point2d Alternatively we can set separate defaults for the point color inside the scenes S1 plot Scene2d points1 PointColor S2 plot Scene2d points2 PointColor plot S1 S2 RGB Red RGB Blue 6 111 6 Graphics and Animations 6 112 Yao Y 40 0 9 0 8 0 8 06 T 0 4 0 8 02 0 5 e 0 0 7 IR a 0 4 1 5 3 0 3 02 di 0 2 0 4 r 0 1 O06 e 0 8 X 1 0 Here 1s the general rule for setting defaults inside a graphical tree see The Full Picture Graphical Trees Note When an attribute is specified in a node of the graphical tree the specified value serves as the default value for the attribute for all primitives that exist in the sub tree starting from th
461. ol LeftArrow Symbol ForALl C 0 UOI M 2 97 2 Notebook Interface Non Greek Characters in Text Regions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When working in a MuPAD notebook you can insert greek letters into text regions To use other special characters 1n text regions 1 Produce special characters in an output region 2 Copythe characters from the output region and paste them into a text region Symbol alpha Use the Symbol command Symbol Element in an input region Symbol Im OL Get special characters in an output region Ti Copy special characters from the output region to a text region Suppose a Z3 2 98 Use Keyboard Shortcuts Use Keyboard Shortcuts Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Shortcut keys for your platform provide quick access to many of the desktop menu items These shortcut keys are sometimes called accelerators or hot keys For example on Microsoft Windows platforms use the Ctrl X shortcut to cut text Many menu items include a shortcut Additional standard platform shortcuts usually work but each menu item lists only one On the Macintosh platform to make full use of all keyboard shortcuts you can enable full keyboard access For this option select Apple menu gt System Preferences and click Keyboard amp Mouse Click Keyboard Shortcuts
462. omatic zmin zmax Automatic Automatic Automatic Automatic 6 60 Easy Plotting Graphs of Functions attribute name __ possible values browser entry example ViewingBoxxXRal xmin xmax viewing range in Automatic CS2d 3d x direction Automatic ViewingBoxYRal ymin ymax viewing range in Automatic CS2d 3d y direction Automatic ViewingBoxZRal zmin zmax viewing range in Automatic CS3d z direction Automatic ViewingBoxXMil xmin real value lowest viewing Automatic CS2d 3d or Automatic valuein x direction ViewingBoxXMa xmax real value highest viewing Automatic CS2d 3d or Automatic j valueinx direction ViewingBoxYMil ymin real value lowest viewing Automatic CS2d 3d or Automatic value in y direction ViewingBoxYMa ymax real value highest viewing Automatic CS2d 3d or Automatic value in y direction ViewingBoxZMil zmin real value lowest viewing Automatic CS3d or Automatic value in z direction ViewingBoxZMa zmax real value highest viewing Automatic CS3d or Automatic value in z direction In contrast to the routines of the plot library plotfunc2d and plotfunc3d also accept the attributes YMin YMax YRange and ZMin ZMax ZRange respectively as shortcuts for the somewhat clumsy attribute names ViewingBoxYMin etc E g plotfunc2d f x x xmin xmax YRange ymin ymax 1s equivalent to plotfunc2d f x x xmin xmax ViewingBoxYRange ymin ymax 6 61 6 Graphics and Animation
463. ompute the Legendre symbol only if the modulus 1s a prime number The following table demonstrates the dependency between the value of the Legendre symbol and solvability of the congruence Ehe Legendre number is aoo Hase or moresolutions OOOO Cannot be solved by numlib msqrts Try numlib mroots 3 329 3 Mathematics 3 330 Fhe Legendre number is MuPAD implements the Legendre symbol as the num1ib Legendre function If and only if the congruence x a mod m is solvable the Legendre symbol 1s equal to 1 numlib legendre 12 13 numlib msqrts 12 13 5 8 If and only if the congruence x a mod m does not have any solutions the Legendre symbol is equal to 1 numlib legendre 11 13 numlib msqrts 11 13 If a and m are not coprime the Legendre symbol is equal to 0 In this case numlib Legendre function returns 0 and num1ib msqrts errors numlib legendre 13 13 numlib msqrts 13 13 Error Arguments must be relative prime numlib msqrts You can compute the Legendre symbol only if the modulus is a prime number If a congruence has a nonprime odd modulus you can compute the Jacobi symbol The Jacobi Congruences symbol determines the unsolvable congruences x a mod m You cannot compute the Jacobi symbol if the modulus is an even number The following table demonstrates the dependency between the value of the Jacobi symbol and the solvability of the congruence fhe J
464. on By specifying disjoint time ranges the second rotation around the z axis starts when the first rotation around the y axis 1s finished m I T1 the radius of the sphere R i19 1 01 increase the radius a little bit c 0 0 0O the center of the sphere thet PI 3 spherical coordinates of phi PI 4 the final point p the final point p plot Point3d c 1 R cos phi sin thet c 2 R sin phi sin thet 6 161 6 Graphics and Animations 6 162 c 3 R cos thet PointSize 2 unit mm Color RGB Black the sphere S plot Sphere r c Color RGB Green the meridian at thet 0 c1 plot i Curvesa cil R sin t c 2 c 3 R cos t t O thet Color RGB Black the meridian at thet 0 C2 plot Curve3d c 1 R cos t sin thet c 2 R sin t sin thet c 3 R cos thet t O phi Color RGB Black form a group consisting of the tangent plane and its normal g plot Group3d plot Surface 6 1 u e 2 v e 3 R u 1 1 v 1 1 Mesh 2 2 Color RGB Red 0 3 plot Arrow3d c 1 c 2 c 3 R c 1 c 2 c 3 R 0 7 1 rotate the group for 3 seconds along the meridian g plot Rotate3d a c O 1 0 a O thet g TimeRange 0 3 rotate the group for further 3 seconds along the azimuth g plot Rotate3d a c 0 O 1 a O phi g TimeRange 3 6 plot s g c1 c2 p Cam
465. onger than the declared dimensions MuPAD returns the following error message matrix 3 2 1 2 3 4 5 6 7 8 9 Perform Computations Error The number of columns does not match Dom Matrix Dom ExpressionField ml You also can create a diagonal matrix G matrix 4 4 1 2 3 4 Diagonal i OL LE L SS bw Operate on Matrices To add substract multiply and divide matrices use standard arithmetic operators For example to multiply two matrices enter matrix 1 2 3 4 5 6 matrix 1 2 3 4 5 6 A B i A B Fa h Li bi ee al nA EE LA ba P Lum ba e Ta ee ba e CO CN ba If you add number x to a matrix A MuPAD adds x times an identity matrix to A For example C matrix 3 3 1 2 3 4 5 6 7 8 9 C 10 l ud dt pal t di 77 8 9J 1 29 l Getting Started UPS 2 1 7 8 34 You can compute the determinant and the inverse of a square matrix G f matrix 1 2 0 2 1 2 O 2 1 Getta 1 G 120 2 12 021 7 8 P 7 7 2 l rj T _f 2 7 7 bi ILa Linear Algebra Library The MuPAD linalg library contains the functions for handling linear algebraic operations Using this library you can perform a wide variety of computations on matrices and vectors For example to find the eigenvalues of the square matrices G F and A B use the linalg eigen
466. ons with order terms the system uses standard arithmetical operations for these terms 0 x 3 0 x 2 O x 3 0 x 2 0 x 3 0 x 2 O x Ol obe 3 163 3 Mathematics Compute Generalized Series 3 164 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The Taylor series expansion is the most common way to approximate an expression by a polynomial However not all expressions can be represented by Taylor series For example you cannot compute a Taylor series expansion for the following expression around X 2 taylor 1 x 3 8 x 2 Error Cannot compute a Taylor expansion of 1 x 3 8 Try series for a more gen If a Taylor series expansion does not exist for your expression try to compute other power series MuPAD provides the function series for computing power series When you call series MuPAD tries to compute the following power series Taylor series e Laurent series e Puiseux series For more information see Series Puiseux Generalized series expansion of f around x xo For more information see Series gseries As soon as Series computes any type of power series it does not continue computing other types of series but stops and returns the result For example for this expression it returns a Laurent series S series 1 x 3 8 x 2 testtype S Type Series Laurent l 1 5 2 e n SY abs wh 12 x 2 24 712 288 1728 l2 E TRUE
467. onstructor hasProp 5 106 Profile Your Code The recommended approach for improving performance of your code is to use the MuPAD functions when possible For example MuPAD provides the has function for checking whether one MuPAD object contains another MuPAD object Rewrite your code using the has function and combining the procedures f and g g proc local M1 begin M1 op M has M1 i i 1 1000 end proc This procedure also converts the matrix M to a set Converting a matrix to a set can reduce the number of elements MuPAD removes duplicate elements of a set The execution time for the procedure call g is the shortest among the three implementations time g 1520 095 The profiling report shows that the procedure spends most of its execution time accessing the 1000x1000 matrix of random integers and converting it to a set This example shows only the top of the profiling report prog profile g percent usage of all time self per single call time self time children per single time children 5 107 5 Programming Fundamentals calls normal exit calls errors 100 0 1556 1 1556 1 1 0 procedure entry point 78 9 1228 1 1228 1 188 0 188 0 1 1 Dom Matrix Dom Integer op 9 0 140 0 140 0 1416 1 1416 1 1 2 9 8 2 0 1 128 0 i 1000 3 p gt coeff p A11 2 1 3 9 0 1 60 0 1000 4 1 gt 1 Rzero r nops 1
468. onstructors Dom Matrix and Dom SquareMatrix can be considerably improved in certain cases Some of the functions of the 1inalg library correspond to certain methods of the domain constructor Dom Matrix in their name and functionality These functions are implemented by calling relevant methods of the domain to that they belong apart from additional argument checking These functions enable an user friendly usage on the interactive level after exporting However in user defined procedures the methods of the corresponding domain should be used directly to avoid additionally calls of procedures For example standard matrix manipulation functions such as deleting extracting or swapping of rows and columns are defined as methods of the domain constructors Dom Matrix and Dom SquareMatrix The method gaussElim offers a Gaussian elimination process for each domain created by these constructors When creating a new matrix the method new is called It converts each component of the matrix explicitly into a component the component ring which may be time consuming However matrices and vectors are often the results of computations whose components already are elements of the component ring Thus the conversion of Linear Algebra Library the entries 1s not necessary To take this into account the domain constructors Dom Matrix and Dom SquareMatrix offer a method create to define matrices in the usual way but without
469. ooter Center Right alignment rgin pMargi ter ader oterFo n HeaderAlignment Left Center horizontal header Center Right alignment LegendVisible TRUE FALSE legend on off FALSE 6 127 6 Graphics and Animations attribute name possible values example LegendAlignment Center Left horizontal legend Center Right alignment LegendPlacement Bottom Top vertical legend Bottom placement Left 0 1 1 0 unit mm distance of the left side of the scene to the left side of the canvas relative or absolute value Bottom 0 1 1 0 unit mm distance of the bottom side of the scene to the bottom side of the canvas relative or absolute value Similar to the canvas scenes can have a border set via BorderWidth and BorderColor There is a small margin into which no graphical content is rendered Further a header and a footer can be specified The scene Header TopMargin LeftMargin RightMargin BorderWidth BottomMargin 6 128 Animations Animations Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Generate Simple Animations on page 6 129 Play Animations on page 6 134 The Number of Frames and the Time Range on page 6 135 What Can Be Animated on page 6 138 Advanced Animations The Synchronization Model on page 6 140 Frame by Frame Animations on page 6 143 Examples on page 6 149 Generate Simple Animations Each primitive of th
470. or function erf o code y t t y t y 0 0 y 0 1 3 y t Solve Equations Numerically ode solve o Suppose you do not need an exact symbolic solution but you want to approximate the solution for several values of the parameter t For numeric approximations of the solutions of ODEs MuPAD provides two functions numeric odesolve returns a numeric approximation of the solution at a particular point numeric odesolve2 returns a function representing a numeric approximation of the solution Both functions accept either a first order ODE or a system of first order ODEs To solve a higher order equation convert 1t to a system of the first order equations For example represent the second order ODE you solved symbolically as a system of two first order equations z z fz y 0 2 0 z 0 The solution vector for this systemis Y y z Approximate at Particular Points The function numeric odesolve requires the system of first order ODEs dynamic system to be represented by a procedure f proc t Y begin Y 2 t Y 2 end proc proc f t Y end The second parameter of numeric odesolve is the range over which you want to solve an ODE The third parameter is a list of initial conditions y 0 0 z 0 Approximate the solutions y t for t 1 t 3 and 1 127 numeric odesolve f 0O 1 O 1 3 numeric odesolve f 0 3 0 1 3 numeric odesolve f 0 1 127
471. or function is called with the coordinates x y z of the points on the graph The next input parameter the 4th argument of mycolor is the animation parameter f x y gt 4 x a 2 y a 2 mycolor proc x y Z a local t begin t sqrt x a 2 y a a if t lt 0 1 then return RGB Red elif t lt 0 4 then 6 133 6 Graphics and Animations return RGB Orange elif t lt 0 7 then return RGB Green else return RGB Blue eng iT end plot plot Function3d f x 1 1 y 1 1 a 1 1 FillColorFunction mycolor Play Animations When an animated plot is created in a MuPAD notebook the first frame of the animation appears as a static picture below the input region To start the animation double click on the plot An icon for starting the animation will appear make sure the item Animation Bar of the View menu is enabled 6 134 Animations fj Notebooki MuPAD E alol x Fie Edit View Tools Animation Window Help e ril 8 Qe y la a tJ e H Alg l a Object Browser X plotfunc2d cos a x x 0 2 PI a 1 2 EF Scene2d i CoordinateSystem2d he Ay Functionzd i Height i Layout gt Rows i Columns 3 TopMargin j z BottomMar LeftMargin One can also use the slider to animate the picture by hand Alternatively the Animation menu provides an item for starting the animation The Number of Frames an
472. or returns the result as a list of one floating point value one has to pass the single list entry as Y X 1 to plot Function2d The vector field is generated via plot VectorField2d 6 86 Advanced Plotting Principles and First Examples gt y 8 cos x odesolve2 X y numeric v numeric ode2vectorfield y x f x y y 0 0 plot RGB Red plot Function2d Y x 1 x 0 6 Color mm 0 0 7 unit plot VectorField2d 1 f x y x LineWidth fe aly 25 25 6 y S TRUE Axes J Mesh RGB Blue Color TRUE SubgridVisible Frame GridVisible boa Roh beth te ed ate ee n ede JAK CCS ss T OR s s s rara Peveeeceeceee ces Cece HA RR NONNUUIS ret AAA Rh NR Nh A BN CNN NUNT AAAAAAAAAAAAAAAA AAG A RRS LHAAHA AAAA AAA AAAA AAAA KK aatttAA AA AA AAA MAR AM X mEegpetetett ttt AAAA AAAA A APANA SEE HAAAAAMAAAAAMAA AS A iittala EE pee i to pa i a Pitt a itech PEA AAA AA gAAAAAAAAA AS AAAI AAA AM AAARAAAAANAA ADA m AAAA AP BRBAAARARAAARAAA AA ANY AAA CAO EA AC A A NN CSI AAAIRRANNKRNAANAMNMAB RIS RM JOA ATR RSS IS S S ee ree AA KK RRR RRR ERROR Ohh hs Big tenere re eee re e rtm A SCR Ee e e re reta o n Ss n e T i q Example 4 The radius r of an object with rotational symmetry around the x axis is measured at various x positions A spline interpolation is
473. ot a x 2 x 1 1 ff ax for Inf 25 5 7 0 fr y ae Output y zz a b a b region 20 7 M a b n x f x ix sa e in wit e o a a mks f 1 0 fe Sa 05 v General Math v Plot Commands 10 08 06 04 02 00 02 04 06 08 10 X Mem 7 MB T0 s Cmd INS In the input regions marked by grey brackets you can type mathematical expressions and commands in the MuPAD language For example type the following expression and press Enter to evaluate the result 272 10 TAS 3 Desktop Overview 9708 3 The results including graphics appear in a new output region The default font color for input regions is red and the default font color for output regions is blue To customize default settings see Changing Default Format Settings When you evaluate an expression in the bottom input region MuPAD inserts a new input region below To insert new input regions in other parts of a notebook Select the place in a notebook where you want to insert a new input region 2 Insert a new input region To insert an input region below the cursor position select Insert gt Calculation from the main menu To insert an input region above the cursor position select Insert gt Calculation Above from the main menu You can type and format text in a notebook similar to working 1n any word processing application To start a new text region click outside the gray brackets and start typing Also to insert a new text region you can select Insert
474. ot run in MATLAB Use Loops to Modify Matrix Elements on page 3 177 Use Functions to Modify Matrix Elements on page 3 178 MuPAD lets you access and change each individual element of a vector or a matrix For example create the 3 X4 matrix of zeros A matrix 3 4 0000 0000 000 To access any element of the matrix use square brackets to specify indices For example assign the value 22 to the second element of the second row of A A 2 2 22 Now assign the value 23 to the third element of the second row of A A 2 3 23 Display the modified matrix A A oO 0 0 0 0 22 23 0 0 0 0 Q Use Loops to Modify Matrix Elements When changing values of the elements of a matrix you can use loops For example use the for loop to define each element of A as a product of its row and column indices 3 177 3 Mathematics A matrix 3 4 for i from 1 to 3 do for j from 1 to 4 do Ali J v 2 end for end for A 1234 246 s 369 17 Use Functions to Modify Matrix Elements Another way to specify a large number of matrix entries efficiently 1s to create and use a function For example define each element as a sum of its row and column indices f i i J gt 1 j A matrix 3 4 f 2345 3456 452607 3 178 Create Matrices over Particular Rings Create Matrices over Particular Rings Note Use only in the MuPAD Notebook Interface This functionality does not run in
475. otebooks You can run MuPAD commands every time you start the engine without displaying these commands in a notebook If you want to use hidden commands for a particular notebook see Hiding Code Lines To add startup commands to all MuPAD notebooks Select View Configure 2 Inthe left pane of the Configure MuPAD dialog box click Engine 3 Inthe User Init Path field specify the path to the initialization file containing your commands Options Available for MuPAD Engine Startup You can use the following options on the startup of the MuPAD engine g Start the engine in debug mode The engine creates debug nodes during the initial read L number U string E T filename Set Engine Preferences of the MuPAD library Without this option MuPAD creates the nodes during a debug session after the first debug call Then it writes the information about passes through the nodes to a temporary file Start the engine in the debug mode MuPAD displays more detailed debug information in the output pane of the Debugger window Suppress reading the initialization files Use this option to test your code without deleting the files or the path specified in the User Init Path field Suppress reading all the package files from the path specified in the Package Path field Use this option to test your code without deleting the files or the path Set the limit of precalculated prime numbers The engine calculates and stores
476. ottom of the calculation and width of the left bracket that encloses the input region 2 25 2 Notebook Interface 2 26 i Calculation Format Bracket Spacing Padding 5 05 Top Line Width 2 5 Bottom 1 00 Zz re we If you want to experiment with different settings for input regions and see how the formatted expressions and commands look in your notebook click the Apply button This button applies formatting to the selected region and leaves the Calculation Format dialog box open You can change settings several times without having to open this dialog box for each change When you finish formatting click OK to close the Calculation Format dialog box Format Expressions in Input Regions File Edit View Mavigation Insert Format Notebook Window Help dj d v 73 CO ntG0 OF Piecewise solutions The solution of the quadratic equation a x bx c 0is piecewise Here a b and c are symbolic parameters and x is a symbolic variable Piecewise objects often occur if an equation contains symbolic parameters in addition to the variable solve a x 2 b x c 0 x f bryb 4ac b yb m Fasi 2a 2a lt if a 0Ab520 C if a O0Ab 0ac 0 e f a O0Ab O0acez0 Mem 8 MB TOs 2 27 2 Notebook Interface Change Default Format Settings 2 28 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If you want to apply a specific format to the whole notebook yo
477. ou can formalize it by asserting that a population parameter or a combination of population parameters has a certain value MuPAD enables you to test the following null hypotheses The data has the distribution function f If f 1s a cumulative distribution function CDF you can use the classical chi square goodness of fit test or the Kolmogorov Smirnov test If f is probability density function PDF a discrete probability function PF or an arbitrary distribution function use the classical chi square goodness of fit test The data has a normal distribution function with a particular mean and a particular variance For cumulative distribution functions use the classical chi square goodness of fit test or the Kolmogorov Smirnov test For other distribution functions use the classical chi square goodness of fit test The data has a normal distribution function with unknown mean and variance Use the Shapiro Wilk goodness of fit test for this hypothesis The mean of the data 1s larger than some particular value Use the t Test for this hypothesis The main result returned by the hypothesis tests 1s the p value PValue The p value of a test indicates the probability under the null hypothesis of obtaining a value of the test statistic as extreme or more extreme than the value computed from the sample If the p value 1s larger than the significance level stated and agreed upon before the test the null hypothesis passes the
478. ou can use the general simplification functions simplify and Simplify to check if they give a simpler form of the expression you use Transform and Simplify Trigonometric Expressions You also can transform and simplify trigonometric expressions The functions for manipulating trigonometric expressions are the same as for polynomial expressions For example to expand a trigonometric expression use the expand command expand sin 5 x 16 sin x c os x 12 sin x cos x sin x To factor the trigonometric expression use the factor command factor cos x 4 4 cos x 3 sin x 6 cos x 2 sin x 2 4 cos x sin x 3 sin x 4 cos x sm x P You can use the general simplification functions on trigonometric expressions simplify cos x 2 sin x 2 1 35 l Getting Started 1 36 simplify cos x 4 sin x 4 sin x cos x Fr 2 u Fo sm 2x sm 2x 1 TH 2 Simplify cos x 4 sin x 4 sin x cos x sin 2 x 1 sm 2 x 2 2 Use Assumptions in Your Computations Solve Expressions with Assumptions By default all variables in MuPAD represent complex numbers When solving equations or simplifying expressions the software considers all possible cases for complex numbers If you are solving an equation or simplifying an expression this default assumption leads to the exact and complete set of results including complex solutions solve x 5 2 1 x ir E PE Iz E QW3 1
479. ox click Delete v Edit Link Target Edit the name of this link target First Order ODEs Export Notebooks to HTML PDF and Plain Text Formats Export Notebooks to HTML PDF and Plain Text Formats Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To export a notebook to HTML PDF or plain text format 1 Select File Export from the main menu 2 From the drop down menu select the file format to which you want to export a notebook J Export Notebook QC F di My Docume Exported Notebooks Organize New folder ems E Mame 2 myMotebook html File name Matebookl h PDF Files pdf Hide Folders Plain Text Files txt All Files 2 59 2 Notebook Interface 3 Inthe Export Notebook dialog box enter a name for the file and click Save If you export a MuPAD document with links to PDF format these links are replaced by regular text 1n the resulting PDF file 2 60 Save and Export Graphics Save and Export Graphics Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Export Static Plots on page 2 61 Choose the Export Format on page 2 64 Save Animations on page 2 65 Export Sequence of Static Images on page 2 66 Export Static Plots To save the resulting plots separately from a notebook 1 Double click the plot you want to export Select File gt Kxport Gr
480. p 123 5 3 3 The symmetric modulo function mods implements the alternative definition of the remainder of a division This definition allows the remainder to be negative The symmetric modulo function compares the absolute values of the negative and the positive remainders and returns the remainder that has the least absolute value mods 122 5 mods 123 5 Modular Arithmetic You can redefine the modulo operator mod by assigning mods or modp to mod 123 mod 5 mod mods 123 mod 5 2 Redefining the modulo operator mod does not affect the div function that computes the quotient The div function always computes the quotient by assuming that the remainder must be nonnegative 123 div 5 123 mod 5 24 3 For further computations restore the default behavior of the modulo operator mod modp Now suppose that the number is represented as o where a and b are integers Suppose you want to compute the modular power of a over C which is the remainder of the division of a by an integer c You can compute the modular power by using the modulo operator mod 987 124 mod 12 When you use the mod operator to compute the modular power MuPAD performs computations 1n two steps First the system computes the power of an integer and then it divides the result and finds the remainder This approach works if both the number and its power are small However if the numbers are large the first step computing the pow
481. p 1s infinite i 1 repeat print i until i gt 3 end_repeat To avoid this infinite loop use the additional statement to change it in each iteration i 21j repeat Loit print i until i gt 3 end_repeat Use Multiple Conditions You can use multiple conditions combining the expressions by and or xor or other logical operators 1 2 j 3 repeat L 159 2 1 j j 2 print i j 4 12 until 1 gt 100 and j gt 10 end_repeat 6 9 54 81 4374 6561 l1 1e j 3 repeat Ler j 1 2 print i j until i gt 100 or j gt 10 end_repeat 6 9 54 81 Use Nested Loops Loops You can place one or several loops inside another loop Internal loops can be of the same or different types S 0 for i from 1 to 3 do for j from 1 to 2 do S i end for end for print s S itji 4 13 4 Programming Basics 4 14 for i from 1 to 3 do 12 while j 2 do S 19 1 j j 1 end_while end_for print s 2 Exit a Loop To add a possibility to exit a loop use the break command Suppose you want to exit a loop if some condition is true for i from 1 to 3 do for j from 1 to 2 do if 1 j then print Unquoted i j expr2text 1i break end_if end for end for i j 2 The break command lets you exit the loop in which you place this command If you create nested loops and use break inside an inner loop MuPAD continues to execute the statements in t
482. pear again after 13 seconds p4 plot Point2d 0 5 0 5 Color RGB Black PointSize 5 unit mm VisibleFromTo 7 13 The start of the animation is determined by p1 which bears the attribute TimeBegin 0 the end of the animation 1s determined by p3 which has set TimeEnd 15 plot p1 p2 p3 p4 PointSize 3 0 unit mn YAxisVisible FALSE Although a typical MuPAD animation is generated object by object each animated object taking care of its own animation we can also use the attributes VisibleAfter VisibleBefore VisibleFromTo to build up an animation frame by frame Note Frame by frame animations Choose a collection of typically static graphical primitives that are to be visible in the i th frame of the animation Set VisibleFromTo Animations t i t it 1 for these primitives where t i t it 1 is the real time life span of the i th frame in seconds Finally plot all frames in a single plot command Here is an example We let two points wander along the graphs of the sine and the cosine function respectively Each frame is to consist of a picture of two points We use plot Group2d to define the frame the group forwards the attribute VisibleFromTo to all its elements for i from O to 101 do t i i 10 end for for i from O to 100 do X i 1 100 PI myframe i plot Group2d plot Point2d x sin x Color RGB Red plot Point2d x cos x Color RGB Blue VisibleFromTo t
483. perating system Depending on the graphics card of your machine you may also have further OpenGL drivers on your system maybe using hardware support to accelerate OpenGL On most Apple Macintosh machines no software OpenGL is available MuPAD uses accellerated OpenGL on these machines automatically The MuPAD 3D graphics was written and tested using certain standard OpenGL drivers The numerous drivers available on the market have different rendering quality and differ slightly which may lead to some unexpected graphical effects on your machine After clicking on a 8D plot a Help menu is visible in a MuPAD notebook The item OpenGL Info provides the information which OpenGL driver you are currently using By default MuPAD uses the software driver provided by the operating system indicated as Renderer GDI Generic on Microsoft Windows Apple Software Renderer on Macintosh systems with software OpenGL and Renderer Mesa GLX Indirect on a typical Linux system followed by a line Direct No to indicate that no hardware acceleration is used You also get the information how many light sources and how many clipping planes this driver supports If you wish to switch to another driver use the item Configure of the View menu Preferences of the MuPAD menu on the Macintosh Picking User Interface on the left you get a dialog that allows to enable accelerated Open
484. phical point in 3D collection of graphical points in 2D collection of graphical points 1n 3D line segments forming a polygon in 2D line segments forming a polygon in 3D rectangle in 2D 6 103 6 Graphics and Animations 6 104 plot plot plot plot plot Sphere SurfaceSet SurfaceSTL Text2d Text3d sphere in 3D surfaces in 3D as a collection of 3D triangles import of 3D stl surfaces text object 1n 2D text object 1n 3D In addition there are primitives for Plato s regular polyhedra plot plot plot plot plot Tetrahedron Hexahedron Octahedron Dodecahedron Icosahedron The following table lists the high level primitives and special purpose primitives plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot Bars2d Bars3d Boxplot Conformal Curve2d Curvea3d Density Functionad Functiona3d Hatch Histogram2d Implicit2d Implicit3d Inequality Integral statistical data plot 1n 2D statistical data plot 1n 3D statistical box plot conformal plot of complex functions parametrized curve in 2D parametrized curve in 3D density plot in 2D function graph in 2D function graph in 3D hatched region in 2D statistical histogram plot in 2D plot of implicitly defined curves in 2D plot of implicitly defined surfaces 1n 3D visualization of inequalities in 2D visualization of in
485. ple switch on the warnings intlib printWarnings TRUE 3 135 3 Mathematics 3 136 Suppose you want to integrate the following expression under the assumption that the integration variable 1s positive This assumption does not conflict with the assumption that the variable 1s real The int command uses your assumption f abs x int f x assuming x O i P Integrate this expression under the assumption that X 1s an integer MuPAD cannot integrate the expression over a discrete subset of the real numbers The int command issues a warning and then integrates over the field of real numbers int f x assuming x in Z_ Warning Cannot integrate when x has property Z The assumption that x has the x sign x For a discrete set of values of the integration variable compute a sum instead of computing an integral See Summation for details Now integrate under the assumption that X 1s imaginary The int command cannot compute the integral of the expression over imaginary numbers It issues a warning and integrates the expression over the domain of complex numbers assume x Type Imaginary int f x Warning Cannot integrate when x has property Dom ImageSet x I x R The assum 0 ii x 0 2 mlt aika a fxgR For more information about the assumptions see Properties and Assumptions Before you proceed with other computations clear the assumption on the variable
486. ple create the domain TempF that represents the Fahrenheit temperature scale TempF newDomain TempF Currently the new domain does not have any elements To create an element of a domain use the new function For example create the new element x of the domain TempF x new TempF 15 new TempF 15 To verify that the object x belongs to the domain TempF use the testtype function You can also use the domtype or type function testtype x TempF domtype x type x TRUE TempF TempF To check the internal representation of X use the extop function extop x p LA Suppose you want the new method of the domain TempF to check whether an input argument is a valid temperature measurement In this case redefine the new method for your domain TempF 9 49 5 Programming Fundamentals 9 50 TempF new t gt if testtype t Type Real then if t 459 67 then new dom t else error Temperature is below absolute zero end if else error Expecting a real number above absolute zero end if The redefined method checks that an input argument 1s a number It also checks that the provided temperature is not below absolute zero Absolute zero is zero degrees on the Kelvin temperature scale which is equivalent to 459 67 degrees on the Fahrenheit scale The redefined method creates new elements in degrees Fahrenheit Call the method TempF new directly or use the shorter syntax TempF newElement
487. plify invL t In f Besides arithmetical expressions the laplace and ilaplace functions also accept matrices of arithmetical expressions For example compute the Laplace transform of the following matrix A i matrix 2 2 1 t t2 t 91 laplace A t s Integral Transforms E3 bal Ey po wolt E3 Ey When computing a transform of an expression you can use assumptions on mathematical properties of the arguments For example compute the Laplace transform of the Dirac delta distribution d laplace dirac t t 0 t s assuming t O gt 0 Restore the Dirac delta distribution from the resulting expression d ilaplace d s t assuming t O gt 0 jt The laplace function provides the transforms for some special functions For example compute the Laplace transforms of the following Bessel functions laplace besselJ O t t s laplace bessellJ 1 t t s laplace besselJ 1 2 t t s l V 5 1 l v2 LL E L i afar ERE 3 247 3 Mathematics 3 248 The laplace and ilaplace functions let you evaluate the transforms of an expression or a matrix at a particular point For example evaluate the Laplace transform of the following expression for the values 10 laplace t exp t t 10 l 121 Now evaluate the inverse Laplace transform of the following expression for the value t X ty ilaplace 1 1 s 2 S X y I y e xc y If MuPAD cannot
488. presentation a b 1 Visualize Expression Trees To display expression trees in a MuPAD notebook use the prog exprtree function It replaces operators with the names of the corresponding system functions prog exprtree a b c d e sin f g plus a mult hes C mult d t e power t Sin 9 151 5 Programming Fundamentals Modify Subexpressions 9 152 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Find and Replace Subexpressions Operations on symbolic expressions often involve finding subexpressions and replacing them with values or with other subexpressions MuPAD provides the following functions for this task evalAt and its shortcut subs Subsex Subsop prog find evalAt replaces specified objects 1n the expression tree with the specified values or subexpressions and then evaluates the expression This function replaces only entire branches of expression trees It cannot replace a part of the branch for example two terms in the sum of three terms a b c a b c a D 6 7 C CY Jl TO oc Il a c diada b c l evalAt replaces only free identifiers int f x x 0 1 f x x 100 Modify Subexpressions l f 100 f x dx 0 Subs replaces specified objects in the expression tree with the specified values or subexpressions This fun
489. pute Indefinite Integrals on page 3 135 3 Mathematics Compute Definite Integrals on page 3 138 Compute Multiple Integrals on page 3 141 Apply Standard Integration Methods Directly on page 3 143 Get Simpler Results on page 3 146 If an Integral Is Undefined on page 3 147 If MuPAD Cannot Compute an Integral on page 3 148 Compute Symbolic Sums on page 3 151 Approximate Sums Numerically on page 3 154 Compute Taylor Series for Univariate Expressions on page 3 156 Compute Taylor Series for Multivariate Expressions on page 3 159 Control Number of Terms in Series Expansions on page 3 160 Q term The Landau Symbol on page 3 163 Compute Generalized Series on page 3 164 Compute Bidirectional Limits on page 3 166 Compute Right and Left Limits on page 3 167 If Limits Do Not Exist on page 3 170 Create Matrices on page 3 172 Create Vectors on page 3 174 Create Special Matrices on page 3 175 Access and Modify Matrix Elements on page 3 177 Create Matrices over Particular Rings on page 3 179 Use Sparse and Dense Matrices on page 3 181 Compute with Matrices on page 3 183 Compute Determinants and Traces of Square Matrices on page 3 188 Invert Matrices on page 3 189 Transpose Matrices on page 3 190 Swap and Delete Rows and Columns on page 3 191 Compute Dimensions of a Matrix on page 3 193 Compute Reduced Row Echelon Form on page 3 194 Compute Rank of a Matrix
490. quations containing symbolic parameters solve x 2 y 2 a x2 y 2 b x yl yf V arb dos ME nn aL Solve Ordinary Differential Equations You can solve different types of ordinary differential equations o ode x 2 diff y x x x 2 x diff y x x x y x solve o esx C4 cs pte 1 32 Perform Computations Solve Inequalities Also you can solve inequalities solve x 4 gt 5 x F ral r ra i ZE uid T 51 4 x If you want to get the result over the field of real numbers only assume that x 1s a real number assume x in R solve x 4 gt 5 x You can pick the solutions that are positive solve x 4 gt 5 x assuming x gt O Manipulate Expressions Transform and Simplify Polynomial Expressions There are several ways to present a polynomial expression The standard polynomial form is a sum of monomials To get this form of a polynomial expression use the expand command expand x 1 x 1 1 XE vox cw 1 X2 19 X 2 X x F X 4 x 2 1 x You can factor this expression using the factor command factor x 12 1 1 33 l Getting Started 1 34 x 1 x41 x7 x 1 x 1 x x 1 ht 41 For multivariable expressions you can specify a variable and collect the terms with the same powers 1n this variable collect x a 4 a x 3 b 2 x b x 10 a 4 b a x 2 x 4 3 fe 21 2 3 1 2 Oo A i12 x c 3g
491. r solve called without arguments end if 82 Gf args 0 gt 2 them 83 egs eg B4 vars var to avoid warnings 85 userinfo l solving exprztext egqgas for exprztext vara Bo else aT emqs eg 88 userinfo l Solving exprztexti egs BS end if 30 31 32 itf type egs equal then 93 if domtype opleqs 1 DOM LIST and 94 domtype op eqs 2 DOM LIST then 55 eqs giplopleqs 1 opleqs 2 equal 0 30 else eqs aop eqs 1 op eqs 2 if eqs undefined then return procname args 11 end if end if end if Remove all breakpoints Mem 1 MB TOs Evaluate Variables and Expressions After a Particular Function Call During the debugging process you can check the values of variables by hovering the cursor over a particular variable The Debugger displays the current value of the variable 9 19 5 Programming Fundamentals Proc n name f begin g 10 n end proc h proc 3 n 5 name Qr ip DO y OF e fo R3 Lp begin x ix 1 end proc oe t M p oc To evaluate the value of an expression 1 Ifyou do not see the Output pane select View gt Output from the main menu 2 Inthe Output pane type the expression you want to evaluate or select one of the prior expressions from the drop down menu 3 Click the Evaluate button or press the Enter key Output Bx Evaluate x x 1 uN x ix 1 10 11 Evaluate expression
492. r from 1 to 1000 g proc local M1 begin M1 sort op M f M1 matrixSize 2 i i 1 1000 end proc Using the bisection method instead of accessing each matrix element significantly improves the performance of the example time g 3724 233 Typically the best approach is to use the appropriate MuPAD functions whenever possible For example to improve performance further rewrite the code using the MuPAD function has Also converting a matrix to a set can reduce the number of elements MuPAD removes duplicate elements of a set In addition to speed up this approach makes your code significantly shorter and easier to read g proc local M1 begin M1 op M has M1 i i 1 1000 end proc In this case execution time 1s even shorter than for the code that implements the bisectional method time g 1508 094 Measure Time Calls to External Processes Results returned by the time function exclude the time spent on calls to external programs If your code uses external programs you can measure the total time spent by that code including calls to external processes To measure the total time use the rtime function instead of time For example the function call rtime returns the elapsed time of the current MuPAD session This time includes idle time of the current session t rtime print Unquoted This session runtime is stringlib formatTime t This session runtime is 5 minutes
493. r a a mod n You cannot predict the number of entries in the resulting list because 1t depends on the parameters a and n Nevertheless you can see that 1n this case the number of entries in the list cannot exceed n 9 145 5 Programming Fundamentals 9 146 modPowers proc a n local L i begin L L 1 LI2 lt i 2 while L i lt gt a do L i 1 a L i mod n i i 1 end while L L 1 1 1 end I o n a a 2 mod n When you call modPowers for a 3and a 2 it creates two lists of different lengths modPowers 3 14 modPowers 2 14 3 9 13 11 5 1 Unknown Maximum Length Collection Often you cannot predict the number of elements and cannot estimate the upper limit on this number before you start generating actual data One way of dealing with this problem is to choose some upper limit and use the strategy described in Known Maximum Length Collection If that limit 1s reached then 1 Choose a larger limit 2 Create a new list with the number of elements corresponding to the new limit 3 Copy existing collected data to the new list Typically increasing the list length by a constant factor results in better performance than increasing 1t by a constant number of entries rndUntil42 proc Data Collection local L i begin i 1 L random while L i mod 42 lt gt 0 do if 1 nops L then L i L L end if Lis DEPT L i random
494. r calculations using different modes By default expressions 1n outputs use typeset mode and abbreviations solve x 3 x 2 1 0 x MaxDegree 3 5 pom 108 To disable abbreviations clear Notebook gt Abbreviate Output solve x 3 x 2 1 O x MaxDegree 3 2 87 2 Notebook Interface 3 FI 108 1s3 Lo Teed l ZEE 9 22 _ 314 108 y 3 54 108 3 18 23 4 31 108 l 1 3 54 108 354 108 3 l 29 31 108 MSN ET THEN GA v TLE 34 10s i 22 21 v10 2 3 4 IP 24 Tr 1 A iM To 2 3 7 j 22 _ 31 p 3 _ 4 54 108 _1 18 28 3l 3 2 3 54 108 3 2 EREA P W 7 gt 77 1 s 28 y ELLAS 3 54 i08 54 008 2 To enable abbreviations select Notebook gt Abbreviate Output Alternatively you can enable and disable abbreviations by using Pref abbreviateOutput For example disable abbreviations Pref abbreviateOutput FALSE Enable abbreviations Pref abbreviateOutput TRUE Typeset Math Mode MuPAD can display results of your calculations using different formats By default expressions in outputs use typeset mode and abbreviations solve x 3 x 2 1 O x MaxDegree 3 2 88 Use Different Output Modes where co 29 i l amp 34 108 F To disable the typeset mode clear Notebook gt Typeset Math solve x 3 x 2 1 0 x MaxDegree 3 1 29 sqrt 31 sqrt 108 1 3 GEI ecce 1 29 sqrt
495. r example it generates c1 c 2and so on Higher Order ODEs Insert link target at current cursor position Not Connected Tet Trg 47 INS 4 Inthe Create Link Target dialog box type the name of the link target 2 49 2 Notebook Interface 2 50 5 Create Link Target Create a new link target First Order ODEs a Save the notebook that contains the link target Add Links To associate a link with a link target Open the notebook in which you want to insert a link This notebook can be the same one where you defined the link target or 1t can be any other notebook Select the part of a notebook where you want to create a link Select Insert gt Link from the main menu or use the context menu In the Create Hyperlink dialog box select MuPAD Document and the name of the notebook that you want to link to The Targets list displays all link targets available in the selected notebook In the Targets list select the link target that you want to use If you want to create a link to the top of the notebook select TOP Work with Links Vx Display text ordinary differential equation MuPAD Link to lo Second Motebook mn Document Use absolute path instead of relative path Browse and select Existing File Current documents et amp First Notebook mn Internet Second Motebaok mn Insert Links Interactively To insert a link to a MuPAD notebook interactively without choos
496. r left corner of the scene as well as its width and height may be specified as absolute physical lengths such as Left 3 0 unit mm Bottom 4 5 unit mm Width 10 unit cm Height 4 unit inch With Layout Relative these values may be specified as fractions of the canvas height and width E g 6 123 6 Graphics and Animations Layout Relative Left 0 3 Bottom 0 2 Width 0 5 Height 0 5 1s equivalent to Layout Absolute Left 0 3 canvaswidth Bottom 0 2 canvasheight Width 0 5 canvaswidth Height 0 5 canvasheight where canvaswidth and canvasheight are the physical width and height of the Canvas The following command uses Layout Relative to position 8 scenes by specifying the lower left corner together with their widths and heights as fractions of the canvas dimensions Left1 0 1 Bottom 0 0 Left2 0 6 Bottom2 0 5 Left3 0 75 Bottom3 0 2 plot plot Canvas BorderWidth O 5 unit mm BackgroundColor RGB Grey 6 Widthl Width2 0 60 Height1 plot Scene2d plot Rectangle 1 2 1 2 1 2 1 Left Left1 Bottom Bottom Width Width1 Height Height1 plot Scene2d plot Rectangle 1 2 1 2 1 2 1 Left Left2 Bottom Bottom2 Width Width2 Height Height2 plot Scene2d plot Rectangle 1 2 1 2 1 2 1 Left Left3 Bottom Bottoms Width Width3 Height Height3 Header The Canvas Header Layout Relative Width 11
497. rameter in other calculations check which properties MuPAD assumes to be valid for this parameter The property showprops command returns all assumptions specified for the parameter assume g in R assume h in Z assume t gt 0 property showprops g property showprops h property showprops t ig e IRL h e F LIO J J t The unassume command clears a particular object from all assumptions unassume g unassume h unassume t property showprops g property showprops h property showprops t J J To delete the value of a parameter and clear all assumptions set for this parameter use the delete command delete g h t For example assign the value to the variable h and assume thath gt 0 1 a Use Permanent Assumptions n ie O t 2 2 assume g gt 0O and h gt QO property showprops h h o lt g Ta j gr aL The unassume command clears the assumption but does not remove the value of the variable unassume h 0 property showprops h h The delete command clears the assumption and the value delete h property showprops h h 3 121 3 Mathematics Use Temporary Assumptions 3 122 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Create Temporary Assumptions on page 3 122 Assign Temporary Values to Parameters on page 3 124 Interactions Between Temporary and Permanen
498. range equation m Riccati differential equation y x p x p x g x y xjRiecati 0000 Solve Ordinary Differential Equations and Systems If the solver cannot identify the equation with the type you indicated it issues a warning and returns the special value FAIL ode solve y x y x x y x Type Homogeneous Warning Cannot detect the homogeneous ODE ode homogeneous FAIL Systems of Ordinary Differential Equations To solve a system of differential equations specify the system as a set of equations i y X 920 Z X yIX Z 2X M Call the ode solve function specifying the set of functions y x z x for which you want to solve the system ode solve s y x z x ie 241 oe as exl2 l1bBg sm i a x C34 e 2 9 0 1 035 e 07 U BUT XX y x C34 e 4 1 1035 ex V7 1 Now suppose the system of differential equations appears in a matrix form For example define the system Y 4 Y 8 where A B and Y represent the following matrices Y matrix x t y t A matrix 1 2 1 111 B matrix 1 t The ode solve function does not accept matrices To be able to use this solver extract the components of the matrix and include them in a set Use the op function to extract the equations from the matrix Then use the braces to create a set of the equations You can omit the right sides of equations in which case MuPAD assumes them to be 0 3 49 3 Mathem
499. rary eee 8 2 CAMA ON TET EEN TERCIO TTL lea cee Go ate Do aati Gh ata 8 2 AXIONIS uev ew PEERS BER OES CORE WE XE ENS 8 4 paibliograph y xs Kad Gd RED EGRE eMe BE d EFE 8 4 CALCCOLICS 62 a oS ee Ree ea OA Wes i a wem Se Mn 8 5 EREPOQGUOLIOB ses d E OH aea eleg aS Bet a ee 8 5 Catesory Constructors a 224 0 Aes a RE ex En PNEU 8 6 DIDIOSTSDDV a deret on di eas videt ue vto ave un o usd a odo diera 8 6 COMDINACOVICS 3 uou od uo sed i OR did ERS he To Res 8 7 Functional Programming eee 8 8 Grobner bases eo ao Set ecd s oae d TR AB ced fs 8 10 The import LIDIA 2223 ER 20 4 Eon RU RNC Red Bose 8 11 Integration Utilities 0 000 0 0 0 0 0008 8 12 Junst Steps is ost ca su eee see es Gee eae qu be Es 8 12 Integration by parts and by change of variables 8 14 Linear Algebra Library 0 0000 eee ee 8 16 Introductio x2 aeaa X Bel t dead reda D dee ery 8 16 Data Types for Matrices and Vectors 8 17 Linear Optimization 0 0 0 0 0 0 0 0c cece eee eee 8 23 The qmise LIDEBEV sus a caw Rhee autero EN deo Rd 8 25 Numeric Algorithms Library een 8 26 Orthogonal Polynomials lees 8 27 Proper leS 2 252 DURS SS ee ERE Be ee d eee 8 28 Typeset Symbols in MuPAD sess 8 31 Greek DOettetS us 43 0 vaa E PS o boa Oe ae ds 8 31 Open Face Letters eee 8 33 PRETO VENTE RNC OTT ETT a T T
500. rations that create matrices with elements outside of the ring For example 3 179 3 Mathematics you cannot compute the inverse of the matrix A because the inverse matrix contains noninteger numbers 1 A FAIL Now create the matrix containing the same elements as A but use the constructor for matrices with rational numbers constructorRational Dom Matrix Dom Rational B constructorRational 3 3 1 2 3 2 3 1 93 1 2 l 2 34 2 3 j 312 Compute the inverse of the matrix B 1 B l T ig I 18 is ud i 1 18 3 180 Use Sparse and Dense Matrices Use Sparse and Dense Matrices Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When you use matrices in MuPAD computations both computational efficiency and memory use can depend on whether the matrix 1s sparse or dense Sparse matrices contain a large number of zero valued elements The internal storage of matrices in MuPAD is optimized for sparse data MuPAD saves the nonzero elements and their indices When you use sparse matrices MuPAD assumes that all unspecified elements are zeros When operating on large sparse matrices consider the following methods for better performance To create matrices use the matrix function or the constructor Dom Matrix whenever possible Both the constructor and the function create matrices over the ring of arbitrary MuPAD expressions Dom ExpressionField When
501. re By default the number of digits is 10 DIGITS 10 To save this default value use the Save command at the beginning of the procedure myProcSave proc newDigits x save DIGITS begin DIGITS newDigits print float x end proc After you call the procedure myProcSave MuPAD restores the value of the global variable DIGITS myProcSave 20 PI DIGITS 3 1415976535897932385 10 The combination of save and delete lets you temporarily free the variable for the use inside a procedure For example the procedure cannot use the variable x because the variable has a value assigned to 1t X 10 proc begin solve x 2 x 1 x end proc Error Invalid variable to solve for solve Use the save command to save the original value 10 Then free the variable X using the delete command Procedures X 10 proc save X begin delete x solve x 2 x 1 x end proc J v _1 v3 2 2 2 3 an After the procedure call MuPAD restores the original value of x X 10 The save and delete combination is helpful when you want to use a symbolic variable without any value assigned to it inside a procedure You cannot use local variables for that purpose because a local variable in MuPAD is not an identifier A local variable must have a value assigned to it Also you cannot specify assumptions on local variables and you cannot integrate with respect to local variab
502. re the values of all variables are equal to zero mtaylor exp x y x y Specify all nonzero values of the variables at the point where you want to compute the series expansion Besides numbers and symbolic parameters mtaylor also accepts real positive infinity o and real negative infinity oc mtaylor 1 x 1 2 exp 1 y x y infinity 7 7 2 7 c 4 7 Tot 4 4 Fe aS VER XE d X ul X 2 dE X ee x 2 2 3 Sy 2 163 16y 48y 325 UD8y 2y 4y ny gy 8 10 4 455 3 159 3 Mathematics Control Number of Terms in Series Expansions 3 160 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Taylor series expansions approximate an arbitrary expression with a polynomial The number of terms in a series expansion determines the accuracy of the approximation The number of terms in a series expansion depends on the truncation order of the expansion By default MuPAD computes the first six terms of series expansions taylor exp x x I 3 4 5 M DexeX eX X X O The number of terms includes the terms with coefficients equal to zero For example the taylor series expansion of cos x includes the terms 0 x 0 x and 0 x MuPAD computes these terms but does not display them taylor cos x x L ky e tal ki X oL Suppose you want to approximate an exponential function with the polynomial expression aroun
503. reason this rule is used within the integrator only on certain secure places On the other hand this may also lead to the fact that some integrals cannot be solved directly f sqrt x sqrt 1 sqrt x int f x ve vi ds eval intlib changevar hold int f x t sqrt x t sqrt x 4 ix x i 2 42 rm u i amp h E Y E 7 tye tly te YX lo lye aly r 105 8 15 8 More Information About Some of the MuPAD Libraries Linear Algebra Library 8 16 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Introduction on page 8 16 Data Types for Matrices and Vectors on page 8 17 Introduction An overview of all the available functions can be obtained by using the MuPAD function info Here we see an extract of the functions available in the linear algebra library we do not state the whole output generated by the call info linalg since the library contains more than 40 different functions info linalg Library linalg the linear algebra package Interface linalg addCol linalg addRow linalg adjoint linalg angle linalg basis linalg charmat linalg charpoly linalg col After being exported library functions can also be used by their short notation The function call use linalg exports all functions of linalg After that one can use the function name gaussElim instead of Linalg gaussElim for example Please note that user defined procedu
504. recision prog test float 1 3 0 3333333333 Method Write Single Tests Also using the Method option lets you specify more than one acceptable solution For example if you randomly pick one solution of the following equation you can get any of its four valid solutions i random 1 4 prog test solve x 4 16 0 x i 2 2 2 I 2 I Method in J For further computations restore the default output precision Pref outputDigits UseDigits 5 133 5 Programming Fundamentals Write Test Scripts 9 134 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If you write your code in collaboration with other developers or intend to extend or update 1t later you need to test your code more than once Testing a part of code every time when you or somebody else change it helps you ensure that this part works properly When you plan to test some part of code repeatedly 1t 1s helpful to write a test script and execute it every time when you need to test the code For example create the following procedure f This procedure accepts two numeric arguments a and b compares them and returns the larger number f proc a Type Numeric b Type Numeric begin if a bor a gt b then return a else return b end if end proc Suppose you will likely update this procedure in the future To ensure that the procedure works as expected after all possible updates write
505. reg sampleX sampleY sampleZ sqrt r 2 x1 2 y1 2 x1 y1 r 0 9977031578 0 0519038156 The stats reg function also accepts the nested list points fit stats reg points sqrt r 2 x1 2 y1 2 x1 y1 r 0 9977031578 0 0519038156 3 307 3 Mathematics 3 308 The stats reg function returns the parameters of the model and the quadratic error in a form of a nested list To access the parameters separately use the following commands R op fit 1 1 chi2 op fit 2 0 997703 1578 0 0519038156 Now plot the data and sphere that you used to fit the data on the same plot Rotate the plot to see how the sphere fits the data plot2 plot FunctionS3d sqrt R 2 X 2 y 2 x 1 1 y Leads plot plot1 plot2 1 0 40 Principles of Hypothesis Testing Principles of Hypothesis Testing Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Hypothesis goodness of fit testing is a common method that uses statistical evidence from a sample to draw a conclusion about a population In hypothesis testing you assert a particular statement a null hypothesis and try to find evidence to support or reject that statement A null hypothesis is an assumption about a population that you would like to test It is null in the sense that it often represents a status quo belief such as the absence of a characteristic or the lack of an effect Y
506. res Note Graphical attributes are specified as equations AttributeName AttributeValue Attributes for a graphical primitive may be passed in the call that generates the primitive The help page of each primitive provides a complete list of all attributes the primitive reacts to Note Attributes determining the general appearance of the picture may be passed in the plot call The help pages of plot Canvas plot Scene2d plot Scene3d plot CoordinateSystem2d and plot CoordinateSystem3d respectively provide a complete list of all attributes determining the general appearance Note All attributes can be changed interactively in the viewer Note Presently 2D and 3D plots are strictly separated Objects of different dimension cannot be rendered in the same plot Note Animations are not created frame by frame but objectwise also see section Frame by Frame Animations An object is animated by generating it with a symbolic animation parameter and providing a range for this parameter in the generating call Section Graphics and Animations provides for further details on animations Presently it 1s not possible to add objects to an existing plot However using animations it is possible to let primitives appear one after another in the animated picture See Graphics and Animations 6 83 6 Graphics and Animations 6 84 Some Examples Example 1 We wish to visualize the interpolation of a discrete data sample by cubic sp
507. res that use functions of the library 1inalg should always use the long notation linalg functionname in order to make sure that the unambiguity of the function name is guaranteed The easiest way to define a matrix A is using the command matrix The following defines a 2X2 matrix A matrix 1 2 3 2 Linear Algebra Library 32 Now you can add or multiply matrices using the standard arithmetical operators of MuPAD A A 2 A 1 A ba ta I C ba md e un lm Further you can use functions of the linalg library linalg det A 4 The domain type returned by matrix is Dom Matrix domtype A Dom Matrix which is introduced in the following section Data Types for Matrices and Vectors The library 1inalg is based on the domains Dom Matrix and Dom SquareMatrix These constructors enable the user to define matrices and they offer matrix arithmetic and several functions for matrix manipulation A domain created by Dom Matrix represents matrices of arbitrary rows and columns over a specified ring The domain constructor Dom Matrix expects a coefficient ring of category Cat Rng a ring without unit as argument If no argument is given the domain of matrices 1s created that represents matrices over the field of arithmetical expressions 1 e the domain Dom ExpressionField Be careful with calculations with matrices over this coefficient domain because their entries usually do
508. resent the rows of the original matrix At the same time coerce converts the array A to a flat list LM coerce M DOM LIST LA coerce A DOM LIST Both new objects belong to the basic domain of lists DOM LIST domtype LM domtype LA DOM LIST DOM LIST For further computations delete the 1dentifiers L S M A LM and LA delete L S M A LM LA Use the expr Function To convert an element of a library domain to an element of a basic kernel domain use the expr function This function does not allow you to select the basic domain to which it converts an object If the conversion to basic domains 1s not possible the function returns FAIL The expr function tries to find the simplest basic domain to which it can convert a given object The function also can convert an element of a more complicated basic domain to the simpler basic domain For example 1t converts the polynomial represented by a single variable x to the identifier x y poly x expr y Convert Data Types poly x x The original object y belongs to the domain of polynomials The result of conversion belongs to the domain of identifiers DOM IDENT domtype y domtype expr y DOM POLY DOM IDENT If you call the expr function for a more complicated polynomial the function converts that polynomial to the expression p poly x 2 x 2 expr p E EN poly x x 2 x 7 x 4 x 2 Again the original polynomial belongs to
509. rformance bottlenecks in your code 9 95 5 Programming Fundamentals Measure Time 9 96 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Calls to MuPAD Processes on page 5 96 Calls to External Processes on page 5 99 Calls to MuPAD Processes The simplest tool you can use to estimate code performance is the time function This function measures the running time of your code snippet The time function does not count the time spent outside of MuPAD processes external function calls or processes running in the background do not affect the results of time The function returns results measured in milliseconds The following example demonstrates different algorithms implemented for the same task The task 1s to check whether each integer from 1 to 1000 appears 1n a 1000x1000 matrix of random integers To create a 1000x1000 matrix of random integers use linalg randomMatrix matrixSize 1000 M linalg randomMatrix matrixSize matrixSize Dom Integer The direct approach 1s to write a procedure that checks every element of a matrix proceeding row by row and column by column f proc M n x begin for j from 1 to n do for k from 1 to n do if M j k x then return TRUE end if end for end for return FALSE Measure Time end proc Call the procedure f 1000 times to check if each number from 1 to 1000 appears in that matrix g proc begin f M matr
510. ributes such as axes style the visibility of grid lines 1n the background etc are associated with the whole scene rather than with the individual primitives These attributes may be included in the plot call plot g p t GridVisible TRUE Advanced Plotting Principles and First Examples As explained in detail in section The Full Picture Graphical Trees the plot command automatically embeds the graphical primitives in a coordinate system which in turn is embedded in a graphical scene which 1s drawn inside a canvas The various attributes associated with the general appearance of the whole picture are associated with these erouping structures a concise list of all such attributes 1s provided on the help pages of plot Canvas plot Scene2d plot Scene3d plot CoordinateSystem2d and plot CoordinateSystem3d respectively The object browser provided by the MuPAD graphics tool allows to select each primitive in the plot After selection the attributes of the primitive can be changed interactively in the property inspector see section Viewer Browser and Inspector Interactive Manipulation Next we wish to demonstrate a animation It is remarkably simple to generate an animated picture We want to let the point x at which the tangent is added move along the graph of the function In MuPAD you do not need to create an animation frame by frame Instead each primitive can be told to animate itself by simply defining it with a
511. rical Avoid storing lots of data 1n the history table If you suspect that the history table uses a significant amount of memory clear the history table or reset the engine For information about the history table see History Mechanism Avoid running large background processes including additional MuPAD sessions at the same time as you execute code in MuPAD Display Memory Usage Display Memory Usage Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Use the Status Bar on page 5 111 Generate Memory Usage Reports Periodically on page 5 112 Generate Memory Usage Reports for Procedure Calls on page 5 113 Use the Status Bar The amount of memory available on your computer can greatly affect your symbolic computations First some computations cannot run without enough memory In this case you get the out of memory error Second if the MuPAD engine uses virtual memory by swapping data on and off the storage device computations can run much slower than they run if the system does not use virtual memory Observing memory usage when executing your code can help you understand whether your code uses available memory efficiently The simplest tool for observing the memory usage 1s the status bar You can find the status bar at the bottom of a MuPAD notebook If you do not see the status bar select View gt Status Bar The far left end of the status bar displays the curren
512. rint functions display outputs differently The print function uses the typeset mode which is how mathematical expressions are typically written on paper The fprint function uses the ASCII format For information about different output modes available in MuPAD see Using Different Output Modes Evaluate at a Point Evaluate at a Point Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To evaluate an expression for particular values of identifiers use the evalAt function or its shortcut For example evaluate the following expression at the point X 0 diff x 2 exp sin x x 3 x 0 6 In MuPAD all computations are symbolic by default For example evaluating the previous expression at X 1 returns the exact symbolic result diff x 2 exp sin x x 3 x 1 ray sin 1 un l ray 3X2 _ain 1 r433 sinll ray anll pay 5 cos 1 e 17 6 e cin 1 6 cos 1 e V cos 1 e l 3 cos 1 e sin 1 To get a numeric approximation of the result use the floating point number to specify the point at which you want to evaluate an expression diff x 2 exp sin x X 3 x 1 0 4 180173868 Alternatively you can evaluate an expression at a point by using the subs function with the EvalChanges option For expressions that contain only free variables evalAt and subs return identical results diff sin x cos x 2 x 2 x PI subs diff sin x cos x 2 x 2
513. rithmetic average of the two central elements of a sorted data sample z 1 1 1 100 100 100 medianZ stats median z Averaged medianz 101 Nevertheless the median is not always the best choice for measuring central tendency of a data sample For example the following data sample distribution has a step in the middle z 1 1 1 2 100 100 100 medianZ stats median z median 2 3 270 Compute Measures of Dispersion Compute Measures of Dispersion Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The measures of dispersion summarize how spread out or scattered the data values are on the number line MuPAD provides the following functions for calculating the measures of dispersion These functions describe the deviation from the arithmetic average mean of a data sample The stats variance function calculates the variance l X H x _ x where x is the arithmetic mean of the data sample x xs Xn n lX i l e The stats stdev function calculates the standard deviation i gt Xn ES n x E x y where X 1s the arithmetic average of the data sample x x i I f The stats meandev function calculates the mean deviation l y n Is _ x where 1s the arithmetic average of the data sample x xs Xn i I The standard deviation and the variance are popular measures of dispersion The standard deviatio
514. rization function Therefore the symbolic function can return different results for the same matrix linalg factorLU T 1000 345 0 n1 2 z 100 O12 5 210 000 6 301 X00 0 12 QR Decomposition The QR factorization expresses an mxn matrix A as follows A Q R Here Q is an mxm unitary matrix and R 1s an mXn upper triangular matrix If the components of A are real numbers Q is an orthogonal matrix To compute the QR decomposition of a matrix Compute Factorizations Numerically numerically use the numeric factorQR function For example create the following 3X3 Vandermonde matrix V linalg vandermonde 2 PI 1 3 1 2 4 Ea Al Dji When computing the QR decomposition of that matrix symbolically you get the following long result Q R linalg factorQR V a x ll N m o 2 3 21 3 3 T 1 6 34 EE v 3 3 mj GN on 37z 7x 2 3 js gyf T1 T v3 73 9 215 3x 7x42 0 i 7 9 3 8 1 505 0 1 x 4 f 4 0 G JF 3 5 5 l6s 13 e438 4 i 2040 A 3 F a l MR 25 6122 28 x 42 55 9 2 44 To get a shorter answer approximate this result by floating point numbers 3 223 3 Mathematics Q R float Q R 0 5773502692 0 08763169824 0 8117803595 0 5773502092 0 0592005045 O0 4817814500 0 5773502092 0 7408382028 0 3299982029 1 997275809 0 773052174 1 732050808 3 1
515. rlte Expressions in Terms of Other Functions on page 3 100 Most mathematical expressions can be represented in different but mathematically equivalent forms Some of these forms might look simpler for example they can be visibly shorter However you might prefer other forms of the same expression for numeric computations There is no general rule as to which form of an expression is the simplest When solving a particular problem you can choose the simplest form of an expression for this problem Besides the general simplification functions simplify and Simplify MuPAD provides a set of functions for transforming mathematical expressions to particular forms The following table helps you choose the function for transforming your expression to the appropriate form To see a short description of a function and a set of examples click the link in the left column To see the detailed help page for a function click the function name in the right column Collect terms with the same powers Combine terms of the same algebraic structure 3 93 3 Mathematics 3 94 Type of Transtornos SS mn 000000 Simplify radicals in an expression Separate the real and imaginary parts of a complex rectform expression Rewrite an expression in terms of a specified target rewrite function Collect Terms with Same Powers If a mathematical expression contains terms with the same powers of a specified variable or expression the collect function r
516. rn for the inverse Fourier transform ifourier F s s t fourier Fis s f js To add the corresponding pattern for the inverse Fourier transform use the ifourier addpattern function For example add the pattern f t for the inverse Fourier transform of F s ifourier addpattern F s s t f t ifourier F s s t fu Using the same method you can add your own patterns for the Laplace transform inverse Laplace transform Z transform and inverse Z transform Use the following functions to add patterns for computing these transforms laplace addpattern to add a pattern for computing the Laplace transform ilaplace addpattern to add a pattern for computing the inverse Laplace transform ztrans addpattern to add a pattern for computing the Z transform iztrans addpattern to add a pattern for computing the inverse Z transform Use Custom Patterns for Transforms Overwrite Existing Patterns You can introduce a new transform pattern for the expression for which MuPAD already has a pattern In this case the system replaces the standard existing pattern with the new one For example the Laplace transform of the hyperbolic sine function has a standard pattern implemented in MuPAD laplace sinh t t s s l Suppose you want to change this pattern Use the laplace addpattern function to replace the existing standard pattern with your custom pattern laplace addpattern sinh t t s 1 2
517. rns a certificate of primality certificate numlib proveprime 1299709 1299709 15 2 2 2 2 2 107 379 700619 67686 0 796444 107 379 Generated primality certificates provide all data that you need for proving primality of a number by the Atkin Goldwasser Kilian Morain algorithm You can substitute the numbers into the algorithm and verify the primality of a number The numlib checkPrimalityCertificate function can verify the certificate for you numlib checkPrimalityCertificate certificate TRUE 3 321 3 Mathematics Modular Arithmetic 3 322 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Quotients and Remainders on page 3 322 Common Modular Arithmetic Operations on page 3 324 Residue Class Rings and Fields on page 3 325 Quotients and Remainders Computing the quotient and the remainder of the division of two integers is a common operation in number theory The MuPAD standard library provides the div function for computing the quotient of a division The standard library also provides the modulo operator mod for computing the remainder of a division 17 div 3 17 mod 3 MuPAD supports two definitions of the remainder of a division The first definition states that the remainder is always a nonnegative number To compute the remainder by this definition use the positive modulo function modp or the default modulo operator mod 123 mod 5 mod
518. rotation to create an ellipse with a different orientation center 1 2 ellipse plot Ellipse2d 2 1 center plot plot Rotate2d PI 4 center ellipse E 1 2 3 Transform objects can be animated We build a group consisting of the ellipse and its symmetry axes An animated rotation is applied to the group g plot Group2d ellipse plot Line2d plot Line2d plot Line2d plot Line2d center center 1 2 center 2 center center 1 2 center 2 center center 1 center 2 1 center center 1 center 2 1 LN ji plot plot Rotate2d a center a 0 2 PI g 6 160 Transformations Objects inside an animated transformation can be animated too The animations run independently and may be synchronized via suitable values of the TimeRange as described in section Advanced Animations The Synchronization Model on page 6 140 We generate a sphere s of radius r with center c cx cy c We wish to visualize the tangent plane at various points of the surface We start with the tangent plane of the north pole and rotate it around the y axes 1 e along the line with zero longitude by the polar angle 0 for the first 3 seconds Then 1t 1s rotated around the z axis 1 e along the line with constant latitude by the azimuth angle We end up with the tangent plane at the point x c cos sin 0 y c sin sin 0 z c cos 0 The two rotations are realized as a nested animati
519. s infinity Real positive infinity complexInfinity Infinite point of the complex plane RD INF Real positive infinity used in floating point intervals RD NINF Real negative infinity used in floating point intervals Boolean Constants MuPAD uses a three state logic with the Boolean constants TRUE FALSE and UNKNOWN You can use these constants 1n computations MuPAD can return these constants as a result of computations Special Values The following objects in MuPAD represent special values You can use these special values in computations MuPAD can return these values as a result of computations I Imaginary unit V Ex NIL Null object of the domain DOM NIL MuPAD uses this object to indicate missing objects explicitly null Null void object of the domain DOM NULL This object does not produce any visible output MuPAD removes this object from data structures such as sequences lists sets and so on undefined Undefined value Mathematical Constants Available in MuPAD RD NAN Undefined value used in floating point intervals If you use typeset mode MuPAD displays this value as NaN in output regions FAIL Failure object of the domain DOM FAIL Special Sets MuPAD provides the following predefined sets and lets you use them 1n computations For example you can use these predefined sets to compute intersections differences and unions or to make assumptions MuPAD can use these sets to return results of comp
520. s 6 48 Once the plot 1s created the first frame of the picture appears as a static plot After double clicking on the picture the animation starts The usual controls for stopping going to some other point in time etc are available The default number of frames of the animation 1s 50 If a different value 1s desired just pass the attribute Frames n where n is the number of frames that shall be created plotfunc3d sin a sin x cos a cos y x 0 2 Pl y 0 2 PI a 0 2 PI Frames 32 Easy Plotting Graphs of Functions Apart from the color specification or the Frames number there is a large number of further attributes that may be passed to plotfunc3d Each attribute is passed as an equation AttributeName AttributeValue to plotfunc3d Here we only present some selected attributes Section Attributes for plotfunc2d and plotfunc3d provides further tables with more attributes plotfunc3d attribute name possible values example Height 8 unit cm physical height of 80 unit mm the picture Width 12 unit cm physical width of the 120 unit mm picture Footer footer text no footer Header header text no header Title title text u no title 6 49 6 Graphics and Animations 6 50 attribute name possible values example TitlePosition real value real coordinates of the value lower left corner of the title GridVisible TRUE FALSE visibility of major grid lines in all dire
521. s 6 62 and plotfunc3d f x y x xmin xmax y ymin ymax ZRange zmin zmax 1s equivalent to plotfunc3d f x y x xmin xmax y ymin ymax ViewingBoxZRange zmin zmax Here 1s a table of the most important attributes for arranging coordinate axes In the interactive object browser you will find them under CoordinateSystem2d CS2d and CoordinateSystem3d CS3d respectively Attributes for Axes attribute name possible values browser entry example Automatic axes type Automatic CS2d 3d Boxed Frame Origin AxesVisible TRUE FALSE visibility of all TRUE axes XAxisVisible TRUE FALSE visibility of the TRUE IM X axis YAxisVisible TRUE FALSE visibility of the TRUE CS2d 3d y axis ZAxisVisible TRUE FALSE visibility of the TRUE CS3d Z axis AxesTitles string titles of the axes X y CS2d string 2D AxesTitles string titles of the axes X Z CS3d string string Easy Plotting Graphs of Functions attribute name pee values browser entry example AxesTitleAligiBegin Center alignment for all End CS2d End axes titles AxesTitleAligiBegin Center alignment for all Center CS3d End axes titles XAxisTitleAliqBegin Center alignment for End CS2d End the x axis title XAxisTitleAli Begin Center alignment for Center CS3d End the x axis title YAxisTitleAliq Begin Center alignment for End CS2d End the y axis title YAXisTitleAliqBegin Center alignment
522. s Use Custom Patterns for Transforms Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Add New Patterns on page 3 257 Overwrite Existing Patterns on page 3 259 Add New Patterns MuPAD provides common patterns for integral and Z transform computations and the corresponding inverse transforms computations Also the system lets you add your own patterns for the transforms Note MuPAD does not save custom patterns permanently To use a custom pattern add it 1n the current MuPAD session The following example demonstrates how to add the pattern for the Fourier transform of the function f t By default there 1s no pattern for f t The fourier function returns the unresolved transform fourier f t t s fourier f t t 5 Suppose you want to add the pattern F s for the Fourier transform of the function f t To add a new pattern for the Fourier transform use the fourier addpattern function fourier addpattern f t t s F s Now when you compute the Fourier transform of f t MuPAD returns F s fourier f t t s 3 297 3 Mathematics 3 258 F s MuPAD can use the new pattern indirectly fourier sin t 2 f 10 t 33 t s ri QUEM e br a b ee z7 ial a ra c Lf ey ba P ha LEM QUUM P ha po When you add a pattern for the Fourier transform MuPAD does not automatically add the patte
523. s Use this mode only for debugging your code Always restore testargs to its default value FALSE after you finish debugging testargs FALSE 9 89 5 Programming Fundamentals Write Error and Warning Messages Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When writing a procedure in MuPAD you can include error and warning messages in your procedure If the system encounters an error while executing a procedure it terminates execution of the procedure and displays an error message If the system encounters a warning it prints the warning message and continues executing the procedure You can specify your own error and warning messages The error function terminates execution of a current procedure with an error For example the following procedure converts the number of a month to the name of a month The procedure checks the type of its argument and accepts only positive integer numbers Since there are only 12 months in a year the procedure must also ensure that the number does not exceed 12 The error function lets you terminate the procedure call with an appropriate error message if the number is greater than 12 monthNumberToName proc n Type PosInt begin if n gt 12 then error Invalid number The number must not exceed 12 end if case n of 1 do return January of 2 do return February of 3 do return March of 4 do return April of 5 do return May of 6 do return Jun
524. s between labeled ticks along all axes XTicksBetween integer gt 0 number 1 CS2d 3d of smaller T e amp 6 Graphics and Animations 6 66 attribute name possible values example unlabeled ticks between labeled ticks along the x axis YTicksBetween integer gt 0 number of smaller unlabeled ticks between labeled ticks along the y axis number of smaller unlabeled ticks between labeled ticks along the Z axis ZTicksBetween integer gt 0 orientation and style of tick labels along all axes TicksLabelSty Diagonal Horizontal Shifted Vertical XTicksLabelSt Diagonal Horizontal Shifted Vertical YTicksLabelStyY Diagonal Horizontal Shifted Vertical ZTicksLabelSt Diagonal Horizontal Shifted Vertical orientation and style of tick labels along the x axes orientation and style of tick labels along the y axis orientation and style of tick labels along the Z axis Ses 1 CS2d 3d Horizontal l TicksAt XTicksAt YTicksAt ZTicksAt TicksLength TicksLabelFon Easy Plotting Graphs of Functions ossible values browser entr P y example tick1 ticks set by the CS2d 3d tick2 user valid for where tick i allaxes is a real value the position or an equation position label string such as 3 14 pi see TicksAt ticks along the CS2d 3d x axis set by the user see TicksAt ticks along the CS2d 3d y axis set by the
525. s you to hide irrelevant intermediate results For example assign the factorial of 123 to the variable a and the factorial of 132 to the variable b In MuPAD the assignment operator is 7 the equivalent function is assign The factorial operator is the equivalent function is f act Terminate these assignments with colons to suppress the outputs Here MuPAD displays only the result of the division a b a i 123 b 132 a b l 9206492916741120000 delete a b You can enter several commands in an input region separating them by semicolons or colons Evaluate Mathematical Expressions and Commands atb aD a b To start a new line in an input region press Ctrl Enter or Shift Enter Working with Multiple Input Regions If you have several input regions you can go back to previous calculations and edit and reevaluate them If you have a sequence of calculations in several input regions the changes in one region do not automatically propagate throughout other regions For example suppose you have the following calculation sequence y exp 2 x If you change the value of the variable y the change does not automatically apply to the variable z To propagate the change throughout different input regions select Notebook from the main menu From here you can e Select Evaluate to evaluate calculations in one input region Select Evaluate From Beginning to evaluate calculations in the input regions from the beginning
526. s Color The MuPAD plot library knows 8 different types of colors The attribute PointColor refers to the color of points in 2D and 3D of type plot Point2d and plot Point3d respectively The attribute LineColor refers to the color of line objects in 2D and 3D This includes the color of Function graphs in 2D curves in 2Dandin 3D polygon lines in 2Dandin 3D etc Also 3D objects such as function graphs in 3D parametrized surfaces etc react to the attribute LineColor it defines the color of the coordinate mesh lines that are displayed on the surface The attribute FillColor refers to the color of closed and filled polygons in 2D and 3D as well as hatched regions in 2D Further it sets the surface color of function graphs in 3D parametrized surfaces etc This includes spheres cones etc The primitives also accept the attribute Color as a shortcut for any one of these colors Depending on the primitive either PointColor LineColor or FillColor is set with the Color attribute RGB Colors MuPAD uses the RGB color model 1 e colors are specified by lists r 9 b of red green and blue values between 0 and 1 Black and white correspond to 0 0 0 and 1 1 1 respectively The library RGB contains numerous color names with corresponding RGB values RGB Black RGB White RGB Red RGB SkyBlue 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 8 1 0 6 171 6 Graphics and Animations You may list all color
527. s expansion of the solution Expand the solution around the point where one of the variables is 0 System of polynomial equations numeric polysysnoots Arbitrary univariate equation numeric realroot numeric realroots S System of arbitrary equations Ordinary differential equation or a system ode solve numeric odesolve of ODEs Ordinary differential equation or a numeric odesolve2 system of ODEs Call this function to get a procedure representing the numeric results instead of getting the numeric approximation itself Ordinary differential equations on Geometric homogeneous manifolds embedded in the space of nxm matrices Linear congruence equation numlib lincongr Quadratic congruence equation numlib msqrts Polynomial equation Call this function to numlib mroots find modular roots 3 21 3 Mathematics Solve Algebraic Equations and Inequalities Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Specify Right Side of Equation on page 3 28 Specify Equation Variables on page 3 29 Solve Higher Order Polynomial Equations on page 3 30 Find Multiple Roots on page 3 32 Isolate Real Roots of Polynomial Equations on page 3 32 Solve Inequalities on page 3 33 Specify Right Side of Equation The solver accepts both equations and expressions If you call solve for an expression the command assumes the right side to be 0 S1 solve x 3
528. s location is available inside the notebook as the environment variable NOTEBOOKPATH If you wish to save your plot in the same folder as the notebook you may call plot primitives OutputFile NOTEBOOKPATH mypicture xvz Apart from saving files as xml data MuPAD pictures can also be saved in a variety of standard graphical formats such as jpg eps svg bmp etc In batch mode the export is triggered by the OutputFile attribute in the same way as for saving in xml format Just use an appropriate extension of the filename indicating the format The following commands save the plot in four different files in jpg eps svg and bmp format respectively plot primitives OutputFile mypicture jpg plot primitives OutputFile mypicture eps plot primitives OutputFile mypicture svg plot primitives OutputFile mypicture bmp On Windows systems an animated MuPAD plot can be exported to avi format plot plot Function2d sin X a X 0 2 PI a 0 5 OutputFile myanimation avi If no file extension is specified by the file name the default extension XVC is used 1 e compressed xml data are written 6 177 6 Graphics and Animations 6 178 In addition to OutputFile there 1s the attribute OutputOptions to specify parameters for some of the export formats The admissible value for this attribute 1s a list of equations OutputOptions lt ReduceTo256Colors b gt DotsPerInch n5 Quality n
529. s not state that the system of linear congruences is solvable only if numbers m m are pairwise coprime If these numbers are not pairwise coprime the system still can have a solution Even if the numbers are not pairwise coprime the solution is still unique up to multiples of the least common multiple ilcm of m ms Mn numlib ichrem 5 7 9 6 10 11 12 13 3945 If the numbers are not pairwise coprime a system of linear congruences does not always have a solution For unsolvable systems numlib ichrem returns FAIL numlib ichrem 5 1 9 6 10 15 12 13 FAIL Congruences Modular Square Roots Compute Modular Square Roots To compute modular square roots x lt m of the equation x a mod m use the numlib msqrts function Here the integers a and m must be coprime For example solve the congruence equation x 13 mod 17 numlib msqrts 13 17 8 9 If the congruence does not have any solutions numlib msqrts returns an empty set numlib msqrts 10 17 If a and m are not coprime numlib msqrts errors numlib msqrts 17 17 Error Arguments must be relative prime numlib msqrts If numlib msqrts cannot solve a congruence try using the numlib mroots function For more information see General Solver for Congruences Use Solvability Tests Legendre and Jacobi Symbols The Legendre symbol determines the solvability of the congruence x a mod m where m is a prime You can c
530. s of a category A category adds a level of abstraction because it postulates conditions which must hold for a domain in order to become a valid member of the category Operations may be defined for all members of a category based on the assumptions and basic operations of that category as long as they make no assumptions about the representation of the elements of the domains that belong to the category Categories may also depend on parameters and are created by category constructors Attributes of domains and categories are defined in terms of so called axioms Axioms state properties of domains or categories This paper describes the category constructors which are part of the Cat library package The categories defined so far in general follow the conventions of algebra There are some properties of the categories which differ from the classical nonconstructive theory of algebra because these properties are not constructive or can not be constructed efficiently The category hierarchy of the Cat package 1s quite similar to part of the category hierarchy of AXIOM JeSu see Da Tr for a description of the basic categories of Scratchpad the predecessor of AXIOM 8 5 8 More Information About Some of the MuPAD Libraries Category Constructors For each category constructor only the entries defined directly by the constructor are described Entries which are inherited from super categories are not described Please note that most
531. se a set as the function in a function call MuPAD returns the set of appropriate function calls sin cos tan f x sin cos tan f 0 1 cos x f x sin x tan x 10 09983341665 0 1003346721 0 9950041653 f 0 1 To apply a function to all elements of a set use the function map map x 0 1 1 5 PI sin 0 0 09983341665 sin E sin x 23 To extract elements with particular properties from a set use the select command 9 21 5 Programming Fundamentals 9 22 select a x b a x 1 contains x 1 x a b x To find the intersection of sets use the intersect command 9 is 41 243 S intersect 2 3 4 phe tna Lag aT To divide a set into three sets according to particular properties use the split command split a x b a x 1 contains x The resulting three sets contain Elements with the required properties Elements without the required properties Elements for which the required properties are unknown Add Replace or Remove Set Elements To add elements to a set 1 Create a set containing the elements you want to add 2 Combine the old and the new sets using the union command eet fa Db Oki set set union d e f Ig bc de f iG 5 c d e fj To replace an element of a set use the subs command The new element does not necessarily appear in place of the old one Sets set4 a b 2 6 7 subs set4 a 1 12
532. sin 2 k 1 x 2 k 1 k 1 floor n M v sin x 2 k 1 a J F m k 2k l First we use plotfunc2d and the sequence operator to plot the first 5 partial sums into the same coordinate system and switch off the legend which 1s not useful for this application plotfuncad f n n 1 5 LegendVisible FALSE 6 89 6 Graphics and Animations 6 90 oo re This plot clearly shows what is known as Gibbs phenomenon At the discontinuities of the step function the approximation overshoots Plotting more approximations simultaneously is going to create a too crowded plot to be of use so to show that using more terms in the sum does not help against Gibbs phenomenon we revert to animations to show the first 30 partial sums this is one of the reasons we used floor n above plotfunced f_n x 5 5 n 1 30 Frames 15 Advanced Plotting Principles and First Examples 5 E Another possibility of showing the convergence behavior is to create a 3D plot with the second ordinate being the number of terms used in the approximation plotfunc3d f n x 5 5 n 1 30 Submesh 5 1 FillColorType Rainbow 6 91 6 Graphics and Animations 6 92 The Full Picture Graphical Trees The Full Picture Graphical Trees Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB For a full understanding of the interactive features of the viewer to be d
533. singularities are found in the function an automatic clipping is called trying to restrict the vertical viewing range in some way to obtain a reasonably scaled picture This is a heuristic approach that sometimes needs a helping adaptation by hand In the following example the automatically chosen range between y 1 and y 440 in vertical direction 1s suitable to represent the 6th order pole at x 1 but it does not provide a good resolution of the first order pole at x 1 plotfunc2d 1 x 1 x 1 6 x 2 2 Easy Plotting Graphs of Functions 240 220 200 180 160 140 120 100 2 0 1 5 4 0 05 5 05 1 0 1 5 20 40 There is no good viewing range that 1s adequate for both poles because they are of different order However some compromise can be found We override the automatic viewing range suggested by plotfunc2d and request a specific viewing range in vertical direction via ViewingBoxYRange plotfunc2d 1 x 1 x 1 6 x 2 2 ViewingBoxYRange 10 10 6 39 6 Graphics and Animations Y 40 iU 0 5 0 5 1 0 1 5 2 0 5 ii 10 The values of the following function have a lower bound but no upper bound We use the attribute ViewingBoxYRange Automatic 10 to let plotfunc2d find a lower bound for the viewing box by itself whilst requesting a specific value of 10 for the upper bound plotfunc2d exp x sin PI x x 1 2 X
534. sion MuPAD provides the Stats reg function This function uses the least squares approach for computing the regression stats reg chooses the parameters p p by trying to minimize the quadratic error x p s BU e ly f P SENE UN NM 2 t Here xj is the ith measurement of the independent variable x The stats reg function also can perform weighted least squares nonlinear regression By default weights are equal to 1 stats reg returns a list of optimized parameters p Pn and the minimized value of the quadratic error for the specified model Suppose you want to find a model for the following data sampleX 1 2 3 4 5 6 7 8 9 sampleY 36 97666099 54 14911101 131 3852077 30 43939553 202 2004454 129 5801972 321 0663718 411 3959961 929 597986 Plotting the data can help you choose the model ploti plot Scatterplot sampleX sampleY LinesVisible FALSE plot plot1 3 303 3 Mathematics 3 304 B00 200 FOO 600 500 The scatter plot clearly shows that linear models do not fit the data The dependency looks similar to exponential Therefore you can try to fit the data to different models involving exponential functions Suppose you want to try fitting the data to the 1 2 xX expression faq xl fit stats reg samplex sampleY pi p2 2 exp x1 x1 x1 pt p2 87 35956975 0 9696856368 26612 78899 The stats reg
535. so that all objects including graphics and calculation regions fit in the page width F Selects page orientation Lets you choose portrait or landscape layout G Opens the Page Format dialog box for adjusting page settings When you modify settings in the Format dialog box MuPAD applies the new settings not only to a preview but also to the notebook itself If later you close the Print Preview window and save the notebook MuPAD saves the new page settings with the notebook See Changing Page Settings for Printing for details H Lets you view multiple pages in the Print Preview window 2 120 Use Print Preview Li Show single page Show facing pages Show overview of all pages The option Show facing pages displays even pages on the left and odd pages on the right If you select this option to display a document with multiple pages the first page appears in the top right corner 2 121 2 Notebook Interface Change Page Settings for Printing Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If you do not specify page format MuPAD uses the page settings of your default printer If you do not install a printer the default page size is A4 Note that A4 is narrower and longer than the Letter paper size M0 deo O 8 3 X 11 7 in 8 5X 1lin 210 X 297 mm 216 X 279 mm To change the page format for your notebook 1 Select Format Page 2 Inthe Page Format dialog box specif
536. solving systems of equations represented by sparse matrices avoid computing inverse matrices Instead use Linalg matlinsolve to find exact symbolic solutions or numeric matlinsolve to find numeric approximations Avoid creating large empty matrices and then using indexed assignments for nonzero values Indexed assignments in MuPAD are expensive operations Specifying the elements at the same time when you create a matrix is more efficient For example the command matrix 10 10 1 2 1 Banded is more efficient than A matrix 10 10 1 for i from to 10 do Afi i 2 end for for i from 1 to 9 do A i i 1 1 Ali 1 21 29 1 end for Dense matrices contain only a few or no zero valued elements MuPAD provides a special matrix domain for dense matrices To create such matrices use the densematrix 3 181 3 Mathematics function which is a shortcut for the constructor Dom DenseMatrix You also can use the constructor itself For matrices of the Dom DenseMatrix domain indexed reading and writing is faster than for matrices of the Dom Matrix domain 3 182 Compute with Matrices Compute with Matrices Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Basic Arithmetic Operations on page 3 183 More Operations Available for Matrices on page 3 184 Basic Arithmetic Operations When performing basic arithmetic operations on matrices
537. ssion rational expression Glossary The help page of a system function only documents the admissible arguments that are of some basic type provided by the MuPAD kernel If the system function f say 1s declared as overloadable the user may extend its functionality He can implement his own domain or function environment with a corresponding slot f An element of this domain is then accepted by the system function f which calls the user defined slot function Syntactically a polynomial such as poly x 2 2 x 1s an object of type DOM POLY It must be created by a call to the function poly Most functions that operate on such polynomials are overloaded by other polynomial domains of the MuPAD library This 1s an arithmetical expression in which symbolic variables and combinations of such variables only enter via positive integer powers Examples are X 2 20r X y z 1 2 This is an arithmetical expression in which symbolic variables and combinations of such variables only enter via integer powers Examples are X 2 x 2or X y 1 z 1 2 Every polynomial expression is also a rational expression but the two previous expressions are not polynomial expressions 7 5 More Information About Some of the MuPAD Libraries Abstract Data Types Library on page 8 2 Axioms on page 8 4 e Categories on page 8 5 Combinatorics on page 8 7 Functional Programming on page 8 8 Gr
538. st possible building blocks this 1s a real disadvantage Nevertheless for many tasks the benefits of this approach prevail over this disadvantage especially if the utility function must be able to modify the arguments of the calling function 9 163 5 Programming Fundamentals 9 164 Utility Functions Outside Procedures You can define utility functions outside a procedure For example define the utility function helper in the function environment f f funcenv proc arguments LOGHL srei begin code using f helper end f helper proc begin end This approach does not require you to define the utility function in the function environment of the procedure that uses it Defining a utility function in the function environment only helps you clarify to people reading your code that you intend to call f helper primarily or solely within f If you later decide to use f helper in another procedure you can move the utility function to a more generic utility library Again this recommendation only helps you improve readability of your code Defining utility functions outside the procedure that uses them does not hide utility functions Therefore this approach lets you Test utility functions directly Define a utility function and a function that uses it in different source files Usethe same utility function for different procedures Defining utility functions outside the procedure that uses t
539. statements for a fixed number of iterations The loop starts with the command for and ends with end_for or just end MuPAD executes all statements between these two words as many times as you specify For example compute the factorial of an integer using the loop X i 1 for i from 1 to 5 do X i x i end for 120 More Efficient Alternative to for Loops You often can speed up the execution of MuPAD code by replacing for loops with the sequence generator For example instead of the loop X i 1 for i from 1 to 10 do Loops E IW Cx end for 3628800 use the statement U i is1 10 3078800 Control Step Size and Count Up and Down By default the loop increments the value of a counter by 1 in each step You can change the step size for i from 1 to 3 step 1 2 do print i end for b t a Las ba taj LA To count backwards decreasing the value of a counter with each step instead of to use the keyword downto for i from 3 downto 1 do print i end_for 4 9 4 Programming Basics Use Mathematical Structures in for Loops MuPAD supports the use of structures such as lists and matrices in for loops for i in 1 4 a b do print i 2 end for l bi ba Dpi S i 0 for i in linalg hilbert 3 do S i S 1 2 end_for 1199 600 Use Loops with Conditions while and repeat Loops Condition at the Beginning while Loops MuPAD supports the use of loops with logical cond
540. sts addition substraction multiplication division and power The lists you operate on must contain an equal number of entries MuPAD forms a new list containing the entries of the existing lists combined pairwise list 9 a b c list2 d e f list list2 115811 1181012 listi1 list2 When you combine a list and a scalar MuPAD combines a scalar with each entry of a list For example list a b c list1 a iisti listi a 5 a a 5 b a 5 c a 5 9 14 Lists Note Combining a scalar and a list differs from combining a scalar and a matrix When you add a scalar to a matrix MuPAD adds the scalar multiplied by an identity matrix to the original matrix For example define a matrix M as follows Add the variable a the matrix M M matrix 1 2 3 4 5 6 7 8 9 M Now define the rows of the matrix M by the following three lists Add the variable a to each list MuPAD adds the variable a to each entry of the three lists listi fe Pty 2 3 list2 4 5 6 list3 7 8 9 matrix list1 a list2 a list3 al a 4 a 5a ax7as 8a49J When you combine a scalar and an empty list the result is an empty list 2 MuPAD lets you combine nested lists a b c d 1 a b c d 1 2 3 a 1 641 c 1 d 4 1 9 15 5 Programming Fundamentals 9 16 To combine lists with unequal numbers of entries use the zip comm
541. sulting file can be read with any text editor One can use the MuPAD graphics tool VCam to open such files and display the xml data Further there are various standard bitmap formats such as bmp Jpg eps etc in which the image may be stored Save in Batch Mode MuPAD plots can also be saved in batch mode by specifying the attribute OutputFile filename ina plot call plot primitives OutputFile mypicture xvz 6 176 Save and Export Pictures Here the extension Xvz of the file name mypicture xvz indicates that the MuPAD xml data are to be written and finally the file 1s to be compressed Alternatively the extension XVC may be used to write the xml data without final compression of the file the resulting text file can be read with any text editor Files in both formats can be opened by the MuPAD graphics tool VCam to generate the plot encoded by the xml data If the MuPAD environment variable WRITEPATH does not have a value the previous call creates the file in the directory where MuPAD is installed An absolute pathname can be specified to place the file anywhere else plot primitives OutputFile C Documents mypicture xvz Alternatively the environment variable WRITEPATH can be set WRITEPATH C Documents plot primitives OutputFile mypicture xvz Now the plot data are stored in the file C Documents mypicture xvz If a MuPAD notebook of 1s saved to a file it
542. sults in plain text mode For example PRETTYPRINT FALSE print Plain Result 1 2 2 1 2 PI 1 2 fresnelS 2 1 2 x PI 1 2 For further computations set PRETTYPRINT to TRUE PRETTYPRINT TRUE Knowing the MuPAD command you can access the corresponding help page and get more information about the special function 2 93 2 Notebook Interface Set Line Length in Plain Text Outputs 2 94 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To see results in the plain text format disable the typeset mode for outputs By default MuPAD limits lines in plain text outputs to 75 symbols To change this setting for your current notebook 1 Select Notebook gt Text Width 2 Inthe Text Width dialog box specify the line length limit LP Text Width Text width 75 characters z a Alternatively assign the new value to the environment variable TEXTWIDTH TEXTWIDTH 15 To restore the setting to its default value delete TEXTWIDTH delete TEXTWIDTH MuPAD applies the new setting to all new outputs in a notebook To apply the setting to existing output regions re evaluate the appropriate input regions See Evaluate Mathematical Expressions and Commands on page 1 4 To change the default line length limit for the current and all new notebooks see Setting Preferences for Notebooks Delete Outputs Delete Outputs Note Use only in the MuPAD Notebook Interface
543. sures of shape indicate the symmetry and flatness of the distribution of a data sample MuPAD provides the following functions for calculating the measures of shape The stats moment function that calculates the k th moment The stats obliquity function that calculates the obliquity skewness l fon f 3 n p x E yea where is the arithmetic average mean of the data sample x xs Xn The stats kurtosis function that calculates the kurtosis excess x il EE l n x Xy of the data sample x xs x centered around X ki where x is the arithmetic average mean of the data sample x xs Xn The stats moment function enables you to compute the kth moment of a data sample centered around an arbitrary value X One of the popular measures in descriptive statistics is a central moment The kth central moment of a data sample is the kth moment centered around the arithmetic average mean of that data sample The following statements are valid for any data sample The zero central moment 1s always 1 The first central moment is always 0 The second central moment is equal to the variance computed by using a divisor n rather than n 1 available via the Population option of stats variance 3 213 3 Mathematics 3 274 For example create the lists L and S as follows L 1 1 1 1 1 1 1 1 100 0 S 100 100 100 100 100 100 100 100 1 0 Calculate t
544. t First use the following procedure to create a link target Open the notebook in which you want to create a link target 2 Select the part of the notebook that you want to use as a link target You can select any object 1n a notebook except for output regions J Select Insert gt Link Target to declare the selected part of a notebook as a link target Alternatively use the context menu Work with Links Format Notebook Calculation Ctrl I 9 le Generic Sans Serif ll Calculation Above Ctrl Shift x Text Paragraph Ctr T 5 Text Paragraph Above Ctrl Shift T xa Laf An ordinary differential equa int variables with respect ffax f gt Ih to the only independent variz Link independent variable the Link Target N pf a dependent variable fo of T First Order ODEs The solution of a single expl Frame ed by integration provided the solution exists To defin de e ode y x vy Line Break Ctrl Enter 2 35 File Path ode x y y x Now use the general solve to solve this equation ZU Ra w solve o General Math l amp cl C3 Plot Commands Alternatively you can call the ODE solver directly ode solve y x y x 2 y x The general solutions of ODEs contain arbitrary constants of integration The solver generates the constants of integration using the format of an uppercase letter C followed by an automatically generated number Fo
545. t Assumptions on page 3 125 Use Temporary Assumptions on Top of Permanent Assumptions on page 3 126 Create Temporary Assumptions Use temporary assumptions to specify that an object holds mathematical properties for a particular calculation Temporary assumptions also help you narrow a general solution and get specific solutions For example the following equation describes linear motion with constant acceleration r ry tVyt BE Here r is the distance the object travels ro is the initial distance v 1s the initial velocity ais the constant acceleration and t is the time of travel If you know all other parameters and want to calculate the time that the object was moving solve the equation for the variable t t solve r P 0 v O t a t 2 2 t Use Temporary Assumptions l vp 794 Vp ty if az D a a r r H if a 0Av 0 L t 0 C if r rQj ac A v 0 Z4 freer a v 0 where aa T V wy 2ar 2ar Suppose you want to keep the general solution for all possible cases of the linear motion with constant acceleration You also want to derive several special cases of this motion and get particular solutions for these cases For example one of the objects you consider moves with constant velocity Derive the solution for this object from the general solution for the time of the motion by assuming the acceleration a 0 t solve r r_0 v O t a t 2 2 t assuming a 0 and r gt r 0 and
546. t Format gt Math 2 21 2 Notebook Interface 2 22 File Edit View Navigation Insert Format Notebook Ld amp 3 emp A f Piecewise solution The solution of the quadratic e and x is a symbolic variable Piecewise objects often occur if a Change math format for selected formulas Characters Window Help dL Q 9 le Generic Sans Serif Math Paragraph Calculation Table Frame Page Increase Size Decrease Size Defaults D is piecewise Here a b and c are symbolic parameters nbolic parameters in addition to the variable Mot Connected 2 Set your formatting preferences You can define the script size choose between inline embedded in text or displayed styles and use the Slant identifiers check box to italicize variables Also you can specify whether you want to wrap long mathematical expressions to a notebook window size Format Mathematical Expressions Slant identifiers Wrap lines Minimal script size 8 w pt Script size multiplier 71 RN If you want to experiment with different settings for mathematical expressions and see how the formatted expression looks in your notebook click Apply This button applies formatting to the selected text and leaves the Math Format dialog box open You can change settings several times without having to open this dialog box for each change When you finish formatting click OK to close the Math Format
547. t also returns a list of all unexpected options When you pass arguments to prog getOptions always use the following order The first argument of prog getOptions is the number n 1 where n is the number of required non optional arguments of the procedure Then you must provide the list of all actual arguments followed by the table of all acceptable options and their default values To access a sequence of all arguments of a procedure call including required arguments and options use the args function The following example demonstrates the procedure that accepts the numeric coefficients a b and c and solves the quadratic equation a x b x c 0 using these coefficients The procedure solveQuadraticEQqn requires the user to provide three numeric values Therefore if you embed prog getOptions into this procedure the first parameter of prog getOptions must be the number 4 The procedure also accepts the optional argument PositiveOnly Ifthe value of PositiveOnly is TRUE the procedure returns only positive solutions of the quadratic equation If the value 1s FALSE the procedure returns all solutions The following function call to prog getOptions sets the default option value PositiveOnly FALSE solveQuadraticEqn proc a Type Numeric b Type Numeric C Type Numeric local options S begin options prog getOptions 4 args table PositiveOnly FALSE S solve a x 2 b x c 0 x if options 1 Positi
548. t engine state including memory and time used during the most recent computations While a computation 1s still running the status bar information keeps changing Mem8MB Tils Cmd INS P If the engine is not connected to your notebook the status bar displays Not Connected For more information about the status bar see Viewing Status Information Note When you perform computations in several MuPAD notebooks each notebook starts its own engine In this case watch for the total amount of memory used by all MuPAD engines the mupkern exe processes 9 111 5 Programming Fundamentals 9 112 Generate Memory Usage Reports Periodically When a computation takes a long time to run it can be helpful to display progress information In this case MuPAD can issue periodic messages showing active memory usage reserved memory and evaluation time You can control the frequency with which MuPAD prints such messages To set the frequency of these periodic messages use the Pref report function By default the value of Pref report is 0 MuPAD does not print periodic status messages If you increase the value to 1 MuPAD prints status messages approximately every hour The exact frequency depends on your machine The maximum value accepted by Pref report is 9 Suppose you want to generate and sort the list of 10 000 000 random integer numbers These operations take a long time because of the huge number of elements If you
549. t lists vectors and arrays with one row or one column Before creating a pie chart extract the bins and the number of elements in them into two separate tables Counts map T op 2 Bins map T op 1 d 2 1 30 4 313 jl 7 1 2 9 10 012 Pot 3 289 3 Mathematics 3 290 o 7 59 7 59 5 08 5 08 2 57 2 57 0 06 r r JA kas La 0 06 2 45 2 45 4 96 4 96 7 47 7 47 9 98 9 98 12 49 10 12 49 15 0 Now extract the entries from the Bins and Counts tables and create the lists containing these entries Counts i i 1 10 expr2text Bins i i 1 10 slices titles Create a 2 D pie chart by using the plot Piechart2d function The slices list specifies the portions that each bin contributes to the total number of all elements of the data sample The titles list specifies the titles for each piece on the pie chart plot plot Piechart2d slices Titles titles Create Bar Charts Histograms and Pie Charts 2 57 0 06 508 257 7 59 5 08 0 06 2 45 infinity 7 59 12 49 15 0 2 45 4 96 9 98 12 49 Create a 3 D pie chart from the same data by using the plot Piechart3d function To rotate the resulting 3 D chart click any place on the chart hold the mouse button and move the cursor plot plot Piechart3d slices Titles tit
550. t x values They are also convenient for plotting combined data samples such as x7 vz x9 vol Xn Yn If you have two separate data samples you can combine the data of these samples pairwise xy Xli yii 9 1 101 To create a list plot use the plot Listplot function plot plot Listplot xy AxesTitles x y Create Scatter and List Plots 0 8 0 6 OF 0 6 0 5 0 4 0 3 0 2 0 1 0 0 By default the plot Listplot function connects adjacent points on the plot by straight lines To hide these connections use the LinesVisible option plot plot Listplot xy AxesTitles x y LinesVisible FALSE 3 283 3 Mathematics 0 9 0 8 0 7 0 6 0 5 0 4 0 3 0 2 0 1 0 0 0 3 0 4 0 5 0 6 0 7 0 8 3 284 Create Bar Charts Histograms and Pie Charts Create Bar Charts Histograms and Pie Charts Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Bar Charts on page 3 285 Histograms on page 3 287 Pie Charts on page 3 288 Bar charts histograms and pie charts help you compare different data samples categorize data and see the distribution of data values across a sample These types of plots are very useful for communicating results of data analysis Bar charts histograms and pie charts can help your audience understand your ideas results and conclusions quickly and clearly Bar Charts To compare different data
551. tY o Toolbars d FocalPointz 1 j v Status Bar ViewingAngle 0 174533 OrthogonalProjec mn Hide Defaults k UpVectorX iW SS Configure S UpVectorY o UpVector 6 vi KeepUpVector ns y 0 5 ee 0 0 on 0 5 10 40 4 Ohiec Hide the default properties in the graphics object browser sidebar Mem 7 MB T0 s ae E A Section Attributes for plotfunc2d and plotfunc3d provides more information on cameras 6 102 Primitives Primitives Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB In this section we give a brief survey of the graphical primitives grouping constructs transformation routines etc provided by the plot library The following table lists the low level primitives plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot Arc2d Arrowad Arrowa3d Box Circle2d Circle3d Cone Cylinder Ellipse2d Ellipsoid Line2d Line3d Parallelograma2d Parallelograma3d Point2d Point3d PointList2d PointList3d Polygon2d Polygon3d Rectangle circular arc in 2D arrow in 2D arrow in 3D rectangular box in 3D circle in 2D circle in 3D cone conical frustum in 3D cylinder in 3D ellipse 1n 2D ellipsoid 1n 3D graphical line segment in 2D graphical line segment in 3D parallelogram in 2D parallelogram in 3D graphical point in 2D gra
552. te the following square matrix A matrix 1 2 3 4 5 6 Ty 2 3 123 ED 123 To compute the eigenvalues of the matrix A use the linalg eigenvalues function ba Qn a linalg eigenvalues A 0 9 The linalg eigenvalues function returns a set of eigenvalues A set in MuPAD cannot contain duplicate elements Therefore if a matrix has eigenvalues with multiplicities greater than 1 MuPAD automatically removes duplicate eigenvalues If you want the linalg eigenvalues function to return eigenvalues along with their multiplicities use the Multiple option For example zero is a double eigenvalue of the matrix A linalg eigenvalues A Multiple 3 197 3 Mathematics 3 198 Llo 2 9 1 To compute the eigenvectors of a matrix use the linalg eigenvectors function The function returns eigenvectors along with corresponding eigenvalues and their multiplicities linalg eigenvectors A Sat The linalg eigenvalues function computes eigenvalues of a matrix by finding the roots of the characteristic polynomial of that matrix There is no general method for solving polynomial equations of orders higher than 4 When trying to compute eigenvalues of a large matrix the solver can return complicated solutions or solutions in the form of RootOf Also the solver can fail to find any solutions for some matrices For example create the 6 x6 Pascal matrix P linalg pascal 6 111 1 1 1 1234 5 6 13
553. tebook Interface This functionality does not run in MATLAB The first time you start MuPAD notebook it appears with the default layout as shown in the following illustration J Notebookl MuPAD File Edit View Navigation Insert Format Notebook Window Help a A nm Let Gy al gt A Q e Te T oO O gt gt Generic Monospace i B A MuPAD notebook has three types of regions input regions output regions and text regions y x 3 C plot y x 2 2 x H D E Command Ger Fad and Resists JK G Mem 7 MB TO s Cmd f INS A Perform most common tasks from the Standard toolbar 2 3 2 Notebook Interface 2 4 B Type your comments in the text regions C Enter commands in the input regions D View results including graphics in the output regions E A new input region appears after evaluation of the bottom input region F View current status information in the Status bar G Find and Replace text in the input and text regions H Quickly access standard functions from the Command Bar I Format nongraphical objects in the input and output regions from the Format toolbar J Use more items from the toolbars K Menus change in the Graphics Format mode Debugger Window Overview Debugger Window Overview Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The first time you start MuPAD Debugger window it appears with the default layout as shown in t
554. teger also belong to this residue class Suppose you want to solve an equation ax b mod m where a b and m are integers and X is an unknown integer Such equations are called linear congruence equations To solve a linear congruence equation use the numlib lincongruence function This function returns only the solutions x lt m For example solve the linear congruence equation 56x 77 mod 49 numlib lincongruence 56 77 49 4 11 18 25 32 39 46 3 327 3 Mathematics 3 328 A linear congruence equation aX b mod m has at least one solution if and only if the parameters a b and m satisfy the following condition b O mod gcd a m If the parameters of a linear congruence equation do not satisfy this condition the equation does not have a solution In this case num1ib lincongruence returns FAIL numlib lincongruence 56 77 48 FAIT Systems of Linear Congruences The Chinese remainder theorem states that if the integers m i 1 n are pairwise coprime the system of n linear congruences X a mod mi has a solution The numbers n i 1 n are pairwise coprime if the greatest common divisor of any pair of numbers m m i j is 1 The solution is unique up to multiples of the least common multiple ilcm of m ms m4 To solve a system of linear congruence equations use the numlib ichrem function numlib ichrem 3 1 10 6 5 13 231 The Chinese remainder theorem doe
555. tegral F x f y dy The area between the graph of f and the x axis is displayed as an animated hatch object The current value of F x is displayed by an animated text DIGITS 2 the function f X gt cos x 2 the anti derivative F x gt numeric int f y y O x the graph of f x g plot Function2d f x x the graph of F x G plot Function2d F x x 0 6 Color RGB Black a point moving along the graph of F x p plot Point2d a F a a 0 6 Color RGB Black hatched region between the origin and the moving point p h plot Hatch g 0 O a a 0 6 Color RGB Red 0 6 Color RGB Blue 6 149 6 Graphics and Animations 6 150 the right border line of the hatched region l plot Line2d a 0 a f a a O 6 Color RGB Red a dashed vertical line from f to F L1 plot Line2d a f a a F a a O 6 Color RGB Black LineStyle Dashed a dashed horizontal line from the y axis to F L2 plot Line2d 0 1 F a a F a a 0 6 Color RGB Black LineStyle Dashed the current value of F at the moving point p t plot Text2d a gt F a 0 2 F a a O 6 HorizontalAlignment Right plot g G p h 1 L1 L2 t YTicksNumber None YTicksAt 1 1 delete DIGITS c 0 S Rs ANM Uzwuru 4 04d d MEN F j j 4 Yg Example 2 We build two 3D animations T
556. tegration plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot plot Iteration Listplot LSys Matrixplot MuPADCube Ode2d Ode3d Piechart2d Piechart3d Plane Raster Scatterplot Sequence SparseMatrixplot Sum Surface Sweep Turtle VectorField2d VectorField3d XRotate ZRotate Primitives visualization of iterations in 2D lists of points in 2D Lindenmayer system in 2D visualization of matrix data as a surface in 3D the MuPAD logo graphical solution of an ODE in 2D graphical solution of an ODE in 3D statistical pie chart in 2D statistical pie chart in 3D infinite plane in 3D raster and bitmap plots in 2D statistical scatter plot in 2D visualization of a sequence of numbers sparsity pattern of a matrix visualization of a sum of numbers parametrized surface 1n 3D sweep surface in 3D turtle plot in 2D vector field plot in 2D vector field plot in 3D surface of revolution in 3D surface of revolution in 3D The following table lists the various light sources available to illuminate 3D plots plot plot plot plot AmbientLight DistantLight PointLight SpotLight ambient undirected light directed light undirected point light directed spot light The following table lists various grouping constructs 6 105 6 Graphics and Animations 6 106 plot
557. tegration provided the solution exists To define an ordinary differential equation use the ode command o ode y X y x 2 y x F PF F 2 F odel y x yix y x J Note ode does not accept multivariate expressions such as y x t It also does not accept piecewise expressions Now use the general solve to solve this equation solve o Solve Ordinary Differential Equations and Systems Eo Alternatively you can call the ODE solver directly ode solve y x y x 2 y x 0 1 a ia C6 x The general solutions of ODEs contain arbitrary constants of integration The solver generates the constants of integration using the format of an uppercase letter C followed by an automatically generated number For example it generates C1 C2 and so on For higher order ODEs you can find explicit solutions only for special types of equations For example the following second order equation has a solution in terms of elementary functions ode solve y x y x y x Ico e 8 e The solver introduces the solution of the following equation 1n terms of the Bessel functions MuPAD uses standard mathematical notations for Bessel and other special functions ode solve y x y x y x exp x y x Icio e 1o e 1 Cll e2 v e Jl If you have a second or higher order ODE nonlinear ODE or a system of ODEs a symbolic solution does not always exist ode solve y X y x 2
558. tes a constant it is not the constant itself Using this approximation you can get incorrect results For example the heaviside special function returns different results for the sine of m and the sine of 10 digit floating point approximation of rr heaviside sin PI heaviside sin pi 0 0 MJ Increase Precision The Riemann hypothesis states that all nontrivial zeros of the Riemann Zeta function D z have the same real part R z L To locate possible zeros of the Zeta function plot its absolute value the Zeta function c ley i au c 1344 y The following plot shows the first three nontrivial roots of 2 fi plot abs zeta 1 2 I y y 0 30 AxesTitles y zeta 3 235 3 Mathematics 3 236 zeta 30 Use the numeric solver to approximate the first three zeros of this Zeta function numeric solve zeta 1 2 I y y 13 15 numeric solve zeta 1 2 I y y 20 22 numeric solve zeta 1 2 I y y 24 26 114 13472514 121 02203964 125 01085758 Now consider the same function but slightly increase the real part t 10000000 According to the Riemann hypothesis this function does not have a zero for any real value y By default MuPAD uses 10 significant decimal digits for computations that involve floating point numbers When you use the numeric solve solver with the default number of digits the solver finds the following nonexisting zero of the
559. the MATLAB Command Window you get only one solution from the infinite set gt gt SYMS X gt gt solve sin x ans 0 By default the MuPAD solver returns all the solutions S solve sin x x ink keZ To get one element of the solution set use the solvelib getElement command solvelib getElement S 0 If you want the solver to return just one solution use the PrincipalValue option S solve sin x x PrincipalValue 10 PrincipalValue can help you shorten the results omitting all solutions except one The option does not allow you to select a particular solution Solve Equations Numerically Solve Equations Numerically Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Get Numeric Results on page 3 73 Solve Polynomial Equations and Systems on page 3 75 Solve Arbitrary Algebraic Equations and Systems on page 3 76 Isolate Numeric Roots on page 3 82 Solve Differential Equations and Systems on page 3 82 Get Numeric Results There are two methods to get numeric approximations of the solutions Solve equations symbolically and approximate the obtained symbolic results numerically Using this method you get numeric approximations of all the solutions found by the symbolic solver If the symbolic solver fails to find any solutions MuPAD calls the numeric solver directly For nonpolynomial equations the numeric solver retur
560. the MuPAD Notebook Interface This functionality does not run in MATLAB If you have an external data set and want to analyze it in MuPAD import the data to the MuPAD session To import an ASCII data file to the MuPAD session use the import readdata function Suppose you want to analyze the world population growth and compare it to the US population growth between 1970 and 2000 The text file WorldPopulation contains the required data To be able to work with the data in MuPAD import the contents of the file line by line by using the import readdata function The function returns the following nested list data import readdata WorldPopulation vear world thousands US thousands AnnualRate World AnnualRateUS 1970 3711962 205052 2 07 1 26 1971 3789539 207661 1 99 1 07 1972 3865804 209896 1 94 0 95 1973 3941551 211909 1 87 0 91 1974 4016056 213854 1 79 0 99 1975 4088612 215973 1 73 0 95 1976 4159763 218035 1 71 1 01 1977 4231510 220239 1 68 1 1 1978 4303134 222585 1 71 1 18 1979 4377497 225055 1 7 0 98 1980 4452548 227726 1 7 0 96 1981 4528882 229966 1 75 0 91 1982 4608682 232188 1 75 0 87 1983 4690278 234307 1 7 0 89 1984 4770468 236348 1 7 0 91 1985 4852052 238466 1 71 0 89 1986 4935874 240651 1 73 0 91 1987 5022023 242804 1 71 0 94 1988 5108860 245021 1 69 1 12 11989 5195713 247342 1 6
561. the conversion of the components Please note that this method does not test its arguments Thus it should be used with caution 3 A further possibility of achieving better runtimes using functions of linalg or methods of the constructor Dom Matrix is to store functions and methods that are called more than once in local variables This enables a faster access of these functions and methods The following example shows how a user defined procedure using functions of linalg and methods of the domain constructor Dom Matrix may look like It computes the adjoint of a square matrix defined over a commutative ring see Cat CommutativeRing adjoint proc A local n R i j a Ai Mat local variables to store often used methods det delRow delCol Rnegate begin if args 0 lt gt 1 then error wrong number of arguments end if Mat A dom the domain of A R Mat coeffRing the component ring of A n Mat matdim A the dimension of A faster than calling linalg matdim if testargs then if Mat hasProp Cat Matrix lt gt TRUE then error expecting a matrix elif not R hasProp Cat CommutativeRing then error expecting matrix over a Cat CommutativeRing elif n 1 lt gt n 2 then error expecting a square matrix end if end 417 store often used methods in local variables det linalg det delRow Mat delRow faster than calling linalg delRow delCol Mat d
562. the domain of polynomials This time the result of the conversion belongs to the domain of expressions domtype p domtype expr p DOM POLY DOM EXPR MuPAD can apply the expr function to an object recursively If an object contains terms that belong to library domains or complicated basic domains expr also tries to convert those terms elements of simpler basic domains For example if the polynomial p is an element of a list applying the expr function to the list converts the polynomial p to the expression matrix 2 2 p 0 0 1 expr matrix 2 2 p 0 0 1 9 45 5 Programming Fundamentals 9 46 The expr function converts a matrix of the library domain Dom Matrix to an array of the basic kernel domain DOM ARRAY M matrix 2 3 1 2 3 4 5 6 456 domtype M domtype expr M Dom Matrix DOM ARRAY The expr function converts an element of the series domain to the expression of a basic domain DOM EXPR Typically the order of terms in the resulting expression changes S series exp x x expr s 2 3 4 3 lx 4 4X 4X oh 2 6 24 130 d Ld ad LM qup 12 24 6 2 domtype s domtype expr s Series Puiseux DOM EXPR For further computations delete the identifiers y p M and s Convert Data Types delete y p M sS Use Constructors Instead of calling the conversion functions you can use the constructor of a domain to which you want to convert an object This approach works for
563. the domain that belong to the category Categories may also depend on parameters and are created by category constructors The category constructors of the MuPAD library are contained in the library package Cat Attributes of domains and categories are defined in terms of so called axioms Axioms state properties of domains or categories They may also depend on parameters and are defined by axiom constructors Please note that most axioms of the domains and categories defined in the MuPAD library are not stated explicitly Only axioms which are not implied by the definition of a category are stated explicitly The category of groups for example has no axiom stating that the multiplication is invertible because that is implied by the definition of a group Most axioms defined in this package are of technical i e algorithmic nature Bibliography K Drescher Axioms Categories and Domains Automath Technical Report No 1 Univ GH Paderborn 1995 Categories Categories Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Introduction on page 8 5 Category Constructors on page 8 6 Bibliography on page 8 6 Introduction In MuPAD an algebraic structure may be represented by a domain Parametrized domains may be defined by domain constructors Many domain constructors are defined in the library package Dom Domains which have a similar mathematical structure may be member
564. the eigenvalues on its main diagonal linalg eigenvalues P linalg jordanForm P J i FE Te Lg 1 1 4 yf to af to 4 To find the Jordan canonical form of a matrix along with the nonsingular similarity transformation matrix T that transforms the original matrix to its Jordan form use the All option J T linalg jordanForm P All Find Jordan Canonical Form of a Matrix 1 0 0 Coo 04 415 0 Jh 1 2 2 1 iE L 0 0 y5B i You can restore the original matrix from its Jordan form and the similarity transformation simplify T J T 1 1 1f 2 3 13 6 You cannot transform to a diagonal form matrices for which the number of linearly independent eigenvectors is less than the matrix dimensions For example the following matrix has the triple eigenvalue 2 The Jordan block corresponding to that eigenvalue has 1s on its first superdiagonal A matrix 6 11 15 11 11 14 22 16 6 7 7 7 24 32 43 34 linalg jordanForm A ba cca HOG c Oo bh 0 oboe oS The 4x4 matrix A has a triple eigenvalue 2 and only two eigenvectors linalg eigenvectors A al 3 p _ la La Lr ELI 3 201 3 Mathematics Compute Matrix Exponentials Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB You can use the exp function to compute matrix exponentials amp 4 _ x 2 1 4 For example compute
565. ther calculations because temporary assumptions do not hold true 0 V 0 4 t If assumptions contain linear equations with one variable MuPAD solves these equations inserts the solutions into the expression and then evaluates the expression r r_0 v_O t a t 2 2 assuming at 5 5 and 2 v_0 4 14 and t 3 and r_O 0 Interactions Between Temporary and Permanent Assumptions The aSSuming command temporarily overwrites all permanent assumptions set on an object assume z in R Z assuming z 2 I 24 After evaluating the statement with a temporary assumption MuPAD reinstates the permanent assumption is z in R_ TRUE See how to use temporary assumptions in combination with permanent assumptions in Using Temporary Assumptions on Top of Permanent Assumptions 3 125 3 Mathematics 3 126 Use Temporary Assumptions on Top of Permanent Assumptions Suppose you set permanent assumptions on a MuPAD object If you evaluate the object with a temporary assumption set by the assuming command MuPAD ignores the permanent assumptions in this evaluation assume x in R solve x 3 x 0 x assuming x lt gt 0 To use permanent assumptions and a temporary assumption together add the temporary assumption using the assumingAlso command assume x in R solve x 3 x 0 x assumingAlso x lt gt 0 t When you use temporary assumptions on top of the permanent ones always check that the assumptions do not
566. there are Examples of plot commands using the described attribute s 6 119 6 Graphics and Animations Layout of Canvas and Scenes 6 120 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Layout of the Canvas The following canvas attributes are relevant for its layout and its style attribute name possible values example 12 unit cm physical width of the 120 unit mm canvas 8 uni cm physical height of 80 unit mm the canvas BackgroundColor RGB color color of the RGB White background BorderColor RGB color color of the border RGB Grey50 gt MM Margin common width for all margins BottomMargin LeftMargin etc ders width of the bottom 1 unit mm margin width of the left 1 unit mm margin width of the right 1 unit mm margin Layout of Canvas and Scenes attribute name possible values example TopMargin 1 unit mm width of the top 1 unit mm margin Footer footer text no footer FooterAlignment Left Center horizontal footer Center Right alignment HeaderAlignment Left Center horizontal header Center Right alignment Layout Tabular Horizontal automatic or user Tabular Vertical Absolute defined layout Relative integer gt 0 number of rows in automatic tabular layout mode integer gt 0 number of columns in automatic tabular layout mode A canvas may contain one or more scenes The following picture shows a canvas with four
567. tiation variables for each step diff x cos x y y X eee 2 ew ixsm xy x ycosix y Note To improve performance MuPAD assumes that all mixed derivatives commute For example 8 8 f x y 2 8 f x y ay Ox i x By ab This assumption suffices for most of engineering and scientific problems 3 129 3 Mathematics Differentiate Functions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To compute derivatives of functions use the differential operator D This operator differentiates both standard mathematical functions and your own functions created in MuPAD For example find the first derivatives of the following standard mathematical functions implemented 1n MuPAD D sin D exp D cosh D sqrt D heaviside cos exp sinh dirac 2 M Create your own function with one variable and compute a derivative of this function f xX gt x 83 D f i x 23x Alternatively use as a shortcut for the differential operator D X gt Sin x x 2 cos x 2sm x 2 3 X X X cos x 2 sm x ax X a Computing the first derivatives of a function lets you find its local extrema minima and maxima For example create this function and plot it on the interval 10 x lt 10 3 130 Differentiate Functions F X gt x 3 sin x plot F x 10 10 x x sin x 500 400 300 200 100 10 100
568. ting expressions Cosine and Sine The results differ from the original expressions invCosine ifourier Cosine w t invSine ifourier Sine w t ti ti e E 2 2 t VI 4 2 m cosl sin v2 vx cosl sin Simplifying the resulting expressions invCosine and invSine gives the original expressions 3 243 3 Mathematics simplify invCosine simplify invSine E cos sin 1 L1 Besides arithmetical expressions the fourier and ifourier functions also accept matrices of arithmetical expressions For example compute the Fourier transform of the following matrix A matrix 2 2 exp t 2 t exp t 2 t 2 exp t 2 t 3 exp t 2 fourier A t w y i G EG W VEO 3 Ww EG i v EG i 2 4 3 i 3 where WL Fr g 4 O1 e The fourier and ifourier functions let you evaluate the transforms of an expression or a matrix at a particular point For example evaluate the Fourier transform of the matrix A for the valuesw Oandw 2 x fourier A t 0 fourier A t 2 x 1 rm v X al c 3 244 Integral Transforms If MuPAD cannot compute the Fourier transform of an expression it returns an unresolved transform fourier f t t w fourier f t t w If MuPAD cannot compute the inverse Fourier transform of an expression it returns the result in terms of an unresolved direct Fourier transform ifourier F w w t fourier F w w t 21
569. tion For example find the prime numbers that precede and follow the number 1000 prevprime 1000 nextprime 1000 997 1009 Note prevprime and nextprime use the probabilistic primality test the Miller Rabin test In rare cases these functions can return nonprime numbers MuPAD stores a precalculated table of the prime numbers up to a certain value The ifactor function with the PrimeLimit option returns that value ifactor PrimeLimit 1 000000 The ithprime function with the PrimeLimit option returns the number of primes in that table ithprime PrimeLimit 78498 The ithprime function extracts the prime number from this table To compute larger prime numbers which MuPAD does not store in the table ithprime chooses some number as a starting point and then recursively calls the nextprime function Although the internal algorithm tries to reduce the number of computation steps computing huge prime numbers can be very slow ithprime 100000000 2038074743 Suppose you want to display a sequence of prime numbers For the numbers that MuPAD stores in the table call the ithprime function to find each number in the sequence 3 319 3 Mathematics 3 320 ithprime i i 1000 1010 7919 7927 7933 7937 7949 7951 7963 7993 8009 8011 8017 If the numbers exceed the value returned by ifactor PrimeLimit MuPAD does not store them In this case calling ithprime for each number can be very slow More efficiently
570. tion of complex matrices symbolically by using linalg factorCholesky or numerically by using numeric factorCholesky For example create the following 2X2 matrix A matrix sin 1 I I exp 2 sil i i e First compute the Cholesky decomposition of that matrix by using the symbolic linalg factorCholesky function L linalg factorCholesky A 3 219 3 Mathematics 3 220 Now compute the Cholesky decomposition by using the symbolic numeric factorCholesky function L numeric factorCholesky A f 0 917317276 0 1 090135361 1 2 490112647 J When using numeric factorCholesky you can prevent the conversion of data to floating point numbers and therefore get the symbolic result by using the Symbolic option L numeric factorCholesky A Symbolic y smi 1 0 E 2 je sin Yo simi The product of the triangular matrix L and its Hermitian transpose gives the original matrix A testeq A L htranspose L TRUE LU Decomposition LU factorization expresses an mXn matrix A as a product of a lower triangular matrix L and an upper triangular matrix U A L U Also LU decomposition can involve a row permutation matrix PA L U To compute the LU decomposition of a matrix numerically use the numeric factorLU function For example create the following 4x4 Toeplitz matrix Compute Factorizations Numerically T linalg toeplitz 4 1 2 3 4 5
571. tion to demonstrate this fact One of the rules for inheriting attributes in a graphical tree 1s Note If an attribute such as LinesVisible TRUE is specified in some node of the graphical tree all primitives below this node that react to this attribute use the specified value as the default value If a type specific attribute such as plot Circle2d LinesVisible TRUE is specified the new default value 1s valid only for primitives of that specific type In the following example we consider 100 randomly placed circles with a rectangle indicating the area into which all circle centers are placed rectangle plot Rectangle 0 1 O 1 circles plot Circle2d 0 05 frandom frandom i 1 100 plot rectangle circles Axes Frame Attributes We wish to turn the circles into filled circles by Filled TRUE LinesVisible FALSE plot rectangle circles Filled TRUE FillPattern LinesVisible FALSE Axes Solid Frame 6 115 6 Graphics and Animations 6 116 0 4 0 3 0 2 0 1 0 0 This is not quite what we wanted Not only the circles but also the rectangle reacts to the attributes Filled FillPattern and LinesVisible The following command restricts these attributes to the circles plot rectangle circles plot Circle2d Filled TRUE plot Circle2d FillPattern Solid plot Circle2d LinesVisible FALSE Axes Frame Attributes 1 0 0 9 0 8 of 0 6 0 5 0 4 0 3 0 2
572. tional Control Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Use if Statements on page 4 2 Apply Multiple Conditions on page 4 3 Use Nested Conditional Statements on page 4 4 Use case and otherwise Statements on page 4 5 Exit a Conditional Statement on page 4 5 Return Value of a Conditional Statement on page 4 6 Display Intermediate Results on page 4 7 Use if Statements You can execute different groups of statements depending on particular conditions Use if to define a condition and use then to define the group of statements you want to execute when the condition is true X i 3 if x 0 then y i X 2 X i Xj print x y end if 31 You also can define the group of statements that you want to execute when the condition 1s false X i if X y O then x t 2 I CO Conditional Control X i Xj print x y else y i X X I Xi print x end_if 2 s y ut uh MuPAD does not require parentheses around conditions X 10 if testtype x Type Positive TRUE and type x DOM INT then print Unquoted x x is a positive integer end if X 10 is a positive integer Apply Multiple Conditions You can use multiple conditions 1n conditional statements Combine multiple conditions by the logical operators X i 5 y i 6 if x gt 0 and 1 y gt O then print Unquoted the co
573. tions with one argument such as f x sin x f x x 1n x etc or 3D plots of functions with two arguments such as f x y sin x 2 y 2 f x y y 1n Xx x 1n y etc The calling syntax is simple just pass the expression that defines the function and optionally a range for the independent variable s 2D Function Graphs plotfunc2d We consider 2D examples 1 e plots of univariate functions y f x Here is one period of the sine function plotfunc2d sin x x 0 2 PI 6 25 6 Graphics and Animations Y 101 0 8 0 8 0 4 02 0 0 02 0 4 06 0 8 1 0 If several functions are to be plotted in the same graphical scene just pass a sequence of function expressions All functions are plotted over the specified common range plotfunc2d sin x x x cos x tan x x 4 4 6 26 Easy Plotting Graphs of Functions Functions that do not allow a simple symbolic representation by an expression can also be defined by a procedure that produces a numerical value f x when called with a numerical value x from the plot range In the following example we consider the largest eigenvalue of a symmetric 3X3 matrix that contains a parameter x We plot this eigenvalue as a function of x f x gt max numeric eigenvalues matrix x x x X X X Lis X X x 2 1 plotfunc2d f x 1 1 6 27 6 Graphics and Animations 1 5 The name x used in the specification of the plotting range
574. tiveOnly TRUE then S select S testtype Type Positive end if return S end proc Verify Options Now the procedure solveQuadraticEgn issues an error The error message indicates the wrong option solveQuadraticEqn 2 3 9 Positive Error The argument number 4 is invalid Evaluating solveQuadraticEqn 9 63 5 Programming Fundamentals Debug MuPAD Code Using the Debugger 9 64 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Overview on page 5 64 Open the Debugger on page 5 65 Debug Step by Step on page 5 66 Set and Remove Breakpoints on page 5 69 Evaluate Variables and Expressions After a Particular Function Call on page 5 75 Watch Intermediate Values of Variables and Expressions on page 5 77 View Names of Currently Running Procedures on page 5 78 Correct Errors on page 5 79 Overview Besides syntax errors such as misspelling a function name or omitting parenthesis run time errors can appear when executing your code For example you might modify the wrong variable or code a calculation incorrectly Runtime errors are usually apparent when your code produces unexpected results Debugging 1s the process of 1solating and fixing these run time problems MuPAD provides a tool to help you with the debugging process With the Debugger you can Run your procedure step by step Set rigid and conditional breakpoints Evaluat
575. to Static Variables in MuPAD Many programming languages support the concept of static variables Static variables are local variables the values of which are not reset 1n each call to a procedure The value of a static variable is initialized during the first call to a procedure In each subsequent call a procedure remembers the value of a static variable from the previous call Although MuPAD does not let you declare a variable inside a procedure as a static variable you can still use the concept of static variables while programming in MuPAD When defining a procedure with proc you often assign the procedure to an identifier However MuPAD lets you use anonymous procedures Also you can define one procedure inside another procedure Thus you can implement the alternative to a static variable in MuPAD as a nested procedure where 1 The outer procedure has a local variable The outer procedure can be anonymous Variables Inside Procedures 2 The inner procedure uses the local variable of the outer procedure For the inner procedure that variable is not local and therefore it does not reset its value in each call For example this code implements cnt as a static variable in MuPAD proc local cnt option escape begin cnt i 0 f i proc begin cnt Cnt 1 end end F 5 fO FC Shared Static Variables The technique of creating static variables in MuPAD lets you create shared static variables by creating several
576. trix A is A matrix 2 2 a b c d linalg tr A a d Now compute the trace of the 12x12 Hilbert matrix H linalg hilbert 12 linalg tr H 744355888 334639305 Invert Matrices Invert Matrices Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To find the inverse of a matrix enter 1 A or A 1 A matrix a b c d B matrix 1 2 3 4 1 A B 1 d b ad bc ad bc a ad be ad be When MuPAD cannot compute the inverse of a matrix it returns FAIL C matrix 1 1 1 111 1 C FAIL 3 189 3 Mathematics Transpose Matrices Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB To transpose a matrix use the transpose command A matrix 1 2 3 4 5 6 transpose A t 3 Ch LA fe 3 190 Swap and Delete Rows and Columns Swap and Delete Rows and Columns Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB The MuPAD linalg library provides the functions for interchanging or deleting rows and columns of a matrix For example to swap two rows of a matrix use linalg swapRow To swap two columns use linalg swapCol OriginalMatrix linalg pascal 3 SwapRows linalg swapRow OriginalMatrix 1 2 SwapColumns Linalg swapCol OriginalMatrix 1 2 Lad 2 C ad c M Lage
577. try example Mesh integer gt 2 number of 121 Function2d major mesh points in x direction The same as XMesh integer gt 2 number of 25 25 Function3d integer gt 2 major mesh points in x and y direction Corresponds to XMesh YMesh Submesh integer gt 0 number of Function2d minor mesh points between the major mesh points set by Mesh The same as XSubmesh 6 71 6 Graphics and Animations attribute name __ possible values browser entry example integer gt 0 integer gt 0 Submesh number of Function3d minor mesh points between the major mesh points set by Mesh Corresponds to XSubmesh YSubmesh XMesh integer gt 2 number of 121 Function2d major mesh points in the x direction XMesh integer gt 2 number of Function3d major mesh points in the x direction XSubmesh integer gt 0 number of Function2d 3d minor mesh points between the major mesh points set by XMesh 0 YMesh integer gt 2 number of Functionad major mesh points in the y direction YMesh integer gt 2 number of Function3d major mesh points in the y direction YSubmesh integer gt 0 number of Function3d minor mesh points between the major 6 72 Easy Plotting Graphs of Functions attribute name __ possible values browser entry EMEN BEEN points set db YMesh sus iveMesh integer gt 0 depth of the nct mE a
578. tself with the same arguments and it reevaluates the result 1n every call time lucas 35 66156 25 Using the remember mechanism eliminates these reevaluations To enable the remember mechanism for a particular procedure use the prog remember function This function returns a modified copy of a procedure that stores results of previous calls in the remember table lucas prog remember lucas When you call this procedure MuPAD accesses the remember table If the system finds the required entry in the remember table it returns remembered results immediately Now MuPAD computes the 35th and even the 100th Lucas number almost instantly time lucas 35 time lucas 100 0 0 0 0 Alternatively you can enable the remember mechanism for a particular procedure by using the option remember for that procedure For example use the option remember to enable the remember mechanism for the procedure lucas lucas proc n Type PosInt option remember begin Remember Mechanism if n 1 then 1 elif n 2 then 3 else lucas n 1 lucas n 2 end_if end proc For further computations delete the procedure lucas delete lucas Remember Results Without Context By default the remember mechanism does not consider context information of a procedure call Thus the remember mechanism disregards any changes in assumptions set on the arguments of a procedure call and the number of digits used for floating point arith
579. turn Values By default a procedure returns the result of the last executed command If you want to return other results use the return command For example create a procedure that computes the factorials of integer numbers myProcReturn proc n begin if n 0orn 1 then return 1 end zT n myProcReturn n 1 end proc Call the procedure myProcReturn 5 120 To display the results on your screen without returning them use the print command myProcPrint proc n begin print n if n 0 or n 1 then return 1 end zT n myProcPrint n 1 end proc Call the procedure myProcPrint 5 Lh 4 19 4 Programming Basics ba Return Multiple Results To return several results from a procedure use such structures as lists or matrices as return values myProcSort proc a b begin if a lt b then a b else b a end_if end proc myProcSort 4 5 5 7 a LA Return Symbolic Calls Many built in MuPAD procedures can return symbolic calls to themselves when they cannot compute results as exact values For example when you compute sin PI 2 the sin function returns the exact value 1 At the same time when you compute sin x 2 the sin function returns the symbolic call to itself sin x 2 4 20 Procedures x sin X 3 F To enable your custom procedure to return symbolic calls use the special syntax procname args For example create the procedure that comput
580. two loops are equivalent for i in 0 1 0 0 do if 1 1 then print Unquoted True else print Unquoted False end_if end for False True False False for i in 0 1 0 0 do if i 1 then print Unquoted True else print Unquoted False end end 4 29 4 Programming Basics 4 30 False True False False Programming Fundamentals Data Type Definition on page 5 3 Sequences on page 5 6 Lists on page 5 10 Sets on page 5 18 Tables on page 5 25 Arrays on page 5 30 Vectors and Matrices on page 5 36 Choose Appropriate Data Structures on page 5 40 Convert Data Types on page 5 42 Define Your Own Data Types on page 5 49 Access Arguments of a Procedure on page 5 52 Test Arguments on page 5 55 e Verify Options on page 5 60 Debug MuPAD Code Using the Debugger on page 5 64 Debug MuPAD Code in the Tracing Mode on page 5 81 Display Progress on page 5 85 Use Assertions on page 5 88 Write Error and Warning Messages on page 5 90 Handle Errors on page 5 92 When to Analyze Performance on page 5 95 Measure Time on page 5 96 Profile Your Code on page 5 100 Techniques for Improving Performance on page 5 109 Display Memory Usage on page 5 111 Remember Mechanism on page 5 115 5 Programming Fundamentals History Mechanism on page 5 123 Why Test Your Code on page 5 128
581. ty 3 100 010 0 0 1 Now create the 3x3 diagonal matrix with the number 5 on the diagonal matrix 3 3 5 Diagonal To create a matrix containing variables or arithmetical expressions always use a list to specify matrix elements For example when creating the 3x3 diagonal matrix with the variable X on its main diagonal specify the diagonal elements inalist X X x Asa shortcut for creating this list you can use the sequence generator Cun e unm 1 em oc Ls Y matrix 3 3 x 3 Diagonal x 00 x o 0Orxrx E To create special matrices such as Hilbert Toeplitz Pascal or Vandermonde matrices use the appropriate function of the linalg library For example to create the 4x4 Hilbert matrix use the linalg hilbert function linalg hilbert 3 3 175 3 Mathematics 1l Loe 111 2 3 4 111 3 4 5 To create a matrix of random numbers use the linalg randomMatrix function For example create a matrix of random integer numbers linalg randomMatrix 3 4 Dom Integer 994 65 814 741 979 764 216 663 880 916 617 535 Now create a matrix that has random rational numbers on the main diagonal and zeros everywhere else linalg randomMatrix 3 3 Diagonal Dom Rational 2M3 9 397 747 2 3 176 Access and Modify Matrix Elements Access and Modify Matrix Elements Note Use only in the MuPAD Notebook Interface This functionality does n
582. ty panes select View gt Object s The top of the Object Browser pane displays the components of your graphics such as scene background coordinate system and a function plot For further information on the structure of graphics see The Full Picture Graphical Trees Browser or click on the toolbar 1 50 Use Graphics al I Canvas E Scene3d 4 i CoordinateSystem3d Function3d After you select a component in the Object Browser pane the bottom of the pane displays the properties of this component gt Surface TrtleFont Arial 11pt TitleAlign Center Change Background Settings To change background settings of your graphics switch to plot formatting mode and select Scene at the top of the Object Browser pane The bottom of the pane shows background properties that you can change For example you can change the background color To choose the color select BackgroundColor and click the ellipsis button 1 51 l Getting Started File Edit View Inset Tools Actions Window Help R t Ske bH06A2Q 4 I Canvas 4 Scene3d 4 d CoordinateSystem3d Function3d plet sqrt 1l x 2 y 2 x 1 1 3D Lighting Backgrou Backgrou Backgrou Backgrou Borderi BorderColor BB 100 background color Mem 7 MB T1s Outp A INS You can use predefined colors or select a color from a more extensive palette 1 52 Use Graphics Modify Axes To
583. u call the juggler procedure the tracing report shows the memory usage for each call to juggler J i juggler 7 enter juggler 7 mem 5338408 enter juggler 18 mem 5373600 enter juggler 4 mem 5374080 enter juggler 2 mem 5374584 enter juggler 1 mem 5375064 computed 7 18 4 2 1 mem 5375032 computed 7 18 4 2 1 mem 5374648 computed 7 18 4 2 1 mem 5374264 computed 7 18 4 2 1 mem 5373880 computed 7 18 4 2 1 mem 5373524 The Mem option is independent of the traced procedure Now if you use prog trace to trace any other procedure prog trace displays memory usage in every step of that procedure Remove this global option for further computations prog trace Mem FALSE To stop tracing the juggler procedure use the prog untrace function prog untrace juggler Remember Mechanism Remember Mechanism Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Why Use the Remember Mechanism on page 5 115 Remember Results Without Context on page 5 117 Remember Results and Context on page 5 118 Clear Remember Tables on page 5 119 Potential Problems Related to the Remember Mechanism on page 5 121 Why Use the Remember Mechanism If your code calls a procedure with the same arguments more than once avoid unnecessary reevaluations and thus improve performance Instead of multiple evaluations of
584. u can change the default settings for particular types of regions For example to change default setting for all commands and expressions in the input and output regions of a notebook 1 Select Format gt Defaults from the main menu File Edit View Insert EPEY Piecewise solution The solution of the quadratic eque symbolic parameters and x is a Piecewise objects often occur if i the variable Change default formats 2 Format Notebook Window Help Characters 7T Math Paragraph Calculation Table 5 plecewise Here a b and c are Frame Page mbolic parameters in addition to A Increase Size A Decrease Size if a O0Ab 0aAc 0 if a O0A5 0ace0 Mem 8 MB TOs output regions select the Calculations tab Change Default Format Settings es Jfd x fof Taf Iu r o f y f Ld ab v General Math Plot Commands In the resulting dialog box use tabs to select the required element For input and 2 29 2 Notebook Interface T Defines the calculation format for a new calculation Bracket Sacing Padding 2 01 Top 1 01 Line Width 0 14 Bottom 1 01 Format Output Paragraph 2 30 Change Default Format Settings In the appropriate fields enter values for the size of indentation the spacing at the top and bottom of the calculation and the width of the left bracket that encloses each input and
585. u do not see the Format toolbar select View Toolbars Format from the main menu Generic Sans Serif ll B P u xa x3 c9 A A To change the font size quickly you can use Format gt Increase Size and Format gt Decrease Size or the corresponding buttons on the Format toolbar 2 17 2 Notebook Interface Choose Indention Spacing and Alignment To change paragraphs settings such as indention spacing alignment and writing direction 1 Select the paragraphs you want to format 2 Select Format gt Paragraph from the main menu or use the context menu J Notebookl MuPAD File Edit View Navigation Insert Notebook Window Help m Ld bis Let A Ed Characters 4 f X n Generic Sans Serif a Command Bar Piecewise solution Paragraph p f mf yvy The solution of the quadratic equa Calculation piecewise Here a b and c are Vds f symbolic parameters and x is a s Table PEE MEE Piecewise objects often occur if i Frame ymbolic parameters in addition to the variable NE ng of TEL ME ENS A Increase Size zs J Decrease Size i x fix r r w Defaults zi x ife T F F x e General Math Plot Commands Change paragraph format Not Connected 3 Inthe Paragraph Format dialog box choose indention spacing alignment background color and writing direction of the text The writing direction is a language specific option that allows you to type from ri
586. uPAD Objects and Library FUNCION 2523553 S7a Dut deas ear es Quir dabei ral civ 1 65 Notebook Interface Notebook Overview ces 2 3 Debugger Window Overview eere 2 5 Arrange Toolbars and Panes less 2 8 Enabling and Disabling Toolbars and Panes 2 8 Move Toolbars and Panes eee 2 9 Enter Data and View Results sess 2 11 View Status Information eee 2 13 Save Custom Arrangements esee 2 14 Format Text a4 Sacerdos amp adr de cue 5 uo Edicion b ocius 2 15 Choose Font Style Size and Colors 2 15 Choose Indention Spacing and Alignment 2 18 Format Mathematical Expressions 2 21 Format Expressions in Input Regions 2 24 Change Default Format Settings 2 28 Use Frames xao 8505422604235 Us Rog aerae Peete es qu RS ee 2 32 Use Fables ha ats dba date Suche hes Deua CUN M RE 2 38 Create Tables S ux e RC bbe Eius o 2 38 Add and Delete Rows and Columns 2 40 Format aD eS ior dh Asie eS pace d asta di osse aS dienen 2 41 Embed GEADlI6S 4 xo aote eS eb So re OOo ese Sad 2 45 Work with Links Insert Links to Targets in Notebooks Insert Links Interactively eere Insert Links to Arbitrary Files Insert Links to Internet Addresses
587. uence generator or its functional form _seqgen Enclose the sequence in brakets i i 1 i 1 10 i 10 L 2 2 2 2 2 2 2 2 A list can contain lists as entries List 1 List 2 Lists A list can be empty empty list MuPAD does not flatten lists like it flattens sequences You can create nested lists list i ly 2 list2 5 6 list3 list 3 4 list2 Access List Entries There are two ways to access particular entries of a list by their indices Ifyou want to use the order in which the entries appear on the screen use brackets or index Ifyou want to use the internal order of a list use Op In general these two indices of an entry of a data structure can be different For lists the internal order is the same as what you see on the screen list a b c d e f list 2 1 _1ndex list 9 525 op list 2 op iist 93 5 9 11 5 Programming Fundamentals 9 12 cde To access an entry counting numbers from the end of a list use negative numbers list a b c d e f list 2 If you use an indexed assignment without creating a list MuPAD generates a table instead of a list L 1 x L 1 x Operate on Lists MuPAD lists support the following operations e Verifying that a list contains a particular object Using a list as a function in a function call Applying a function to all entries of a list Extracting entries of a list D
588. uments LOCAL ssi begin code using helper end g proc arguments lo6c8l sisi begin code using helper end end For details about such structures see Closures and Static Variables 5 165 5 Programming Fundamentals 5 166 If you define a utility function in a closure that function is inaccessible to any external code Your users cannot see and therefore rely on a particular implementation of that utility function Changing it will not break their code At the same time this approach lets you create more than one procedure that can access the utility function In the example both f and g can access helper The disadvantage of this approach is that the helper function cannot access the local variables of the procedures that use it To overcome this limitation you can use the context function or shared static variables Note Using context or shared static variables to make local variables of the calling procedure accessible for the utility function is not recommended Using context to overcome this limitation typically leads to unreadable and difficult to maintain code The problems with shared static variables resemble the problems with global variables especially for recursive calls The helper procedure can access and modify such variables but all other procedures inside the same outer procedure can access and modify them too Private Methods Private Methods Note Use only in the MuPAD Noteboo
589. umeric svd A 0 6104993556 0 7174382767 0 3355187863 0 6645912432 0 2336056545 0 7097512787 14 9359164 5 188294644 U 4308236486 0 6562855456 0 6194192978 p 0 6925379522 0 7213814419 aaar ore a 8 704148513 1077 8 704148513 10 6 039716306 97 1 4 352074257 10 1 4 352074257 Tia Instead of returning the diagonal matrix S MuPAD returns the list d of the diagonal elements of that matrix d svd 2 114 9359164 5 188294644 You can restore the matrix S from that list S matrix 3 2 d Diagonal 1493590164 0 5 s 18894644 i 0 0 3 225 3 Mathematics 3 226 The numeric svd function also computes the residues resy and resy for the numeric singular vectors The residues are the estimated errors for the numerical matrices U and V res U res_V svd 4 svd 5 res 8 704148513 10 _ 8 704148513 10 6 039716306 a res 4 352074257 1071 4 352074257 10714 Small residue values indicate that roundoff errors do not significantly affect the results To suppress the computation of the residues use the NoResidues option svd numeric svd A NoResidues 0 6104993556 0 71743827607 0 3355187863 0 6645912432 02336056545 0 7097512787 14 9359164 5 188294644 U 4308236486 0 6562855456 0 6194192978 0 6925379522 0 7213814419 0 7213814419 0 6925379522 eee Within the floating point precision the product of
590. umps up and down while the other points remain at their initial position Then all points stay static for 1 second After a total of 6 seconds the middle point starts its animation by jumping up and down while the left point remains static in its final position and the right points stays static in its initial position After 9 seconds the right point begins to move as well The overall time span for the animation is the hull of the time ranges of all animated objects 1 e 15 seconds in this example p1 plot Point2d 1 sin a a O PI Color RGB Red PointSize 5 unit mm TimeBegin O TimeEnd 5 ll p2 plot Point2d 0 sin a a O PI Color RGB Green PointSize 5 unit mm TimeBegin 6 TimeEnd 12 p3 plot Point2d 1 sin a a O PI Color RGB Blue PointSize 5 unit mm TimeBegin 9 TimeEnd 15 plot p1 p2 p3 PointSize 3 0 unit mn Animations YAxisVisible FALSE Here all points use the default settings VisibleBeforeBegin TRUE and VisibleAfterEnd TRUE which make them visible as static objects outside the time range of their animation We set VisibleAfterEnd FALSE for the middle point so that 1t disappears after the end of its animation With VisibleBeforeBegin FALSE the right point 1s not visible until its animation starts p2 VisibleAfterEnd FALSE p3 VisibleBeforeBegin FALSE plot p1 p2 p3 PointSize 3 0 unit mm YAxisVisible FALSE 6
591. unction MuPAD provides two differentiation functions diff and D The diff function serves for differentiating mathematical expressions such as sin X cos 2y exp x 2 x 2 1 f y and so on To differentiate a standard function such as sin exp heaviside or a custom function such as f X gt x 2 1 use the differential operator D D sin D exp D heaviside cos exp dirac fT i X gt x 2 1 D f x 2x is a shortcut for the differential operator D sin sin x f cos cos x x 2 x The command D f X assumes that f 1s a univariate function and represents the derivative of f at the point x For example the derivative of the sine function at the point x is D sin x 2 1 25 l Getting Started 1 26 cos x Note that in this example you differentiate the sin function not the function f x gt sin x 2 Differentiating f returns this result f X gt sin x 2 D f x 2x coslx For details about using the operator D for computing second and higher order derivatives of functions see Differentiating Functions Integration Indefinite Integrals To compute integrals use the int command For example you can compute indefinite integrals int cos x 38 x stni x sin x The int command returns results without an integration constant Definite Integrals To find a definite integral pass the upper and lower limits of the integration interval to
592. unctions You can call any library function except for the standard library functions using the following syntax library function If you frequently use some functions that do 1 65 l Getting Started not belong to the standard library it is possible to call them without specifying the library name The use command exports functions of the MuPAD libraries to the global namespace allowing you to call them without using the library names For example you can export the function that computes the decimal expansion of a rational number use numlib decimal decimal 1 3 0 3 After exporting the decimal function you can use it without using the library name numlib decimal 1 200 0 0 0 5 To call the info help or commands use the full name of an exported function including the name of a library numlib decimal You cannot export a library function with the same name you use for another object hilbert x use linalg hilbert Warning Identifier hilbert already has a value It is not exported use After clearing the variable decimal you can export a function delete hilbert use linalg hilbert hilbert 3 ba bu ln I EJ Vni un im You also can export several functions from the same library simultaneously For example you can export the functions for finding the sum of digits and the set of positive divisors of an integer 1 66 Use the MuPAD Libraries use numlib sumO
593. ure user defined Function2d pepe meme rm Setting LinesVisible FALSE and PointsVisible TRUE the functions plotted by plotfunc2d will not be displayed as polygons but as sequences of points Here is a table of the attributes to set the presentation style of points Attributes for Points attribute name possible values browser entry example PointsVisible TRUE FALSE visibility of FALSE Function2d points points PointStyle Circles presentation FilledCircles Function2ad Crosses style of points Diamonds FilledCircles FilledDiamond FilledSquares Squares Stars XCrosses The colors and surface styles of the functions plotted by plotfunc3d are chosen automatically The property inspector see section Viewer Browser and Inspector Interactive Manipulation allows to the change these attributes 6 74 Easy Plotting Graphs of Functions Attributes for Surface Style of 3 D Function Graphs attribute name possible values browser entry example Filled TRUE FALSE display as a TRUE Function3d surface or as a wireframe model FillColor RGB or RGBa main color for Function3d color flat coloring FillColor2 RGB or RGBa secondary Function3d color color for Dichromatic and Monochrome coloring FillColorType Dichromatic color scheme Dichromatic Function3d Flat Functional Monochrome Rainbow FillColorFunc procedure user defined Function3d coloring Shading Smooth Flat smooth or flat Smooth Fun
594. ut the noise effectively hides the period For example the following data list represents such a signal fi 150 f2 300 Discrete Fourier Transforms data sin f1 2 PI t 1000 sin f2 2 PI t 1000 10 frandom 1 2 t 0 1000 When you plot the data the signal seems random The noise effectively hides the two main frequencies of the signal plot plot Listplot data t 0 1000 AxesTitles Time Amplitude YAxisTitleOrientation Vertical XAxisTitleAlignment Center YAxisTitleAlignment Center 0 100 200 300 400 500 600 T00 200 500 1000 Time To prove that the signal has a strong periodic component and to find the main frequencies compute the discrete Fourier transform of the signal fft abs numeric fft data The plot of fft shows four peaks The peaks correspond to the two main frequencies of the original signal f1 150 and f2 300 plot plot Listplot fft f 0 1000 AxesTitles Frequency Power 3 253 3 Mathematics YAxisTitleOrientation Vertical XAxisTitleAlignment Center YAxisTitleAlignment Center 400 300 Power 0 100 200 300 400 300 600 TU0 800 900 1000 Frequency The numeric fft and numeric invfft functions accept options Use the Symbolic option to prevent the conversion of your data to floating point numbers For example create a list of the following exact values exactData sin 1 3 2 PI n 10 n 0 3 UT E in 27 V
595. utations The set C of complex numbers The set of positive integers 7 1 a The set 2 of rational numbers 2 The set F of real numbers The set of integers 3 229 3 Mathematics Special Functions Available in MuPAD 3 230 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Dirac and Heaviside Functions on page 3 230 Gamma Functions on page 3 230 Zeta Function and Polylogarithms on page 3 231 Airy and Bessel Functions on page 3 231 Exponential and Trigonometric Integrals on page 3 231 Error Functions and Fresnel Functions on page 3 232 Hypergeometric Meijer G and Whittaker Functions on page 3 232 Elliptic Integrals on page 3 233 Lambert W Function omega Function on page 3 233 Dirac and Heaviside Functions The following MuPAD functions represent the Dirac 6 distribution and the Heaviside step function You can use these functions as input for your computations MuPAD can return results in terms of these functions dirac Dirac function heaviside Heaviside function Gamma Functions MuPAD provides the following functions to represent the 6 function function and other related special functions You can use these functions as input for your computations MuPAD can return results in terms of these functions beta p function Special Functions Available in MuPAD binomial Binomial expression HK gamma I fu
596. ute value of Zeta function n J plot abs zeta 1000000001 2000000000 I y y 0 30 AxesTitles y zeta 3 239 3 Mathematics 3 240 zetal To see more details of the function plot near the possible zero zoom the plot To see that the numeric result is incorrect enlarge that part of the function plot beyond the numeric working precision and then reevaluate the plot When you zoom and reevaluate MuPAD recalculates the part of the function plot with the increased numeric precision Note When zooming MuPAD does not automatically reevaluate the function plot 2 To get accurate results after zooming the plot use the Recalculate button u After zooming and reevaluating the plot you can see that the function does not have a zero at that interval Floating Point Arguments and Function Sensitivity zetal 6 0e 9 3 06 9 4 0e 9 2 le 8 1 0e 8 0 0e 0 1413472512 14143472514 1413472516 14 13472518 1 0e 9 y 3 241 3 Mathematics Integral Transforms 3 242 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Fourier and Inverse Fourier Transforms on page 3 242 Laplace and Inverse Laplace Transforms on page 3 245 Fourier and Inverse Fourier Transforms There are several commonly used conventions for defining Fourier transforms MuPAD defines the Fourier transform FT as F w c f Fi ivt dr Here C and s are the parameters o
597. value command linalg eigenvalues G linalg eigenvalues F linalg eigenvalues A B 11 242 242 1 i 10j 0 43 7 4 37 7 4 357 43 1 30 Perform Computations To see all the functions available in this library enter info linalg in an input region You can obtain detailed information about a specific function by entering functionname For example to open the help page on the eigenvalue function enter linalg eigenvalues Solve Equations Solve Equations with One Variable To solve a simple algebraic equation with one variable use the solve command solve x 5 8 x 4 23 x 3 51 x 2 94 x 120 0 x Solving Equations with Parameters You can solve an equation with symbolic parameters solve a x 2 b x c O x btc b c Load Lise i E if a 0Ab 0 b e if a 0Ab 0acz 0 where age i g y D 4ac If you want to get the solution for particular values of the parameters use the assuming command For example you can solve the following equation assuming that a is positive solve a x 2 b x c O x assuming a gt O 1 31 l Getting Started fa FR be b 4ac b b 4ac 2a l 2a For more information see Using Assumptions Solve Systems of Equations You can solve a system of equations solve x 2 x y y 2 1 x 2 y 2 0 x y x v3 y 4 3 x v3 y ESI x l y IL x l y or you can solve a system of e
598. veOnly TRUE then S select S testtype Type Positive end_if return S end proc If you call solveQuadraticEqn without the PositiveOnly option the procedure returns all solutions of the quadratic equation 9 61 5 Programming Fundamentals 9 62 solveQuadraticEqn 2 3 9 58 If you use the PositiveOnly option the procedure returns only positive solutions solveQuadraticEqn 2 3 9 PositiveOnly 7 By default prog getOptions does not error when it finds an unexpected option an option that is not listed in the table of accepted options Instead it collects all unexpected options and returns them in a separate list Thus the procedure solveQuadraticEqn does not issue an error when you spell the option name incorrectly solveQuadraticEqn 2 3 9 Positive 58 The prog getOptions function can issue an error when it finds an unexpected option In a function call to prog getOptions the fourth argument indicates whether prog getOptions must silently collect unexpected options or issue an error This argument is optional By default it is set to FALSE To issue an error instead of listing unexpected arguments use TRUE as the fourth argument of prog getOptions solveQuadraticEqn proc a Type Numeric b Type Numeric C Type Numeric local options S begin options prog getOptions 4 args table PositiveOnly FALSE TRUE S solve a x 2 b x c 0 x if options 1 Posi
599. veral assumptions for the same object each new assumption overwrites the previous one assume h in R assume h 0 is h in R is h lt gt 0 3 117 3 Mathematics 3 118 UNKNOWN TRUE If you want to keep the previous assumption while adding a new one see Adding Assumptions The assume command cannot solve assumptions in the form of equations and does not assign values to the variables assume g 5 14 8 and 2 t 14 h g r2 2 i f 7 ata When you set an assumption in the form of an inequality both sides of the inequality must represent real values Inequalities with complex numbers are invalid because the field of complex numbers is not an ordered field For example if you try to use the following assumption MuPAD returns an error assume t gt 2 I Error Assumptions are inconsistent property assume You can use complex values in an assumption written in the form of an equation assume t 2 PI I Add Permanent Assumptions When you set an assumption on an object MuPAD replaces the previous assumptions on that object with the new assumption assume x in Z assume x in R is x i Z J4 is X in R UNKNOWN TRUE To add a new assumption without removing the previous assumptions use the assumeAlso command Use Permanent Assumptions assume x in Z assumeAlso x in R is x in Z is x in R TRUE TRUE Also you can set multiple assumptions in one function c
600. ving Special Functions on page 3 110 Verify Solutions Involving Special Functions on page 3 110 Simplify Special Functions Automatically MuPAD provides many special functions commonly used in engineering and science MuPAD uses standard mathematical notations for special functions If you do not recognize a notation see Mathematical Notations Uses in Typeset Mode Particular parameter choices can simplify special functions Often MuPAD handles such simplifications automatically For example the following parameters reduce hypergeometric functions to elementary functions hypergeom hypergeom 1 hypergeom a z Z Z Convert Expressions Involving Special Functions Use General Simplifiers to Reduce Special Functions MuPAD does not automatically simplify some functions For example it does not automatically simplify the Meier G special function meijerG 1 z Gl z oiri The general simplification functions simplify and Simplify represent this expression in terms of elementary functions simplify meijerG 1 z MuPAD also does not use automatic simplifications for many expressions involving special functions Suppose you get an expression containing the Fresnel sine integral function 2 fresnelS z fresnelS z S z 2 S z To apply the reflection rule fresnelS z fresnelS z and simplify this expression explicitly call one
601. w To close Print Preview click the Close button on the Print Preview toolbar Print Documents from Print Preview Suppose you like the way your document appears in the Print Preview window and want to print the document To print a document directly from Print Preview click the Print button on the Print Preview toolbar Use Print Preview 7 MuPAD Help Print Preview When you print directly from Print Preview you can select and print specific pages To print a particular page Open Print Preview Click the Print button in the Print Preview toolbar In the resulting dialog box click the Pages option under Page Range Aa O NO Type the number of the page you want to print To specify a range of pages use a hyphen For example to print the second third and fourth pages type 2 4 If your document is wide and does not fit the page use the Print Preview toolbar to adjust the document before printing When you print a wide document from the Print Preview window MuPAD does not prompt you to scale your document down MuPAD prints documents exactly as you see them in the Print Preview window Save Documents to PDF Format If you like how your document appears in the Print Preview window you can save it to PDF format without leaving Print Preview To save a document as a PDF from the Print Preview window click the Save as PDF button on the Print Preview toolbar 7 MuPAD Help Print Preview PDF files created with
602. which fonts are available on your machine open the menu Format submenu Font in your MuPAD notebook The first column in the font dialog provides the names of the font families that you may specify You may also specify one the three generic family names Serif Sans serif or monospace and the size j o CNN NEN system will automatically choose one of the available font families of the specified type for you text alignment in case of new lines one of the flags Left Center or Right color In the following example we specify the font for the canvas header am S1Z col 6 168 Fonts plot plot Function2d sin x x 0 2 PI Header The sine function HeaderFont monospace 14 Bold The sine function 0 5 0 5 1 0 All font parameters are optional some default values are chosen for entries that are not specified For example 1f you do not care about the footer font family for your plot but you insist on a specific font size you may specify an 18 pt font as follows plot plot Function2d sin x x 0 2 PI Footer The sine function FooterFont 18 6 169 6 Graphics and Animations 0 0 The sine function 6 170 Colors Colors Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB RGB Colors on page 6 171 HSV Colors on page 6 174 The most prominent plot attribute available for all primitives i
603. with different distributions by using them to position random points ri stats normalRandom O 1 group1 plot Group2d plot Point2d r1 r1 i 1 200 r2 stats uniformRandom 3 3 group2 plot Group2d plot Point2d r2 r2 i 1 500 plot group1 group2 Axes Frame 6 157 6 Graphics and Animations 6 158 We cannot distinguish between the two kinds of points Due to the grouping it is very easy to change their color and size by setting the appropriate attributes in the groups Now the two kinds of points can be distinguished easily groupi PointColor RGB Red groupi PointSize 1 5 unit mm group2 PointColor RGB Blue group2 PointSize 1 3 unit mm plot group1 group2 Axes Frame Transformations Transformations Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Affine linear transformations x A x with a vector b and a matrix A can be applied to graphical objects via transformation objects There are special transformations such as translations scaling and rotations as well as general affine linear transformations plot Translate2d b1 b2 Primitivei Primitive2 applies the translation x x 4 by the vector b b1 b2 to all points of 2D primitives plot Translate3d b1 b2 b3 Primitivel applies the translation x x b by the vector b b1 b2 b3 to all points of 3D primitives
604. x To extract the real and imaginary parts of y use the Re and Im functions Re y Im y sm 2 ix cosh 2 S x cos 2 9R x sinh S x cosh 2 S x cos 2 Rix Rewrite Expressions in Terms of Other Functions To present an expression in terms of a particular function use the rewrite command The command uses mathematical 1dentities between functions For example rewrite 3 100 Choose Simplification Functions an expression containing trigonometric functions in terms of a particular trigonometric function sin X rewrite sin x cos x rewrite cos x Sin 2 x cOS 3 X 2 tan tan rewrite sin 2 x cos 3 x 2 tan tan i cos x tan z 1 Lai 2 tan x tan x 1 Use rewrite to express the trigonometric and hyperbolic functions in terms of the exponential function sin x rewrite sin x cos x rewrite cos x sinh x rewrite sinh cosh x rewrite cosh o eti eti sm x ni m xi r yvi Cos l x TII E e7 sinh x 2 ta T exp exp exp exp J J X J X J 101 3 Mathematics 3 102 de d AX cosh x The command also expresses inverse hyperbolic functions in terms of logarithms arcsinh x rewrite arcsinh x ln arccosh x rewrite arccosh x Ln a i a ie ee i 2 arcsinh x In xax l arccosh x tn x yx 1J As target functions rewrite a
605. x x x sm x dx 2x sinx cos x lx 2 Also you can prevent evaluation of an object by using the level function with the second argument 0 When you use level to prevent evaluation of identifiers the results are equivalent to the results obtained with the hold function level int x 2 sin x x 0 j T a oa J x sinx dx The level function only prevents evaluation of 1dentifiers If you create a function without a name for example x sim x level does not prevent evaluation of that function level x gt sin x PI O 0 3 19 3 Mathematics 3 20 In this case use the hold function to prevent evaluation For example hold successfully prevents evaluation of the function x stn x at the point x m hold x sin x PI x smx T Both hold and level functions prevent the evaluation of an object only in the particular computation in which you explicitly use them These functions do not prevent further evaluations For example if you assign an expression containing hold to a variable and then call that variable MuPAD evaluates the expression hold int x 2 sin x x J x sm x dx 2 x sin x cos x x 2 y y Actual and Displayed Results of Evaluations Actual and Displayed Results of Evaluations Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When MuPAD evaluates an expression or executes a command the output that t
606. x 7 x 4a 426545 b x lla d For rational expressions you can use the partfrac command to present the expression as a sum of fractions partial fraction decomposition For example partrrac 7 x 2 4 7 x 8 X 9 4 29502 24 1 x a x 1l y4x41 MuPAD also provides two general simplification functions Simplify and Simplify The simplify function is faster and it can handle most of the elementary expressions simplify x 1 x 1 x 2 x 1 x 2 1 x 2 X 1 x 4 x 2 1 i ed The Simplify function searches for simpler results deeper than the simplify function The more extensive search makes this function slower than simplify The Simplify function allows you to extend the simplification rule set with your own rules and serves better for transforming more complex expressions For the elementary expressions it gives the same result as simplify Simplify x 1 x 1 x 2 x 1 x 2 1 X 2 x 1 x 4 x 2 1 S For the following expression the two simplification functions give different forms of the same mathematical expression Perform Computations f exp wrightOmega 1n 3 5 exp ln 5 1n 3 simplify f Simplify f Note that there 1s no universal simplification strategy because the meaning of the simplest representation of a symbolic expression cannot be defined clearly Different problems require different forms of the same mathematical expression Y
607. x x 1 1 To get more real solutions of a single equation containing one variable call the numeric solver with the option AllRealRoots The AllRealRoots option does not guarantee that the solver finds all existing real roots For example the option helps to find additional solutions for the equation numeric solve sin 1 x x x AllRealRoots Warning Problem in isolating search intervals Some roots might be lost numeric al 1 0 8975394613 0 3606716807 0 1553007909 0 1073278873 0 07907931072 0 060392778175 0 05290310069 0 0455672924 0 039725392668 0 03179879680 0 0289615375 0 01988649969 0 01591146474 0 007402961185 0 007402961185 0 01591146474 0 01988649969 0 0289615375 0 03179879686 0 03972597668 0 04556 72924 0 05290310069 0 06392228125 0 07907931072 0 1073278873 0 1553007909 0 3606716807 0 8975394613 3 77 3 Mathematics 3 78 For a system of nonpolynomial equation the solver also returns only one solution Plotting the equations you see that the system has more than one solution numeric solve sin x y 2 1 cos x y x yl plot sin x y 2 1 5 cos x y 4 x 2 1 570796327 y 0 00000000025993 18689 t The AllRealRoots option does not work for systems numeric solve sin x y 2 1 cos x y x yl AllRealRoots Error Only one equation is allowed with the AllRealRoots option numeric so
608. x 3 y x 0 DM uL C Ko 5 3 FO Jx x WX i Ox For this ODE the solver returns the result in terms of the Bessel functions S solve ode eq y x To verify correctness of the returned solution try substituting it into the original equation by using evalAt or its shortcut You get the following long and complicated result that still contains the Bessel special functions MuPAD does not automatically simplify this result eq y x S 1 3 111 3 Mathematics where m 9 4 x E1 96 G 3 x a i 2r L1 9 G 3 _x 2 G AX Simplifying this expression proves the correctness of the solution 3 112 Convert Expressions Involving Special Functions simplify eq y x S 1 TRUE The testeq command serves best for verifying correctness of the solutions The command automatically simplifies expressions on both sides of the equation testeq eq y x S 1 TRUE For more information see Testing Results 3 113 3 Mathematics When to Use Assumptions 3 114 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB By default MuPAD assumes that all symbolic parameters and variables represent complex numbers If you perform computations that involve unknowns with natural restrictions you can set assumptions on these unknowns For example when solving an equation where one of the parameters represents real numbers requ
609. xample create the function f that computes the reciprocal of a number Use prog remember to enable the remember mechanism for this function In the prog remember function call specify the dependency function The dependency function 1s the function that computes the current properties of the input arguments and the values of DIGITS and ORDER Then prog remember compares this context information with the context information used to compute the remembered values If the context information 1s the same prog remember returns the remembered result Otherwise MuPAD evaluates the current procedure call and adds the new result to the remember table Note The option remember does not let you specify the dependency function If results of a procedure depend on the context information use the prog remember function for that procedure In this example the dependency function is a list that checks both the properties of input arguments and the value of DIGITS T T d X 1 0 x prog remember f gt property depends args DIGITS The default number of significant digits for floating point numbers is 10 Use the function f to compute the reciprocal of 3 The system displays the result with the 10 digits accuracy T 3 0 3333333333 Remember Mechanism If you set the number of digits to 50 and then call the function f with the same argument 3 prog remember realizes that the number of digits has changed Instea
610. xes appearance grid lines tick marks line and marker styles Apply affine transformations to a plot You can scale rotate reflect or move a plot Set cameras for a 3 D plot See the MuPAD gallery of plots To see all functions available in the MuPAD graphics library enter info plot Basic Plotting Create 2 D Plots The simple way to create a 2 D plot of a function is to use the plot command plot sin x cos 3 x Use Graphics Create 3 D Plots The simple way to create a 3 D plot of a function 1s to use the plot command with the option 3D plot sin x sin y 3D Note By default for a function of two variables the plot command creates a 2 D animation Using the option 3D lets you create a 3 D plot instead of a 2 D animation Plot Multiple Functions in One Graph To plot several functions in one figure list all the functions separating them by commas MuPAD uses different colors when plotting multiple functions plot sin x cos x tan x cot x 1 41 l Getting Started You can use the sequence generator to create a sequence of functions plot sin k x k 1 3 1 42 Use Graphics WIE UH You also can plot multiple functions in one 3 D graph plot sqrt r 2 x 2 y 2 r 1 5 3D l Getting Started Specify Plot Ranges You can specify a range over which to plot a function plot sin x 3 exp x x 3 5 1 44 Use Graphics m sull An MUTA l G
611. xt z is a complex number Computing the sign of expr2text z as z z 9 85 5 Programming Fundamentals z abs z else print Unquoted expr2text z is a real number print Unquoted Is expr2text z a positive number if z gt 0 then print Unquoted expr2text z is a positive number 1 else print Unquoted expr2text z is not a positive number print Unquoted Is expr2text z a negative number if z lt 0 then print Unquoted expr2text z is a negative number 1 else print Unquoted expr2text z is not a negative number print Unquoted expr2text z is zero 0 end if end if end if end proc Now the procedure S displays the status messages S 0 Is 0 a real number O is a real number Is 0 a positive number O is not a positive number Is 0 a negative number O is not a negative number O is zero 9 86 Display Progress 5 87 5 Programming Fundamentals Use Assertions 9 88 Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If you rely on correctness of particular statements for your code then consider including these statements in the code Such statements are called assertions Assertions help you remember specific conditions under which you expected to execute your code They can also help other developers who might need to review or update your code MuPAD lets you use checked assertions If you switch to
612. y numApprox t 1 nume pprox t 2 Use the plot Curve2d plotting function to generate a parametric plot of the numeric solution curve plot Curve2d numApprox t 1 numApprox t 2 t 0 20 plot curve 3 87 3 Mathematics 02 03 04 05 Alternatively use plot 0de2d or plot Ode3d 3 88 Use General Simplification Functions Use General Simplification Functions Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB When to Use General Simplifiers on page 3 89 Choose simplify or Simplify on page 3 90 Use Options to Control Simplification Algorithms on page 3 90 When to Use General Simplifiers Simplification of mathematical expression is not a clearly defined subject There is no universal idea as to which form of an expression is simplest The form of a mathematical expression that is simplest for one problem turns out to be complicated or even unsuitable for another problem For example the following two mathematical expressions present the same polynomial in different forms x 1 x 2 x 3 x 4 x 2x 13x 14 x 24 The first form clearly shows the roots of this polynomial This form is simpler for working with the roots The second form serves best when you want to the coefficients of the polynomial If the problem you want to solve requires a particular form of an expression the best approach 1s to choos
613. y including solvers and simplifiers These improvements can cause different releases of MuPAD to return different forms of the same symbolic expressions For example when you solve the equation eq ode y t a 2 y t y O 1 y PI a 0 y t MuPAD 5 1 R2008b returns solution solve eq eval solution assuming a lt gt 0 cos a t J For the same equation MuPAD 5 2 R2009a returns solution solve eq eval solution assuming a lt gt 0 l ati EE 2 2 Note testeq cannot compare sets To test mathematical equality of the solutions returned as sets compare each pair of the solutions individually 3 67 3 Mathematics 3 68 If a returned solution differs from what you expect test mathematical equality of the solutions testeq cos a t 1 exp a t I 2 exp a t I 2 TRUE Verify Equivalence of Solutions Containing Arbitrary Constants Equal Arbitrary Constants Verifying solutions with arbitrary constants can be a lot more complicated than verifying simple solutions without constants In such solutions consider arbitrary constants as symbolic parameters In simple cases you can assume that the parameters are equal For example solve the following ordinary differential equation The form of the returned solution depends on the type of an equation The solver can identify an equation with different equation types reset 0 ode y X 1 x 2 I y x 1 x y x 2 y x 01
614. y domains are listed in Library Domains Other library domains are listed in the corresponding libraries For example you can find the library domain solvelib BasicSet of the basic infinite sets under the Utilities for the Solver category The library domains are written in the MuPAD programming language You also can create your own library domains Overloading works differently for the basic domains and the library domains The system can overload any method of a library domain For basic domains the system overloads only some methods Expression Types The basic domain DOM EXPR includes MuPAD expressions such as expressions created by arithmetical or indexed operators statements and function calls MuPAD classifies the elements of the domain DOM EXPR further by defining expression types Expression 5 3 5 Programming Fundamentals 9 4 types provide more detailed information about a particular expression For example you might want to know whether the expression is an arithmetical expression such as a sum or a product a Boolean expression a function call or some other type of expression For these expressions the domtype function returns their domain type DOM EXPR domtype a b domtype a b domtype a and b domtype sin a domtype a b DOM EXPR DOM EXPR DOM EXPR DOM EXPR DOM EXPR To find the expression types of these expressions use the type function type a b type a b type a and b type
615. y in the MuPAD Notebook Interface This functionality does not run in MATLAB When computing integrals MuPAD applies strict mathematical rules For example integrate the following expression int arcsin sin x x ERN x sign cos x 2 If you want a simple practical solution try the IgnoreAnalyticConstraints option With this option MuPAD uses a set of simplified mathematical rules that are not generally correct The returned results might be shorter and more useful for example int arcsin sin x x IgnoreAnalyticConstraints i SE 68 bal If an Integral Is Undefined If an Integral Is Undefined Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB If one of the following conditions is true a definite integral f f x dx might not exist in a v a strict mathematical sense Ifthe interior of the integration interval a b contains poles of the integrand f x Ifa oorb oor both If f x changes sign at all poles in a b the so called infinite parts of the integral to the left and to the right of a pole can cancel each other In this case use the PrincipalValue option to find a weaker form of a definite integral called the Cauchy principal value For example this integral is not defined because it has a pole at X O int 1 X X 1 1 undefined To compute the Cauchy principal value call int with the option PrincipalValue int 1 x x 1 1 Prin
616. y paper size margin size orientation and background color for your pages a Page Format Paper Size Letter 216 x 279 mm Paper Width 215 90 Paper Height 279 40 Page Margins 19 76 Orientation Portrait J Landscape Des EJ Lo ev j Cms MuPAD saves your page settings with a notebook These settings do not affect other existing or new notebooks 2 122 Print Wide Notebooks Print Wide Notebooks Note Use only in the MuPAD Notebook Interface This functionality does not run in MATLAB Before printing a notebook that displays wide graphics or long lines in the input or output regions use Print Preview to see how the content fits the page Print Preview makes it easier to view and adjust wide documents Alternatively wrap and then unwrap text in a notebook by using the option View gt Wrap To Window When you wrap text in a notebook and then unwrap it the vertical line appears This line shows you the position of the right margin of the current page format When you print a notebook that does not fit the page format MuPAD prompts you to select one of the following options Print only the part of the notebook to the left of the margin Scale the whole notebook to the size that fits the page format i Page too small i The width of the document exceeds the available print area Should the document be trimmed or scaled to fit the print area Trim Right Scaleto 49 Cancel Also
617. y x exp x y x 3 45 3 Mathematics L wire JV 2 X Of F 1 solvel y x y x yix yx For ODEs that cannot be solved symbolically try using numeric solvers Initial and Boundary Value Problems Many problems in engineering and physics involve solving differential equations with initial conditions or boundary conditions or both To specify initial or boundary conditions create a set containing an equation and conditions For example state the following initial value problem by defining an ODE with initial conditions IVP ode y x y x y 0 5 y 0 1 y x ode y 0 1 y x p x 0 5 x When you solve an ODE with initial or boundary conditions the solver adjusts the integration constants to fit these conditions solve IVP fa e 43 e The following equation has both initial and boundary conditions ode solve y x y x y 0 0 y 5 1 y 0 0j y x 3 46 Solve Ordinary Differential Equations and Systems Each independent condition removes one integration constant ode solve y X y x y x lei C19 amp C18 2 ode solve y x y x y 0 0 y x 24 C23 e e C23 C ode solve y X y x y 0 0 y 1 1 y x X Fy EE i n 2 5 G C28 e C28e _e e C28e C28e E 9 ode solve iy x y x y 0 0 y 1 1 y 0 1 2 y x Dm 4e e 1 e e 1 2 e 2le 1 2 e 2e 1 2
618. ylor series expansions approximate expressions for which the derivatives up to infinite order exist around a particular value x of a variable x x x l 2 0 HH To compute Taylor series expansion use the taylor command For example approximate the expression sin X X around x 0 exact sin x x approx taylor sin x x x 2 4 r BN 1 X 4X o0 x 6 010 Plot the exact expression and its taylor series expansion in the same coordinate system The taylor series expansion approximates the expression near X O but visibly deviates from sin Xx x for larger x plot plot Function2d exact x PI PI Legend sin x x Color RGB Red plot Function2d approx x PI PI Legend approximation of sin x x Compute Taylor Series for Univariate Expressions Wm sin xy x WR approximation of sin x x Accuracy of an approximation depends on the proximity to the expansion point and on the number of terms used in the series expansion See how to specify the number of terms in Controlling the Number of Terms in Series Expansions Taylor series expansions around X O are also called Maclaurin series expansions Approximate the expressions by Maclaurin series taylor exp x taylor sin x taylor cos x u nl P mm I X a X gt 3 T y Fa l x 4_4 2 Bx Bx Olx TD X4 dou j L 2 24 24 3 157 3 Mathematics 3 158 The Maclaurin series exp
619. you can change the page format When you print a wide document from the Print Preview window the above dialog box does not appear Use the Print Preview toolbar to adjust the document before printing MuPAD prints documents exactly as you see them in the Print Preview window 2 123 Mathematics Evaluations in Symbolic Computations on page 3 5 Level of Evaluation on page 3 8 Enforce Evaluation on page 3 16 Prevent Evaluation on page 3 19 Actual and Displayed Results of Evaluations on page 3 21 Evaluate at a Point on page 3 23 Choose a Solver on page 3 25 Solve Algebraic Equations and Inequalities on page 3 28 Solve Algebraic Systems on page 3 34 Solve Ordinary Differential Equations and Systems on page 3 44 Test Results on page 3 56 If Results Look Too Complicated on page 3 62 If Results Differ from Expected on page 3 67 Solve Equations Numerically on page 3 73 Use General Simplification Functions on page 3 89 Choose Simplification Functions on page 3 93 If You Want to Simplify Results Further on page 3 103 Convert Expressions Involving Special Functions on page 3 108 When to Use Assumptions on page 3 114 Use Permanent Assumptions on page 3 116 Use Temporary Assumptions on page 3 122 Choose Differentiation Function on page 3 127 Differentiate Expressions on page 3 128 Differentiate Functions on page 8 130 Com
620. you or someone else edits your code later or when you need to integrate parts of the program written by different developers MuPAD provides tools for unit testing your code These tools let you write and execute your own test scripts for a particular part of your code for example for a function or a procedure Suppose you create the procedure that accepts two numeric arguments a and b compares them and returns the larger number f proc a Type Numeric b Type Numeric begin if a bor a gt b then return a else return b end_if end proc The type Type Numeric includes integers rationals floating point numbers and also complex numbers Therefore any complex numbers are valid arguments of the procedure f The procedure f has a flaw in its design because you cannot compare two complex numbers If you call this procedure for two different complex numbers the procedure call results in an error Nevertheless the procedure works if you call it for equal complex numbers T I I Suppose you decide to keep the procedure f as 1t 1s It works for equal complex arguments The error only occurs when the complex arguments are not equal Later Why Test Your Code you or somebody else forgets about the issue with complex numbers but sees that the procedure can be improved as follows f proc a Type Numeric b Type Numeric begin if a gt b then return a else return b end_if end proc This code looks shorter an
621. ystems of type plot CoordinateSystem2d or plot CoordinateSystem3d exist inside a 2D scene or a 3D scene respectively There may be one or more coordinate systems in a scene Each coordinate system has its own axes In the following example we place two coordinate systems in one scene The first is used to display the sales of apples in the years 1998 through 2003 in units of 1000 tons the second is used to display the sale of cars in units of 10 000 cars The y axis for the apples is flushed left by setting the x component of its origin to the first year 1998 whilst the y axis for the cars 1s flushed right by setting the x component of its origin to the last year 2003 apples plot Polygon2d 1998 7 4 1999 7 8 2000 7 7 2001 8 3 2002 8 0 2003 8 5 Color RGB Red PointsVisible TRUE cars plot Polygon2d 1998 3 2 1999 3 5 2000 3 7 2001 3 7 2002 4 0 2003 4 1 Color RGB Blue The Full Picture Graphical Trees PointsVisible TRUE plot plot Scene2d plot CoordinateSystem2d apples ViewingBoxYRange 0 10 YAxisTitle apples 10 3 tons Axes Origin AxesOriginX 1998 XTicksNumber None XTicksAt 1998 2003 plot CoordinateSystem2d cars ViewingBoxYRange 0 5 YAxisTitle cars 10 4 Axes Origin AxesOriginX 2003 XTicksNumber None XTicksAt 1998 2003 apples 10 3 tons A _ cars 10 4 h3 i d on GO SS fo wo
622. zcTa if x0 solve also can return an expression as X in S where X is a list of variables for which you solve an equation and S is a set of the solution vectors solve a x 1 x Solve Higher Order Polynomial Equations When you solve a higher order polynomial equation the solver sometimes uses RootOf to return the results solve x 3 2 x 1 O x RootOf z 2 z 4 1 z To get an explicit solution for such equations try calling the solver with the option MaxDegree The option specifies the maximal degree of polynomials for which the solver tries to return explicit solutions By default MaxDegree 2 Increasing this Solve Algebraic Equations and Inequalities value you can get explicit solutions for higher order polynomials For example specify MaxDegree 3 and get explicit solutions instead of RootOf for the third order polynomial solve x 3 2 x 1 0 x MaxDegree 3 o my Ir u dl s 888 2 108 2j When you solve a fifth or higher order polynomial equation the solver might be unable to return the solution explicitly even with the option MaxDegree solve x 5 2 X 1 0 X solve x 5 2 x 1 0 x MaxDegree 5 RootOf Z 2 z 1 z RootOf z 2221 z In general there are no explicit expressions for the roots of polynomials of degrees higher than 4 Setting the option MaxDegree to 4 or a higher value makes no difference RootOf symbolically represents the set of the

Download Pdf Manuals

image

Related Search

Related Contents

Planar Systems PX212M  Série 10 - 4010 Gear Publié le 23 Juin 2014 4,44 mb  Simply swing XL  Nanoxx 9600 IP - TELE-audiovision Magazine  

Copyright © All rights reserved.
Failed to retrieve file