The 2nd theme: Linear algorithms cycles. Approximate calculation of the integral in their efficiency. Matrix multiplication. Calculation of determinants
The 2nd theme: Linear algorithms. Cycles. Approximate calculation of the integrals in their efficiency. Multiplication of matrices. Calculations of determinants
PhD, dotsent Sabirov Karimjon Kabildjanovich
Introduction
The efficiency of software methods for solving applied problems is especially clearly manifested in cases when we are faced with multiple executions of the same type of operations. Anyone who has mastered program methods for solving a problem will everywhere strive to be added, namely a program method for solving a problem. To do this, it is necessary to master the skills of designing algorithms, their representation in algorithmic programming languages and the process of debugging programs on a computer. The structure and subject matter of this course is formed on the basis of this goal.
The main structures of algorithms
There are three main structures of algorithms:
Linear.
Branching (alternative "if-then-else" or "if-then").
Cyclic (repetition).
Linear algorithms
The linear algorithm is the main one. It means that the actions are performed one after the other.
The rectangle shown in the figure can represent either a single command or a set of operators necessary to perform complex data processing, where F1 and F2 are some commands for the corresponding executor. Commands are written using the assignment operator.
Assigning a value to a variable or assigning a value to another variable is the most common action in a program written in any programming language. In a programming language, assignment is an operation and is denoted as ":=". This means that when this operation is performed, not only is a value assigned to a certain variable, but a certain value is also returned.
The cyclic algorithm
The cyclic algorithm (or repetition) involves the repeated execution of a certain set of actions.
Cycles allow you to record long sequences of data processing operations with a small number of repetitive commands.
An iterative cycle is called, the number of repetitions of which is not set, but is determined during the execution of the cycle. In this case, one iteration of the cycle is called an iteration.
Examples
Calculate the value of the sum
Calculate the value of the sum at the points
As can be seen from the statement, the process of calculating this sum has no complexity, but is associated with repeated repetition of operations of the same type.
Recall one more statement: the sum of any convergent functional series represents some function.
Algorithm of calculating determinants
If two matrices и are given, then the multiplication of these matrices is with elements
Calculations of determinants of matrices
Here, represents one permutation of numbers
The number of operations required to calculate the order determinant :
The number of multiplications:
The number of additions:
The total number of operations:
There are various ways to calculate determinants.
Example
Calculate the matrix determinant using the Gaussian method with an accuracy of 0.001
Example
Approximate integration formulas
Formulas for Left, Right, and Middle Rectangles
Trapezoidal formula
Simpson formula
Formulas of Left, Right, and Middle Rectangles
Let us the segment of integrations separate into parts with steps .
- formula of left rectangles
- formula of right rectangles
- formula of middle (average) rectangles
where
Trapezoidal formula
where
Simpson’s formula
where should be the even number
Efficiency of integration formulas
Simpson’s formula is more efficiency than other formulas