MatCalc Online Tutorial
Key Words and Built in Functions
MatCalc Tutorial For Beginners
Increased interest in mathematical approaches to education and research in the physical and biological sciences has necessitated the availability of reliable, inexpensive software applications that can facilitate computations in general arithmetic, real and complex matrix and vector algebra. MatCalc has been developed over the past twelve years to assist in accomplishing that end. The basic application interface has been designed to serve as a fundamental building block with which an endless variety of optional application can be used.
At its simplest level, MatCalc is a calculator. It will accept an arithmetic expression, calculate its value, display the result and store it for a later use. MatCalc can perform the basic operations of addition, subtraction, multiplication, division, and finding the square root of both real and complex numbers. MatCalc can be also used for calculations that involve real and complex vectors and matrices. These include:
entering and editing matrices directly from the keyboard, to be saved and manipulated
loading and saving matrices to disk using several different file formats
manipulating matrices up to 100 x 100 and larger using up to 27 virtual memory storage registers
formatting both real and complex matrices
perfomance of common matrix operations such as transposition, inversion, finding the adjugate, doing fundamental row operations, Gaussian elimination (to row-reduced echelon form)
performance of common binary operations such as matrix addition, subtraction, multiplication, and integral exponentiation
scalar and elementwise operations including transcendental function ops
solving systems of simultaneous linear equations
performing numerous matrix evaluation tests such as determinant, rank, orthogonality, singularity, symmetry, size, and more.
parsing or evaluating matrix polynomial expressions, i.e., 3*A^3 - 2*A^2 + 14*A^ + A^0
perfoming linear optimization routines using the simplex method
basic operations on complex matrices such as addition, subtraction, multiplication, transposition, inversion, testing for Hermitian and unitary properties.
Advanced operations on complex Hermitian matrices such as finding the determinant, eigenvalues, eigenvectors, and diagonalization.
Calculating analytic matrix functions, i.e., sin, cos, exp, using matrix series expansion algorithms
Performing graphical analysis as it pertains to vectors and matrices.
Performing statistical analysis of data.
Save, load, and edit and solve linear programs.
Save, load, edit and solve matrix games.
1 - Before starting up the MatCalc application, use the Windows Explorer to navigate to create a directory in which to store your application data files and scripts. You should also include several subdirectories in this directory in order to make it easier to find certain categories of files more quickly. An example of this type of directory might look something like that below.
2 - Start the MatCalc application from the Start Menu or desktop icon. There should be at least two separate panels visible, the File View panel and the Command View panel. If these are not displayed, use the Desktop menu to bring them into view. You can drag these panes to a positional setup that you find personally convenient.
3 - From the File View panel toolbar, click on the Search button and navigate to the root directory that you have set up for the application data files. If the File View panel is not initially visible, use the Desktop menu and click on File View to add that view to the display.
4 - If the Command View panel is not initially visible, use the Desktop menu and click on Command View to add that view to the display. From the prompt >>> on the Command View you can type in arithmetic and algebraic commands. After each command, press the Enter button on your keyboard and the result of the command will be immediately visible. For example:
5 - Right clicking anywhere on the Command View will bring up the Command View Pop-Up menu.
The menu items are largely self-explanatory. The Display Variable List displays a list of the current variables. Highlighting a variable name selects that variable and choosing Show Selected Variable will display that variable. Similarly, highlighting a variable name in the list and selecting Delete Selected Variable will remove that variable from the list. Choosing Delete all variables will remove all the current variables from the list without the need to highlight any variable. The Function Browser is an application window that allows you to browse and search for the application built in key words as well as any currently mapped user defined functions. The Cut, Copy, and Paste items function as in any text editor.
For a list of all the currently mapped variables, type 'listvars' at the command prompt. For a list of all the currently mapped user-defined functions type 'listfuncs' at the command prompt. For a list of all the built-in key words type 'listkeys' at the prompt.
Scrollbars appear in the Command View to allow you to scroll to any portion of the display. However, you can only type new commands at the last command prompt. The entire window can be cleared by typing 'reset' at the prompt or by selecting ClearCommand Window from the pop-up menu.
Use the function browser and online help for further information on how to use the key word functions.
If the Command View panel is not initially visible, use the Desktop menu and click on Command View to add that view to the display. From the prompt >>> on the Command View you can type in arithmetic and algebraic commands. After each command, press the Enter button on your keyboard and the result of the command will be immediately visible. For example:
Right clicking anywhere on the Command View will bring up the Command View Pop-Up menu.
The menu items are largely self-explanatory. The Display Variable List displays a list of the current variables. Highlighting a variable name selects that variable and choosing Show Selected Variable will display that variable. Similarly, highlighting a variable name in the list and selecting Delete Selected Variable will remove that variable from the list. Choosing Delete all variables will remove all the current variables from the list without the need to highlight any variable. The Function Browser is an application window that allows you to browse and search for the application built in key words as well as any currently mapped user defined functions. The Cut, Copy, and Paste items function as in any text editor.
For a list of all the currently mapped variables, type 'listvars' at the command prompt. For a list of all the currently mapped user-defined functions type 'listfuncs' at the command prompt. For a list of all the built-in key words type 'listkeys' at the prompt.
Scrollbars appear in the Command View to allow you to scroll to any portion of the display. However, you can only type new commands at the last command prompt. The entire window can be cleared by typing 'reset' at the prompt or by selecting ClearCommand Window from the pop-up menu.
Use the function browser and online help for further information on how to use the key word functions.
If the File View panel is not initially visible, use the Desktop menu and click on File View to add that view to the display.
Right clicking anywhere on the File View will bring up the File View Pop-Up menu.
Double clicking on a selected *.mc (MatCalc Script File) file will bring up the MatCalc Editor window with that script loaded.
Double clicking on Microsoft Excel files (*.xls) will bring up the file (Microsoft Office must be installed).
Double clicking on a *.mch (MatCalc History file) will load that history into the History View.
Double clicking on a *.mtx (MatCalc matrix file) will load that file into the current workspace.
Double clicking on a *.mws (MatCalc workspace file) will load that file into the current workspace.
If the Command History View panel is not initially visible, use the Desktop menu and click on Command History to add that view to the display.
Right clicking anywhere on the Command History View will bring up the Command History Pop-Up menu. Menu choices are self-explanatory with respect to the History View.
Double clicking on an item in the History will activate that item as though it has been typed into the Command View window.
If the Workspace View panel is not initially visible, use the Desktop menu and click on Workspace to add that view to the display.
Right clicking anywhere on the Workspace View will bring up the Workspace Pop-Up menu. Menu choices are self-explanatory with respect to the Workspace.
Double clicking on an item in the Workspace list will bring the data up in the Variable View window.
If the Variable View panel is not initially visible, use the Desktop menu and click on Variable to add that view to the display.
Right clicking anywhere on the Variable View will bring up the Variable View Pop-Up menu. Menu choices are self-explanatory with respect to the Variable View.
The data in the variable display are editable and the data can be saved to disk as a *.mtx file using the either the pop-up menu or Variable View toolbar Save.
The script editor can be accessed via the MatCalc main menu Tools menu or by double clicking on a script (*.mc) file in the File View. The latter action will automatically load the selected file into the editor window. Files can also be loaded by using the Editor main menu File/Open and saved using the File/Save menu item.
The Editor scripting engine is an both an editor and an interpreter. Variables are autodeclared. Built in functions (keywords) are syntactically colored (rose), as are numbers (blue) and quoted strings (red).
To interpret a script, double click on the green arrow on the toolbar. The script will be interpreted and the results will appear in the Command View window. File, Edit, View, and Window menus operate as most Windows multidocument interface editors.
The 2D Plotter can be accessed via the MatCalc main menu Tools menu or by employing the plot(Var) from either the Command View or the scripting Editor. The latter action will automatically load the selected file into the editor window. Here Var refers to an N x 2 matrix whose two columns represent x and y values to be plotted.
The 2D plotter has it's own online help. It has the capability of loading and saving data files in the form of *.mtx files. The plots can be edited and transformed in a variety of ways. They can also be saved as bitmap (*.bmp) files for incorporation into presentations.
The 3D Plotter can be accessed via the MatCalc main menu Tools menu or by employing the plot3d(Var) from either the Command View or the scripting Editor. The latter action will automatically load the selected file into the editor window. Here Var refers to an N x 3 matrix whose three columns represent x, y and z values to be plotted.
The 3D plotter has it's own online help. It has the capability of loading and saving data files in the form of *.mtx files and *.dat files. The plots can be edited and transformed in a variety of ways. They can also be saved as bitmap (*.bmp) files for incorporation into presentations.
Basic Command Line Syntax Guidelines | |
1. | Use numerals (0 - 9) for numbers, i.e., 123.234, -0.2343 |
2. | Use lower case, single letter (a - z) for scalar variables |
3. | Use upper case, single letter (A - Z) for complex, vector, and matrix variables |
4. | Use lower case with parentheses for all commands, i.e., A = inv(B) |
Table 1. List of Available Commands |
||
Command | Syntax | Action |
Variables and Operators | ||
A, B, C, . . . | A | calls the matrix variable, A |
a, b, c, . . . | a | calls the scalar variable, a |
= | A = B, a = b*c | assigns the right hand expression to the left variable |
+ | A + C, a + c | adds left-side variable to right-side variable |
- | A - C, a - c | subtracts right-side variable from left-side variable |
* | A * B, a * b | multiplies right-side variable by left-side variable |
/ | A / B, a / b | divides left-side variable by right-side variable |
% | A%B, A%b, a%b | computes left-side variable modulo right-side variable |
^ | A^3, A^b, A^-b, a^3, a^b, a^-x | raises left-side variable to right-side variable (exponent) power exponent may be an integer, fraction, negative, or a numeric variable, but not matrix |
@ | A @ b, A @ B, a @ b | performs Kronecker multiplication |
Scalar, Vector, and Matrix Functions | ||
sin | sin(a), sin(A) | computes the sin of the scalar or matrix elements |
cos | cos(a), cos(A) | computes the cos of the scalar or matrix elements |
tan | tan(a), tan(A) | computes the tan of the scalar or matrix elements |
sec | sec(a), sec(A) | computes the sec of the scalar or matrix elements |
csc | csc(a), csc(A) | computes the csc of the scalar or matrix elements |
cot | cot(A), cot(A) | computes the cot of the scalar or matrix elements |
log | log(a), log(A) | computes the decimal log (base 10) of the scalar or matrix elements |
ln | ln(a), ln(A) | computes the natural log (base e) of the scalar or matrix elements |
exp | exp(a), exp(A) | raises the natural logarithm, e, to the scalar or matrix elements |
sqrt | sqrt(a), sqrt(A) | computes the square root of the scalar or matrix elements |
abs | abs(a), abs(A) | converts to absolute value the scalar or matrix elements |
recip | recip(a), recip(A) | computes the reciprocal of the scalar or matrix elements |
nfac | nfac(a), nfac(A) | computes the factorial of the scalar or matrix elements (integers) |
deg | deg(a), deg(A) | conversion of radians to degrees of scalar or matrix elements |
rad | rad(a), rad(A) | conversion of degrees to radians of scalar or matrix elements |
asin | asin(a), asin(A) | computes arcsin of scalar or matrix elements |
acos | acos(a), acos(A) | computes arccos of scalar or matrix elements |
atan | atan(a), atan(A) | computes arctan of scalar or matrix elements |
sinh | sinh(a), sinh(A) | computes hyperbolic sin of scalar or matrix elements |
cosh | cosh(a), cosh(A) | computes hyperbolic cosine of scalar or matrix elements |
tanh | tanh(a), tanh(A) | computes hyperbolic tangent of scalar or matrix elements |
nprob | nprob(a) | computes the normal probability cumulative range of the scalar |
Vector and Matrix Functions | ||
det | det(A) | computes the determinant of the matrix |
trans | trans(A) | transposes the matrix |
inv | inv(A) | computes the inverse matrix |
ginv | ginv(A) | computes the generalized (Moore-Penrose) inverse matrix |
trace | trace(A) | computes the trace (diagonal sum) of the matrix |
eigval | eigenval(A) | computes the eigenvalues of the matrix |
eigvec | eigenvec(A) | computes the eigenvectors of the matrix |
row | row(A, 2) | isolates the second row from matrix A |
column | column(A, 3) | isolates the third column from matrix A |
adj | adj(A) | computes the adjugate (adjoint) matrix |
rref | rref(A) | computes the row-reduced echelon form of the matrix |
norm | norm(A) | computes the Euclidian norm of the matrix |
rank | rank(A) | calculates the rank of the matrix |
cond | cond(A) | calculates the condition number of the matrix |
flip | flip(A) | rearranges the matrix as though flipped left to right |
flop | flop(A) | rearranges the matrix as though flopped top to bottom |
mexp | mexp(A) | computes the matrix exp function from a matrix convergent series |
msin | msin(A) | computes the matrix sin function from a matrix convergent series |
mcos | mcos(A) | computes the matrix cos function from a matrix convergent series |
lul | lul(A) | computes the LU decomposition lower matrix |
luu | luu(A) | computes the LU decomposition upper matrix |
svdd | svdd(A) | computes the SVD diagonal matrix |
svdv | svdv(A) | computes the SVD V matrix |
svdu | svdu(A) | computes the SVD U matrix |
qrq | qrq(A) | computes the QR Q matrix |
qrr | qrr(A) | computes the QR R matrix |
matrix | matrix(1,2,..;5,6,..) | Sets elements in a
matrix. The columns are delimited by commas and the rows by
semicolons.. Brackets [ ] or parentheses ( ) delimit matrix. Example: A = matrix[1, 2, 3 ; 4, 5, 6 ; 7, 8, 12] |
submatrix | submatrix(A,1,2;1,2) | Defines a submatrix of a given matrix. |
hcon | hcon(A, B) | Horizontally concatentates matrices A and B |
vcon | vcon(A, B) | Vertically concatentates matrices A and B |
nullspace | nullspace(A) | Computes the nullspace (kernel) of matrix A |
System Commands | ||
real | real | Sets the operation mode to use only real matrices |
complex | complex | Sets the operation mode to use complex matrices |
open | A=open... | Opens a matrix from disk file |
saveas | saveas | Saves the current matrix to disk with a new name |
proc | proc | Displays the Procedures option list |
test | test | Displays the Test option list |
create | create | Displays the Create option list |
mode | mode | Displays the Mode option list |
display | display | Displays the Display option list |
store | store | Displays the Store option list |
recall | recall | Displays the Recall option list |
clear | clear | Clears the current display |
quit | quit | Terminates the command line mode; prompts to save work |
Keywords and Built In Functions
A list of all the built-in keywords can be quickly viewd by typing listkeys in the Command View window.
Similarly, a list of all user-defined functions currently mapped can be quickly viewed by typing listfuncs in the Command View window.
>>> listkeys
abs acos acosh acot acsc addfun
adjacency adjugate arg asec asin asinh
atan atan2 atanh avg bessj bessj0
bessj1 bessy bessy0 bessy1 bico ceil
cffrac charac chisqr cholesky circulant colnorm
colspace colsum column companion complex compos
cond conj conjugate cos cosh cot
csc cyclic datgen dcon dec decompos
def defun degrees delcol delfuncs delrow
delvars descriptives det diagonalize diagprod ediv
eigval eigvec element emul eroot eroots
esum exp factorial fill flip floor
flop fmod for fraccf ftest gauss
get getcol getimag getreal getreg getrow
ginv hankel hcon help hermit hermitian
hilbert htrans ident incidence inv inv2
jordblk jordfrm listfuncs listkeys listvars ln
log log10 log2 lul luu mat
matrix max mcos mexp min minor
mlog modulus mpow mroot msin msum
ncols nfac nilpot norm npermut nprob
nrows nullspace open openxls permut pinv
plot plot3d pout pow print putreg
qrq qrr quaternion radians random rank
readxls real recip rename rndcplx rndflt
rndint rndorth rndreal rndstochb rndstochc rndstochr
rotate2 rotate3 round row rowsum rref
run runfun runfuns runscript save sec
set setimag setreal shape sign sin
sinh sqrt standev studttest submat submatrix
subvec subvector sum surf svdd svdu
svdv tan tanh test this toeplitz
trace trans unitary vander vcon vec
vector wid write
>>> listfuncs
f0()(P=rndstochr(n);I=ident(n);Q=I-P;S=P+Q;)
f1()(M=mat(1,2,3:4,5,6:7,8,2);ML=mlog(M);M2=mexp(ML);M2r=round(M2,12);Mx=M-M2;)
f2()(H=hermit(3,-1.0,1.0);LH=mlog(H);H2=mexp(LH);Hx=H-H2;)
f3()(M=rndcplx(3,3,-1.0,1.0);M=M*htrans(M);P=eigvec(M);D=inv(P)*M*P;M2=P*D*inv(P);M2r=round(M2,12);)
f4()(Cmp=companion(V);Cmp=trans(Cmp);P=eigvec(Cmp);D=inv(P)*Cmp*P;t0=0.1;tD=t0*D;S=mexp(tD);)
f5()(M=real(3,3,-1.0,1.0);t=0.1;tM=t*M;)
For more detailed information on built-in keyword use, see the Function Browser and Command Syntax.
The function browser is available via the Command View window context menu by selecting Function Browser. This window allows you to search for a particular built-in or user-defined function by typing the function name in the search window and pressing the Enter key or clicking on the Search button. Double clicking on the highlighted item will bring up the help tip window which shows most of the general uses of that function.
In the example shown here, there are at least six different contexts in which the function acos might be used. When applied to a real or complex number, the function returns a real or complex number respectively. When applied to real or complex vectors or matrices, the function will return a real or complex vector or matrix respectively, with each element of the vector or matrix converted to the value of the acos function.
The matrix calculator can be accessed by typing MCalc in the Command View window.
The MatCalc Matrix Analyzer application is an add-on that has many useful features for data calculation and manipulation. The application has it's own built-in online help and ancillary modules including a script interpreter, a C-language interpreter, and arbitrary precision calculators. It can be downloaded as a separate application.
MatCalc Tutorial For Beginners