|
MatBasic - a programming language for mathematical calculations
The Matbasic program for Windows platform is designed and purposed for solving difficult mathematical problems
with the option of text and graphical output of results. The Matbasic is an integrated development environment of mathematical solutions.
The program is based on a specially developed high-level programming language translator and the language is the most appropriate for
solving mathematical and technical problems. The Matbasic language combines the simplicity of the BASIC syntax and the flexibility of such
high-level languages as C and Pascal. The set of commands and operators the language has is wide enough for the development of algorithms
of any level of complexity. The program allows to conduct any operations with real-valued and complex numbers also as with matrices.
It has a wide range of built-in linear algebra functions, solutions of non-linear equation systems, numerical integration and plenty of other
functions. This software allows to create and store a personal library of functions. An Matbasic calculation tool has a
full-functional debugger which allows to trace current program state at any step of its run.
Matbasic is provide following calculation tools:
- Base calculation tools;
- Full complex arithmetic's;
- Linear algebra and operations. Solving systems of linear equations, eigenvalue problems, and singular value problems. Matrix factorizations (LU, Cholesky, QR, SVD, Schur);
- Polynomial problems. Roots of the polynomial. Polynomials multiplication, division and other functions;
- Numerically evaluate integral of function;
- Solve non-linear system of equations;
- Find zero of a function of one variable (solve non-linear equation);
- Minimize a function of one and more variables;
- Solve initial value problems for ordinary differential equations (stiff and non-stiff);
- and others;
Matbasic IDE
The Matbasic has its own main code editor. The editor is equipped with a system of syntax highlighting
of the keywords, comments, string types, etc. Every layer of highlighting can be flexibly set up by a user via the main program settings.
There is also an option of mass commenting. The editor provides an easy way of insertion and editing of some special type constants
supported by the Matbasic language (e.g. matrix, structure). The IDE interface has a convenient toolbar and a data panel. Every event
of a program is displayed at the event panel which can also be used as an output console (Output Bar).
Matbasic language
The Matbasic programming language is simple and flexible at the same time.
At the same time the Matbasic environment can be used for executing rapid calculations or, in other word, it can be used as a calculator.
For example in order to divide complex numbers it's necessary to write:
As the result of this expression calculation the following string is displayed at the output panel:
-0.8758568165-0.5277989337i |
Note: The "semicolon" symbol at the end of the expression is obligatory. It is used for splitting the operations.
Several expressions can be written in a sequence using this separation symbol and that allows creating a calculations.
For example let's take the following:
(4.1-7.2i)/(0.2+8.1i);
sqrt(-0.8758568165-0.5277989337i); |
A square root from the result of division will be calculated and displayed at the output panel:
-0.8758568165-0.5277989337i
0.2708656453-0.9742817941i |
It's evident that for the creation of full-scale programs only numerical expressions are not enough.
At least variables are necessary. And for the creation of more flexible and more complex algorithms, operators (or commands) are needed.
Every variable doesn't need declaration and declaring its type. All the variables declarations and type transformations are occurring automatically.
The Matbasic variables can be of one of the following types:
- real-valued number;
- complex number;
- matrix;
- string (symbol);
- structure;
- pointer;
- identifier.
For example in order to declare a variable and to give it a complex number the following can be done:
The Matbasic has a powerful and flexible system of syntax analysis of expressions. For example the following is acceptable:
y=3.2;
x=2.38-(y+=2.8)*9.2-(z=[7.1i,2.8,0.2])[1]; |
And after execution of that code the variables would get the following values:
x=-52.82-7.1i
y=6
z=[7.1i,2.8,0.2] |
A vector has been used in this example. It was instantly given to the variable z as a value.
The vector is a special case of a matrix. In order to declare a matrix with dimensionality 3x3 it's enough to write:
b=[ 6.34+0.23i, 5-3i, 8.3;
9.23i, 0, 0;
3, 11.43-5i, 6.34]; |
The 3x1 matrix declaration:
Now in order to solve a system of linear equations:

or in a matrix form: b*x=c,
it's enough to call the function of linear equations system solving:
The result will amount to:
xyz=
-0.975081i;
1.71436+0.373988i;
-0.23109+1.13918i |
The same result can be got after executing several operation of linear algebra, and if b*x=c,
then to find the roots of x:
The Matbasic language allows creation of own functions. For example:
function y=f1(x)
y=x^4*cos(-10*x)+20*x^3*sin(5*x)-40*x;
end |
After declaration of this function, its graph can be plotted using the plot2d command:
% Graph at the interval [-3,3] with a step 0.01
x=-3..0.01..3;
plot2d (x,f1(x)); |

Now in order to solve an equation f1(x)=0 a standard function of nonlinear equations system solving can be used
with the set approximation to 2 and tuple precision 1e-6:
We'll get:
All the mentioned functions represent only a small part of standard Matbasic abilities.
Problems of that type can be solved pretty fast due to basic functionality of the program. First of all, Matbasic is a
programming language which means a user can himself create algorithms of solving - particularly algorithmic programs.
It's especially actually, when there is no standard solution.
Matbasic is have a full-scale toolset for the creation of algorithms, which unites commands, operations
and standard functions. Due to a flexible functions declaration system, every created algorithm can be arranged as a function and
later added to a library of user's function for the convenience of its usage in other programs.
As a simple example of algorithms realization we can take an algorithm of finding equal neighboring elements in a sequence (vector).
This program uses one cycle and a relation operator:
vec=[1,3,5467,3,44,54,65,65,678,6,5,6,6,0,0,45,6,456,43,43,4];
count=0;
for(i=1:length(vec)-1)
if(vec[i]==vec[i+1])
print "vec[",i,"]=vec[",i+1,
"]=",vec[i];
count++;
end
end |
And the result of program execution is:
vec[7]=vec[8]=65
vec[12]=vec[13]=6
vec[14]=vec[15]=0
vec[19]=vec[20]=43 |
A function in Matbasic programming language is one of central notions.
The syntax of functions declaration is universal and provides wide functionality:
- arguments by default;
- variable number of arguments;
- multiple parameters return;
- arguments by links;
- functions overload.
A function of a factorial finding can be given as an example:
function y=fact(x)
for(i=x-1:1:-1)
x*=i;
end
y=x;
end
print fact(4); % Factorial 4 |
Matbasic programs debugging
Program debugging is a step-by-step run process allowing to trace a state of different
data areas at every single step of a program run. It's impossible to develop a functioning complex algorithm without a good debugging system.
Matbasic has a fully functional debug system which allows stopping the program execution at any point. This can be done with the help of breakpoints
in the program code or using hotkeys. At every breakpoint a user can view and process every data type. At the same time all the callstack
information is available for viewing too at every program run step.
See also: Matbasic compare
|