1. Elements of the Maple language

The output file is a text file that includes a part or all program code. The program can consist of a single file, as well as several hundreds of source code files.

Functions, variables, and constants are the main objects that make up the source program (source files).

Elements of the Maple language are basic constructs that are used when writing programs. These include alphabet, identifiers, keywords, commentary, etc.

Alphabet - a set of characters that can be typed on the keyboard to create Maple language constructs.

The alphabet is used to form lexemes - the minimum lexical units that are recognized by the interpreter. These include keywords (reserved words), operations symbols, variable names, functions and commands, rows, numbers, delimiters.

The Maple interpreter reads each line and divides it into tokens that run immediately.

The Ukrainian alphabet can only be used in character strings, constants or in comments (in the explanations to the program).

The space characters are the space bar, the transition to a new line, the horizontal and vertical tabs, the new page. These symbols share tokens from each other.

The interpreter ignores several space characters in a row, which allows them to be used to improve the visuality of the program.

Separators are used by the interpreter for various tasks - from organizing the text of the program to instructing the compiler to perform specific actions:

, coma (comma) - when transferring;

; semicolon - ending the operator;

[] square brackets (square brackets) - definition of the sequence (array);

{} curly brackets - the definition of a plural;

() parentheses - function definitions and others.

Constants are a number, a character, or a string of characters that does not change during the execution of the program.

There are constants: goals; valid (with a floating point); symbolic; timely

Maple contains a number of named constants - those whose values can be accessed by name. Some of these constants cannot be changed.

These include:

  • true, false - logical values "true" and "false";
  • infinity - infinity;
  • I - the imaginary unit;
  • Pi is a constant of 3.14159265.

Some constants can be overridden, for example, Digits, which specifies the number of significant digits for floating point numbers (default 10).

To view all the constants in Maple, follow the command:.

Maple works with the following types of numbers :

  • ( integer ) integer decimal (0, 1, 123, -456, etc.),
  • ( fraction ) rational in the form of the ratio of integers (7/9, -123/127, etc.),
  • ( float ) valid from the mantissa and order (1.23E5, 123.456E-10)
  • ( complex ) complex (2 + 3I).

Numbers are any sequence of numbers. Maple ignores the left zeros.

Whole numbers are natural numbers with or. Whole numbers are given as a sequence of digits from 0 to 9. Example of integer constants: 10, 32767, -32767.

Maple can work with whole numbers of arbitrary value, the number of digits is limited to 2 28. Large numbers that do not fit on one line, Maple moves to the next line, using the reverse slash (\).

When checking the type of a natural number, the command whattype() returns the whole type of integer, since the natural type natural is considered as one of the subtypes of the integer type.

To specify a subtype of an integer, you must use the type () command with a parameter that describes the subtypes of the whole type: natural, negint (negative integer), posint(positive integer), even (odd), odd (odd) and prime (simple )

Calculations with integers implement four arithmetic operations ( adding +, subtraction -, multiplication *, division /) and calculating the factorial (!).

Get a list of all the commands for working with integers can be typing the command: ?Integer. Some of these commands:

  • irem - calculation of the balance in the whole division operation irem(53,7) = 4
  • igcd - finding the largest common divisor of integers igcd(192,90) = 6
  • isprime - check whether the integer is simple.

Ordinary fractions are asked by dividing the two integers. Maple automatically performs fraction reduction, for example, 32/12;

Above the fractions, you can perform all basic arithmetic operations.

To convert a common fraction into a decimal value, the command evalf() is used

The second parameter of this command specifies the number of significant digits, for example: evalf(3/8, 4) = 0.3750.

The fraction and its decimal representation are not identical to the Maple objects.

A floating point number is a real number that has an integer and fractional part. The whole part of the fraction is separated by a dot, not a comma. To write a valid constancy in the exponential form, use the symbol ' e ' or ' E ', for example: 15.78, 0.5, 1.0, 1.2e7,.00075, -2.5e-2. The calculation of real numbers is made by default with 10 significant digits.

If all numbers in the expression are integers, fractions or radicals, the result is also represented using these types of data. If, in the expression, there is a float number, then the result of such a "mixed" expression is a floating point number. For example, 3e2 + 3/4 + sqrt (5) + 3/4 * 0.1 + surd (6.3) * 43/10;

Radicals are defined as the result of inputting into fractional degrees of whole or fractional numbers, or calculating from them the same square root sqrt (), or calculating the root n -th degree surd (number, n). In Maple, the rise to a degree is given by a symbol or a sequence of two asterisks.

Unlike floating point numbers, calculations with integers, fractions, and radicals are absolutely accurate, since Maple does not perform any rounding.

Complex numbers. For the imaginary unit in Maple constant is used. If at least one of the parts of a complex number (real or imaginary) is calculated as a floating point, then the result will be the same.

Basic commands for working with complex numbers:

  •  allocation of a valid part of a complex number
  •  allocation of the imaginary part of the complex number.

Special characters (or sequences) are used to perform characteristic actions, such as moving to a new line, tab, sound.

A string is any set of symbols taken in double quotes, for example. The line length in Maple can have 268435439 characters. A string connection can be performed using the concatenation operation ||, or by calling to the cat function (line 1, line 2).

Comment - explanatory text to the program, which can be written in any part of it. The comment, as a sequence of characters, is ignored by the compiler and interpreted as spaces. It is recommended that you use the comment as often as possible, which will make it easier to understand the code when it is modified.

Identifiers are the names of the variables and functions that are created in the program.

The identifier uses only two sets of characters that can be typed on the keyboard:

  • Letters of the Latin alphabet - A ... Z, a ... z , underscore "_";
  • Arabic numerals 0, 1, 2..9 .

Requirements for writing identifiers:

  • must start with a letter or an underline mark;
  • must carry a clear meaning of the name of the variable or function;
  • should not match the keyword.

Examples: temp1 , Skip _ 1 , Alpha , Fi , Sum , Ad , aD .

It Maple is case sensitive - small and large letters of the alphabet are different.

Key (service) words - predefined identifiers that have a special meaning.

and break by catch description do elif else end error export fi for finally from global if in intersect local minus mod module next no od option options or proc quit read return save stop then try union use while

Service words cannot be used as their own identifiers.