Back to the table of contents

Acquaintance and first steps

This chapter is devoted to a first acquaintance with possibilities which Mathapar opens. The language MathPar, which is described below, may be considered as a kind of development of a TeX language. TeX serves for writing mathematical texts and preparing them for publication. It may be called "passive" in comparison with the language MathPar, which permits to execute computations, and so is a self-depended mathematical language. A problem definition and a result of computations are written in MathPar.

Just after computations you see the whole mathematical text as a pdf-image which is accustomed in scientific and technical publications.

The result may be further used in different ways.

(1) You may click the text with your mouse, and it would return to the initial form of the MathPar language. Then you may continue to edit the text or pass to a next task. There is another way to change a form of a text — using a button , placed between buttons "$\blacktriangleright$" and "$+$".

(2) You may click the image of the mathematical text with the right mouse button, and the drop-down menu appears. The upper field Show-Math-As permits to pass to the choice of language. It is suggested to chose Tex or MathML. You may open a field you need.

For example, a matrix of the size $2\times 2$ will be written in MathPar in the following way:

A=[[a,b],[c,d]];

in TeX as follows:

A= $\backslash$left(begin{array}{${cc}$}$ a \& b$ $\backslash\backslash c \& d \backslash\backslash$ end{array}$\backslash$right).

In MathML it is much more complicated.

The text obtained in Tex or in MathML you may copy and past into TeX or HTML file and use for publication. You may also save it as an image and use in any document. It is useful, for example, when it is necessary to save a plot or a solution of a problem

2.1 Input data and run the calculations

At the center of the screen there is an entry field where it is possible to enter mathematical expressions. To start a task press the button $\blacktriangleright$. When your cursor is disposed in the field of input you can press the combination of keys Ctrl+Enter.

On the top of the screen you can see buttons ${\small \fbox {Help}}$ and ${\small \fbox{Handbook}}$. This is way to the help files. All the fields of the help pages are active, and you can run the help examples. You can copy text from the samples and transfer them into the field for user input.

When you enter mathematical expressions, they must be separated by a semicolon (;) or text comments, which are enclosed in quotation marks. When you need to have a mathematical expression in the comment as part of the comment, it must be skirted in the dollar signs ($\$$). For example, you can write a comment:

\noindent $"$ Two different notations $\$ \backslash exp(x)\$$ and $\$\backslash e \widehat{ }{} x\$$ are used for the exponential function.$"$

To obtain results it is necessary to use the command print() and to specify the names of those expressions which are required to be printed.

If the list of statement does not contain a print statement print() or any other operator (plot(), prints(), etc.), it will be shown the result obtained in the last statement. All commands or operators should begin with the symbol "back slash" ($\backslash$). The button $\fbox{+}$ lets us add new entry fields. You can press the combination of keys Crtl+Del to remove this field or you can press the button $\fbox{x}$ at the right side of this field on the screen. The button $\fbox{C}$ is designed to clean the values of all previously typed names. It is useful to have such button when the numerical values are entered in some sections, and the calculations are done in other sections. Clearing all names allows you to obtain a symbolic expression rather than the number.

On the left of the screen you can see fields with a current environment and a current random access memory. Under the fields differant buttons for enter of functions are placed.

Working with files

Functions for working with files are available at the "Files" collapsible panel from menu at the left.

Here is what you can do with files:

1) Save the result of the last run section as PDF file with "Save PDF" button. You can specify desirable paper size (dimensions are in centimeters), by default page has size A4 (21x29.7 cm)

2) Upload text files to Mathpar server with "Upload file" button. Under the button there is a list of uploaded files. Files should contain Mathpar expressions or tables in specific format.

Table contains of header — it's the first row with arbitrary strings in it — and number rows. Columns are separated with tabulation symbol. Functions for working with tables are available at the panel "Graphics and tables" (see also section 3.1 Plotting functions of help system).

3) Input Mathpar expressions from uploaded files with fromFile() function. E.g., to make an expression from file myfile.txt and assign this expression to variable $a$ run: a = fromFile('myfile.txt').

2.2 Mathematical functions

The following notations for elementary functions and constants are accepted.

Constants

$\backslash$i — imaginary unit,

$\backslash$e — the basis of natural logarithm,

$\backslash$pi — the ratio of length of a circle to its diameter,

