MuPAD is a registered trademark of SciFace Software GmbH & Co. KG. MATLAB and Simulink
are
registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks
for a list
of additional trademarks. Prior to the R2016a release of MATLAB® (March 2016), the MuPAD Notebook was the primary interface for performing and
documenting symbolic math calculations. Starting in R2016a, the recommended approach is to use the MATLAB Live Editor.
In contrast to numerical computations, there are symbolic computations in
computer algebra as computations with symbols
representing mathematical objects. Here, an object may be a number, but also a
polynomial, an equation, an expression or a formula, a function, a group, a ring,
or any other mathematical object. Symbolic computations with numbers are
carried out exactly.
Most of the current computer algebra systems can be used interactively. The user
enters some formulae and commands, and the system evaluates them. Then it
returns an answer, which can be manipulated further if necessary.
Moreover, modern computer algebra systems provide a powerful programming
language (since the MuPAD is a version of Maple, its programming language is structured similarly to Pascal, with extensions such as language
constructs for object oriented programming) and tools for visualization and animation of mathematical data. Also,
many systems can produce layouted documents (known as notebooks or
worksheets). The MuPAD system has such a notebook concept, but we will only
sketch it briefly in this tutorial. Please check the user interface documentation
instead for more details. The goal of this tutorial is to give an introduction to the
mathematical power of the MuPAD language.
MATLAB is computer programming language used for numerical calculation and systems modeling. Its popularity has been growing over the past few years and has become one of the standards for use in many engineering and applied mathematical practices. MuPAD is a simple sub-language of MATLAB based on Maple's coding style. MuPAD is by far the quickest method of symbolic calculation in MATLAB, and remains mostly as powerful as Maple™. MuPADs can handle complex integration and differentiation, systems of equations, linear algebra functions, plotting, and more in mere seconds. For previous users of Maple, most of the syntax will be very similar. The goal of this tutorial is to touch on the MuPAD Notebook and show how it can be used as a quicker method of calculations, especially for homework applications.
Double click your MATLAB Icon to open the MATLAB GUI. Then you can start MuPAD by typing
>> mupad
You will see the screen that should appear
This is your MuPad shell. You can type commands into this window, and it will solve problems for you. You can type commands into this window, and it will compile them automatically and give you an answer. The shell is great, but it works off of Random Access Memory and will not save your variables or work once you close the program. This is why most people write a script, or a savable document that can perform your calculations through the shell. To open an existing MuPAD file with the extension .mu in the MATLAB Editor, double-click the file name or select Open and navigate to the file. After editing the code, save the file. Note that the extension .mu allows the Editor to recognize and open MuPAD program files.
For our purposes, we want to launch the MuPad Notebook. This is simply a program inside of MATLAB that works better for the calculations we will be making. Most of the buttons should be self-explanatory.
NOTE: MuPAD distinguishes between uppercase and lowercase. Most common errors are found because a variable word was either spelled wrong or had some form of wrong capitalization.
In a MuPAD™ notebook, you can convert characters in the text region to Greek letters one at a time:
a) Select the character you want to convert or place the cursor to the right of the character.
b) Select Edit>Toggle Greek.
For example, display the Greek letter δ by typing d and then placing your cursor to the right of d and selecting Edit>Toggle Greek.
Symbol::new(symname) or simply Symbol(symname) creates the typesetting symbol corresponding to symname.
The typesetting symbols can be accessed in two different ways: Most symbols can be input by typing Symbol::symname, where symname is taken from the lists in the introduction. For some symbol names (such as not or I), this is not possible in the MuPAD® language. What is possible in any case is to invoke Symbol as a function, taking a string representation as its argument, as in Symbol("not").
Any line with an open bracket “ [ ” is a calculation line. Work in calculation lines will appear in red text and their answers will appear in blue text. All other lines are considered comments and plain text, so they will appear in plain black text, and will not be executed as functions. A new calculation line can be made by pressing the red pi button, and a new line of text with the blue paragraph button.
Pressing [Enter] after a line of code will execute that code (in a calculation line). You can change code at any time, and re-calculate it by going to it and pressing [Enter] again. Or if you have several lines to run at once, the first few choices under the drop-down menu “Notebook” will give you options for how to re-run your code after making changes.
Try typing into the top text line and executing a simple calculator function:
This is an arithmetic test:
[ 2+2
4
[
Notice that a new calculation line will automatically appear after you execute your line of code. Remember that you can always create a new text line after a calculation answer by clicking after the answer on the same line and pressing the blue paragraph button.
When you are creating a large notebook for all your homework problems, it is a good rule of thumb to have many comments telling the grader what question you are on and what calculation you just performed. Sometimes it is best to suppress the answer after a calculation (aka – run the calculation but not have it display the answer). This may sound ludicrous, but you will probably find yourself wanting to suppress answers to save space and time in the future. A colon “ : ” after an expression will suppress its output, but still perform the calculation.
Example:
[ 2+2:
[
From this point onward, I will drop the brackets before a calculation line to make the command text easier to copy and paste into your own MuPad. Calculations will appear in red and the answers below it in blue.
In addition to exact symbolic computations, most computer algebra packages can approximate solutions numerically as well. The user can set the precision to the desired number of digits. In MuPAD®, the global variable DIGITS handles this. For example, if you enter the simple command DIGITS:= 100, then MuPAD performs all floating-point calculations with a precision of 100 decimal digits. Of course, such computations need more computing time and more storage than the use of hardware floating-point arithmetic. Here are some examples.Notice also that, unlike MATLAB, MuPAD returns the exact answer for sin(PI/3) because by default, MUPAD is not working with floating point numbers. It returns the exact answer to any calculation.
If you want to convert the answer into floating point representation, you need first to define how many decimal places you want to see in your output. This can be accomplished by typing:if you want to have 16 decimal places. For instance, if you want to see floating-point approximation of the previous output (sin(PI/3)), just type:
The output will be the same
0.86602540378443864
MuPAD knows many special functions. For example,
gamma(0.34)
2.624163256498484
besselJ(0.23,1)
0.7562982188935567
You can input complex numbers in the usual mathematical notation \(x + y i\) . Note that in engineering and computer science, the unit vector in the vertical direction is denoted by j but not i. Both
the real part \( x \) and the imaginary part \( y \) may be integers, rational numbers, or floating-point numbers:
(1 + 2*I)*(4 + I), (1/2 + I)*(0.1 + I/2)^3
2 + 9 i, 0.073 − 0.129 i
If you use symbolic expressions such as, e.g., sqrt(2), MuPAD may not return the
result of a calculation in Cartesian coordinates:
1/(sqrt(2) + I)
MuPAD distinguishes between uppercase and lowercase. The command
reset()
will clear all global variables so that you can start with a fresh set
of letters. Because MuPad reads code from top to bottom, the reset
command can be used in-between problems as a good way to clear the
variable cache.
Note that unlike the MATLAB command windows, MUPAD lets you go back and change any line, and will then let you execute the file again with changed code. The NOtebook menu gives lots of options for re-doing calculations after a correction.
You may recall that we claimed that symbolic notation in MuPAD is quite easy. As soon as you type a letter (excluding some restricted letters*) MuPAD will declare it automatically as a variable for you.
*a few exceptions, such as the lowercase letter "i" represents a given value as defined in the MuPAD syntax. More on this can be found in the MATLAB Documentation Center on the Web and searching for "MuPAD".
For example:
These are some basic commands that you can type into MuPAD and they will perform specific functions and calculations for you. It is necessary to know the difference between a command and a parameter. A command is a function that we will apply with parenthesis such as "solve(. . . )" and a parameter is a part of a command within the parenthesis that tells MuPAD to do a certain task or follow a certain rule when executing the command. A parameter can be the variable with which to integrate, or an exception to follow or ignore. Parameters will always be separated by commas. When it is necessary to have multiple elements in one parameter, brackets can be used to group these objects to the same parameter.
In most practical cases, numerical approximation to sums (particularly infinite sums) are the most useful tool. For more abstract summation techniques, please check out the MATLAB MuPAD documentation on the web.
The general format for summation will be
sum(function, n = lowerbound..upperbound)
This is very similar to the other functions we have been using - hopefully you are starting to get a hang of how most of the syntax works. Sometimes MuPAD can calculate an answer from the simple "sum" function, but usually you will have to use "numeric::sum" to get an answer. Here is an example:
Universities usually offer two courses on differential equations: one is just an introductory course (which requires basic knowledge of calculus), and another one presents further exposition of differential equations, including an introduction to partial differential equations. These courses form a main mathematical background for all students majoring in engineering, physics, geology, economics, biology, and other areas. In our days, information technologies play more and more significant role in modeling, therefore we observe a trend in an intensive use of available softwere packages. This tutorial is a part of introductory web sites that inform students, who are taking differential equations courses, with some applications of software packages that can be used. The tutorial accompanies the textbook Applied Differential Equations. The Primary Course by Vladimir Dobrushkin, CRC Press, 2015; http://www.crcpress.com/product/isbn/9781439851043
Therefore, the goal of this document is not to explain the material in the text; rather, it is to give you the tools to solve problems and to present the capabilities of available software packages as they are needed by someone studying the text. There are usually several different commands (or sets of commands) that will accomplish the same task. As a result, this tutorial will sometimes introduce several different ways to do the same thing. It is always good to be aware of these alternate pathways, but you are welcome to pick whatever notation you like the best. This tutorial can be used to introduce students who are taking the first course in differential equations (at Brown University, it is APMA 0330, Methods of Applied Mathematics - I) to a symbolic mathematical computation program MuPAD that is part of Matlab based on Maple. MuPAD is a great computer algebra system to use, especially if you are in applied areas where it is necessary to solve differential equations. MuPAD provides friendly tools to solve and plot solutions to differential equations. This computer algebra system has tremendous plotting capabilities.