![]() |
Basics of MuPADBrown University, Applied Mathematics |
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, 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.
For instance, you can select to only run a section of your code instead of all of it.
Try typing into the top text line and executing a simple calculator function:
This is a test
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. MuPAD inputs will appear in red and the corresponding outputs below it are 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
The imaginary unit along the vertical axis is represented in MuPAD by the symbol I in the input and an upright i in the typeset output.
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)
\[
\frac{\sqrt{2}}{3} - \frac{i}{3}
\]
The functions Re and Im return the real part \(x \) and the imaginary part \( y \) ,
respectively, of a complex number \(x + y i\) . The functions conjugate, abs, and arg
compute the complex conjugate \(x - y i\) , the absolute value \( |x + y i | = \sqrt{x^2 + y^2}\) ,
and the polar angle, respectively:
Re(1/(sqrt(2) + I)), Im(1/(sqrt(2) + I)),
conjugate(1/(sqrt(2) + I)),
abs(1/(sqrt(2) + I)), arg(1/(sqrt(2) + I)),
rectform(conjugate(1/(sqrt(2) + I)))
\[
\frac{\sqrt{2}}{3} , \quad -\frac{1}{3} , \quad \frac{1}{\sqrt{2} -i}
, \quad \frac{\sqrt{3}}{3} , \quad -\arctan \left( \frac{\sqrt{2}}{2}
\right) , \quad \frac{\sqrt{2}}{3} + \frac{i}{3}
\]
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.
Home |
< Previous |
Next > |