$\backslash$infty — infinity sign.

Functions of one argument

$\backslash$ln — natural logarithm,

$\backslash$lg — decimal logarithm,

$\backslash$sin — sine,

$\backslash$cos — cosine,

$\backslash$tg — tangent,

$\backslash$ctg — cotangent,

$\backslash$arcsin — arcsine,

$\backslash$arccos — arccosine,

$\backslash$arctg — arctangent,

$\backslash$arcctg — arccotangent,

$\backslash$sh — sine hyperbolic,

$\backslash$ch — cosine hyperbolic,

$\backslash$th — tangent hyperbolic,

$\backslash$cth — cotangent hyperbolic,

$\backslash$arcsh — arcsine hyperbolic,

$\backslash$arcch — arccosine hyperbolic,

$\backslash$arcth — arctangent hyperbolic,

$\backslash$arccth — arccotangent hyperbolic,

$\backslash$exp — exponent,

$\backslash$sqrt — root square,

$\backslash$abs — absolute value of real numbers (module for complex numbers),

$\backslash$sign — number sign (returns $1$, $0$, $-1$ when number sign is $+$, $0$, $-$, correspondingly), $\backslash$unitStep$(x,a)$ — is a function which, for $ x> a $ takes the value $ 1 $, and for $ x <a $ takes the value $ 0 $;

$\backslash$fact — factorial. It is defined for positive integers. It is equivalent to $n!$.

Functions of two arguments

$\widehat{ }{}$ — degree,

$\backslash$log — logarithm of function with given base,

$\backslash$rootOf(x, n) — root of degree n of x,

$\backslash$Gamma — the function Gamma,

$\backslash$Gamma2 — the function Gamma 2,

$\backslash$binomial — binomial coefficient.

No result yet

2.3 Actions with functions

For the above functions and their compositions, you can calculate the value of the function at the point, substitute the expression into a function instead of arguments, calculate the limit of the function, calculate derivative, etc. For this purpose, the following commands are defined.

To calculate the value of a function at a point you must run value(f, [var1, var2, …, varn]), where $f$ — function, and $var1, var2, …, varn $ — values of the variables of the ring.

For the substitution of expressions to the function you must execute the value(f, [func1, func2, …, funcn]), where $ f $ — a function $ func1, func2, …, funcn $ — expressions that are substituted for the corresponding variables.

To calculate the limit of a function at a point you must run lim(f, var), where $ f $ — this function, and $ var $ — the point at which you want to find the limit.

In order to calculate the derivative of $f$ in the variable $y$ in the ring $\mathbb {Z} [x, y, z]$ you must run D(f, y). To find a mixed first-order derivative of the function $ f $ there is a command D(f, [x, y]), to find the derivative of higher order you must use the command $\backslash {\mathbf {D}} (f, [x \widehat{ }{} k, z \widehat{ }{} m, y \widehat{ }{} n])$, where $ k, m, n $ indicate the order of the derivative of variables.

No result yet
No result yet
No result yet
No result yet

2.4 Solution of the algebraic equation

To obtain a solution of the algebraic equation use the command solve.

The command $FLOATPOS = N$ is used for setting the environment. It sets the number of decimal places after the decimal point $ (N) $, which should appear in the print of the numerical results of approximate calculations. It is not connected with the process of calculation, but only with printing. By default, $ FLOATPOS = 2 $.

No result yet

No result yet

No result yet

2.5 Solution of the algebraic inequalities

To obtain a solution of the algebraic inequalities use the command solve, which contains the inequalities. We can solve strict and not strict algebraic inequalities. Open interval is indicated in parentheses ( ), closed interval is indicated inbrackets [ ], set is denoted by braces { }.

No result yet

No result yet

No result yet

No result yet

2.6 Solution of the algebraic inequalities systems

To obtain a solution of the algebraic inequalities systems use the command solve[In1, In2, ..., Ink], where $[In1, In2, ..., Ink]$ — vector, where contain inequalities. System contain strict and not strict algebraic inequalities. Open interval is indicated in parentheses (), closed interval is indicated inbrackets, set is denoted by braces { }.

No result yet

No result yet

No result yet

2.7 Operations on subsets of the real numbers

To specify a subset use the command set((a,b),(c,d]), where $a,b,c,d$ are numbers. Subset may consist of open intervals indicated by parentheses ( ), half-open intervals indicated by [ ) or ( ], segments indicated by brackets [ ] and points indicated by braces { }, or like segments.

