121 CHEMICAL SCIENCES УДК 536.632 MATHEMATICAL ASPECTS OF USING THE VECTOR APPROACH FOR BALANCING CHEMICAL REACTIONS Kozub Pavlo, PhD (Technical Sciences), Associate Professor Kharkiv National University of Radio Electronics Kharkiv, Ukraine Yilmaz Nataliia, PhDS, scientist EPFL, the Swiss Federal Institute of Technology in Lausanne Lausanne, Switzerland Kozub Svetlana, PhD (Technical Sciences), Associate Professor Kharkiv National Medical University Lukianova Viktoriia, PhD (Pedagogical Sciences), Associate Professor Kharkiv National University of Radio Electronics Martyniuk Mykola, teacher, professional IT college of National aerospace university named after M. E. Zhukovsky “HAI”, Kharkiv, Ukraine Abstract: On the basis of the general algorithm for calculating stoichiometric coefficients for chemical reactions using the vector approach, a detailed calculation algorithm in the form of mathematical and logical equations has been developed, which allows to significantly reduce the number of calculations compared to theoretically derived mathematical constructions and therefore significantly speeds up the calculations. Practical testing of the proposed balancing algorithm in practice has shown that it can be used to create a calculation program in any programming 122 language. Keywords: chemical reactions, equations, balancing, stoichiometric coefficients, vectors, calculation algorithm. The use of the vector approach to analyze chemical processes can greatly simplify not only the understanding of general principles (the law of conservation of mass, chemical reaction routes), but also allows us to create new approaches to solving very common chemical problems (balancing chemical reactions, generating reaction systems) [1-5]. The methods of matrix algebra make it possible to use standard mathematical methods and software libraries for them, but as the practice of their use shows, such theoretically oriented calculations based on pure mathematical methods without taking into account the characteristics of real objects and the conditions for using mathematical methods when creating real algorithms for real programming languages lead to excessive time and resources and therefore prevent the use of such methods by specialists in other fields of science [6-8]. This is also true for the problem of balancing chemical equations. While the mathematical solution is relatively simple and transparent, it leads to a large number of unnecessary or repetitive calculations when used in practice [9-11]. But the practical solution to the problem showed that it is the use of the vector approach that allows you to create a simple and efficient algorithm suitable for implementing calculations for all programming languages. Thus, the chemical formula of a compound is a generally accepted and convenient way to display the composition, which reflects the number of elemental atoms for each of the compounds. Therefore, the main unit of initial and final data is the compound vector and the stoichiometric coefficients of the chemical equation 2221 ...... ABCnBCnBAn mj  (1) It should be noted that the absence of an element in the formula means its quantity is 0, and the absence of a subscript means its quantity is 1. In addition, the name of the element is essentially a definition of the ordinal number in the vector of 123 this quantity and in some compounds can occur several times or have a different place in the formula (CH3COOH, H2O, NaOH). Therefore, in order to perform calculations, it is necessary to first bring the chemical formulas to a single form mnmimjnjij aaamaaaj CBACBAСBA 11 ......0121   (2) then each of the compounds can be defined as a vector of the number of atoms in the compound      mnmimmjnjijj n aaaСaaaССNC ,,,...,,,...0,1,2: 111  (3) In a chemical system that consists of several chemical equations, the size of the vector is determined by the number of elements in the entire chemical system, not in a single chemical reaction, and the vector of all possible compounds that make up the chemical system can be represented as a matrix of size m n.                                      mnmim jnjij ni m j nm aaa aaa aaa C C C NL       ,, ,, ,, 1 1 11111 (4) This matrix allows you to calculate the amount of each of the i elements in a chemical equation if you know the amount of the compound in it, which in turn is determined by the stoichiometric coefficient before the compound. It should be noted that its value is always a positive integer (unlike the traditional matrix method), since the partial compound or negative compound does not exist physically. Thus, the number of compounds involved in a chemical reaction can be determined by the vector of stoichiometric quantities of compounds  mj m NNN   ,,: 1 (5) From the point of view of the vector approach, the right and left sides of the equation are different vectors that have the same endpoint, or their difference will be a zero vector. This fact is determined by using the vector of the direction of transformation (participation), the values of the elements of which take only three values: -1 for compounds to the right of the equation sign, +1 for compounds to the left of the equation sign, and 0 if the compound does not participate in the reaction 124    1,0,1,,,: 1  ttttTZT mj m  (6) The vector of reaction coefficients takes into account the direction of the reaction, so it has both positive and negative values  mj m kkkNTKZK  ,,: 1 (7) This vector physically corresponds to the difference in the quantities of elements in the right and left parts of the chemical equation and allows you to determine the coordinate of the end of the vector of compounds with their quantities       mj j jijini n akddddKLDZD 1 1 ,,,:  (8) A fully balanced equation will have zero deviation values for all elements, and a zero deviation value for one element will correspond to a balance for that element only. The essence of the vector method of balancing chemical reactions is the selection of balanced reactions from the total set of possible reactions, so in practice it can be realized in the form of a vector (list) of reactions with variable sizes, and for calculations it is more practical to use it in the form of a two-dimensional array (matrix) of size w×m                     wmxmm wjxjj wx wx mw kkk kkk kkk KKKRZR       1 1 1111 1 ,,: (9) To start the calculations, the number of possible reactions must be at least as large as the number of compounds involved in the reaction, and from the point of view of linear algebra, they must be linearly independent. These conditions are met by the values of the coefficients, which are a diagonal matrix with the values of the diagonal elements with the values of the transformation direction vector T 125   , 00 00 00 ,, 100 010 001 :, 1 100                                    m jmj mw t t t tttTIRmwZR            (10) All subsequent calculations are repeated for each of the i-elements in the form of a cycle of calculations from 1 to n-elements. It should be noted that such calculations are not performed for all elements simultaneously, but only for the current element, which reduces the number of calculations. 1. To identify balanced reactions for the current element, a vector of deviations for each of the reactions for the i-element. The size of the vector coincides with the number of reactions in the reaction system       mj j jixjxwx w akddddEZE 1 1 ,,,:  (11) 2. Since it is assumed that only a part of the equations are balanced, the list of reactions is supplemented with new equations that are calculated as a linear combination of existing equations. Theoretically, the number of such combinations can be very large for complex systems (the number of combinations of two quantities). However, the vector approach implies that the new equation will be linearly independent and balanced only if both equations have deviations from balance, and their signs are opposite, so checking for this condition significantly reduces the number of required calculations. The condition for the possibility of obtaining a new equation is that the products of the deviations are negative and non- zero   xydddkdkkKKFKZKKKF yxxiyjyjxjzjyxz m zyx  0:,,,,: (11) 3. It follows from formula (11) that the absolute values of the new coefficients can only increase, which can lead to solutions that are linearly dependent on each other and have large values. To do this, it is necessary to reduce the obtained equations to the classical form: first, reduce the coefficients to the smallest multiple, and then remove all reactions that have equal coefficients. From a practical point of view, the most effective solution to the first problem 126 is to bring the coefficients to multiples of the minimum coefficient (then you can make them integers) ],1[: min mj k k k zj zj zj  (12) 4. This makes it possible to exclude identical equations from consideration. As a general solution, you can use the entire array of previous equations for comparison, but from the point of view of the efficiency of using the algorithm, it is advisable to start the comparison with the last reactions obtained. If there is a difference for at least one of the coefficients in the two equations, it means that the equation is unique ]1;1[: 1    zxkku mj j xjzj (13) and therefore this equation is added to the list of possible linearly independent equations 0, , , , `),,(`:``,: 1 1 111111 1                      u kkkkk kkkkk kkkkk RKRARZRRRA zmwmyjxmm zjwjyjxjj zwyx z mw      (14) 5. Since some of these equations were unbalanced at the beginning of the calculation, they are removed from this list. A sign for deletion is a non-zero deviation of the balance for the i-element. To reduce computations, the check can be performed only for equations that were in the initial vector of chemical equations (the new ones are already balanced) 0:`,``,: 111 111 111111 1 1 1111 1                                                          x mwmxm jwjxj wx wmxmm wjxjj wx mw d kkk kkk kkk kkk kkk kkk delRZRRRdel           (15) 6. The generated new vector of chemical equations has only equations balanced for the i-element and is used as the initial one for calculations for the next element (calculations from step 1 to step 5) 0,:1`,  wniiiRR (16) 127 If there are no balanced equations in the vector of chemical equations, it indicates that there are no solutions, so further calculations are stopped. Thus, on the basis of the proposed general algorithm for calculating stoichiometric coefficients for chemical reactions, a detailed calculation algorithm in the form of mathematical and logical equations has been developed, which allows to significantly reduce the number of calculations compared to theoretically derived mathematical constructions and therefore significantly speeds up the calculations. Practical testing of the proposed balancing algorithm in practice has shown that it can be used to create a calculation program in any programming language. REFERENCES 1. Використання векторів для проведення та наглядного представлення стехіометричних розрахунків у хімії/ Козуб П.А., Козуб С.М., Бердо Р.В., Печерська В.І., Романов М.Д. / Актуальні проблеми сучасної хімії: Матеріали Всеукраїнської науково-практичної конференції студентів, аспірантів та молодих науковців , 20-22 квітня 2017р. – Миколаїв: НУК, 2017. - 41-43 с. 2. Козуб П.A., Козуб C.M., Присяжний О.В.. Вдосконалення стехіометричних методів аналізу складних хімічних систем / Science and society. Proceedings of the 9th International conference. Accent Graphics Communications & Publishing. Hamilton, Canada. 2019. Pp. 1095–1105 3. P. Kozub, V. Lukianova, S. Kozub Vector approach for modeling, research and optimization of complex chemical systems. Abstracts of international conference of natural sciences and technologies (ICONAT-2021). Turkish Republic of Northern Cyprus. 18-20 AUGUST 2021 . P. 28. 4. Козуб П. А., Мірошніченко Н. М., Лук'янова В. А., Козуб С. М., Мігунов В. Л. Використання векторного підходу для балансування хімічних рівнянь //Proceedings of the 15th International scientific and practical conference. BoScience Publisher. Chicago, USA. 2022. Pp. 65-73. URL: https://sci- conf.com.ua/xv-mizhnarodna-naukovo-praktichna-konferentsiya-modern-directions- 128 of-scientific-research-development-10-12-08-2022-chikago-ssha-arhiv/. 5. Козуб П. А., Мірошніченко Н. М., Лук'янова В. А., Козуб С. М., Гуріна Г. І. Використання векторного підходу для задач хімічної стехіометрії // Modern scientific research: achievements, innovations and development prospects. Proceedings of the 15th International scientific and practical conference. MDPC Publishing. Berlin, Germany. 2022. Pp. 80-87. URL: https://sci-conf.com.ua/xv-mizhnarodna-naukovo- praktichna-konferentsiya-modern-scientific-research-achievements-innovations-and- development-prospects-14-16-08-2022-berlin-nimechchina-arhiv/. 6. Zeggeren, V. F.; Storey, S. H. The Computation of Chemical Equlibria, Cambridge Univ. Press, London,1970 7. Smith, W. R.; Missen, R. W. Chemical Reaction Equilibrium Analysis: Theory and Algorithms, Wiley, New York 1982. 8. Gabriel, C.I. and Onwuka, G.I. (2015) Balancing of Chemical Equations Using Matrix Algebra/ Journal of Natural Sciences Research , 3, pp.29-36. 9. Risteski, I. B., 2009. "A new singular matrix method for balancing chemical equations and their stability." Journal of the Chinese Chemical Society, vol. 56, pp. 65-79. 10. Thorne, Lawrence R. (2010). "An Innovative Approach to Balancing Chemical-Reaction Equations: A Simplified Matrix-Inversion Technique for Determining the Matrix Null Space". Chem. Educator. 15: 304–308. arXiv:1110.4321 11. Risteski, I.B. (2012). A new algebra for balancing special chemical reactions, Chemistry: Bulg. J. Sci. Educ., 21, 223-234 https://wp-en.wikideck.com/ArXiv_(identifier) https://arxiv.org/abs/1110.4321