Simple subset is denoted by the same brackets, but you need to add a backslash ($ \backslash $) in front of each bracket. For example $ \backslash (3,4.5) \backslash] $, $ \backslash[7, 7 \backslash]$ or $\backslash{8 \backslash}$. The operator $ \backslash {\mathbf {set}} $ is not required.

No result yet

With subsets we can make the following operations: union, intersection, subtraction, calculation of the symmetric difference and complement set, using the commands $\backslash cup$, $\backslash cap$, $\backslash setminus$, $\backslash triangle$ and symbol (') apostrophe.

No result yet

\newpage

2.8 Vectors and matrices

To define the row-vector you have to list its elements in square brackets.

To define the matrix you must take in square brackets a list of row vectors, for example, $ A = [[1, 2], [3, 4]] $.

Element of the matrix may be obtained by specifying the row and column number in the two lower indexes of the matrix, and an element of the vector may be obtained by specifying its number in the lower index of the vector. The is an example for obtaining elements. You have to set $a=\backslash elementOf(A)$, and then obtain $a$_{$i, j$}. If $B$ is a vector, then you have to set $b=\backslash elementOf(B)$, and then obtain element $b$_{$i$}. You can get a row of the matrix as a vector-row and column of the matrix as a column vector. The row vector obtained by specifying the number of row in the first index and a sign of question (?) in the second index, for example, $a$_{$i, ?$}. Column vector obtained by specifying the number of column in the second index and the sign of question (?) in the first index, for example, $a$_{$?, j$}. The names of non-commutative objects, such as matrices and vectors, must be written with the symbol <<back slash>> ($\backslash$) and a capital letter.

To denote zero and identity matrix you can use the caps $\backslash O$ and $\backslash I$, with two indexes, indicating the number of rows and columns. With the help of the symbol $\backslash I $, you can create any size square matrix whose elements on the main diagonal are equal to $ 1 $, and the remaining elements are zero. For example, $\backslash I$_{$2, 3$} and $\backslash O$_{$2, 2$} denote the matrix $ \left(\begin {array} {ccc} 1 & 0 & 0 \ 0 & 1 & 0 \ \end {array} \right) $ and $ \left(\begin {array} {cc} 0 & 0 \ 0 & 0 \ \end {array} \right) $. You can specify zero vectors, indicating the index number of elements: $\backslash O$_{$3$} denote the vector $ [0, 0, 0] $ and $I$_{$3$} denotes the vector $ [ 1, 0, 0] $.

Column vector can be formed by transposing the row vector, for example, $ D = [7, 2, 3] ^ T $ — it is a column vector with three elements. Arithmetic operations are indicated by standard signs ``~+~'',~``~-~'', ``~*~''.

No result yet

No result yet

No result yet

No result yet

No result yet

No result yet

2.9 Generation of random elements

Mathpar can generate of random elements such as numbers, polynomials and matrices.

Generation of numbers

To create a random number you have to execute the command randomNumber(k), where $k$ is the number of bits.

No result yet

Generation of random polynomial

To create a random polynomial with three variables you have to execute the command randomPolynom(d1, d2,…, ds, dens, bits), where $dens$ is a polynomial density, $bits$ is a number of bits in numerical coefficients, and $d1, d2, …, ds$ denote the highest degrees of variable. If $dens=100$, you get a polynomial that has all coefficients non-zero, all $(d1 +1) (d2 +1) \cdot (ds +1)$ non-zero terms. When $ dens < 100$, only $ dens \% $ coefficients are nonzero, and the remaining $ (100-dens) \% $ will be zero.

No result yet

Generation of random matrix

To create arandom numerical matrix you have to execute the command randomMatrix(m, n, dens, bits), where last two arguments are the density of matrix and the number of bits in numerical elements of matrix, and first two arguments denote the sizes of a matrix.

To create a polynomial matrix you have to execute the command randomMatrix(m, n, dens, d1, d2, …, ds, pol_dens, pol_bits)), where first three arguments denote the size of a matrix and its density, last two arguments are the density of polynomials and the number of bits in numerical coefficients, the numbers $d1, d2,…, ds$ set the highest degrees of polynomial variables.

No result yet

Back to the table of contents