Method for carrying out batch analytic calculation on Latex mathematical formula and application

Based on the optimization algorithm based on the principle of compilation, simplifying and improving the calculation method of Latex mathematics formulas, the problem of low efficiency of the Latex mathematical formula in the existing technologies, the efficient grammatical analysis and batch operations have been achieved, and the calculation is improved. efficiency.

CN119337862APending Publication Date: 2025-01-21SICHUAN ZHONGRUI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411565277.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

The existing Latex mathematical formula calculation method has low batch computing efficiency for matrix data and relies on specific computing tools such as matlab, resulting in complex deployment and implementation and low computing efficiency.

Method used

Using an optimization algorithm based on compilation principles, the operator matrix is ​​simplified through multi-type classification, and the single-way stack operation is improved into a 1+n-way stack operation to achieve efficient syntax parsing and batch operations of Latex expressions.

Benefits of technology

The synchronous operation of 100,000 -level data is completed within seconds, which greatly optimizes the syntax analysis process and batch computing efficiency of Latex expression, and provides a complete front -end computing page and system application based on Mathjax+Java.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119337862A_ABST
    Figure CN119337862A_ABST
Patent Text Reader

Abstract

The invention relates to the field of Latex mathematical formulas, aims to solve the problem that an existing Latex mathematical formula is low in matrix data calculation efficiency, and provides a method and application for conducting batch analytical calculation on Latex mathematical formulas, and the method comprises the steps that 1, according to input, a variable set, Latex formula expression and a variable data set are determined; step 2, performing escape of a Latex expression; 3, performing unified expression conversion on the formula subjected to escape in the step 2; step 4, performing division optimization; 5, initializing an operand mapping set and an operator array; 6, scanning in sequence according to the operator list, and checking the legality of each operator according to the operator type; and 7, setting an equal-size operand list, and replacing the variables with data set numerical values at equal positions. 8, if the expression structure is legal, carrying out parallel calculation on an operator stack and an operand stack; and step 9, placing an operation result into a result array to complete calculation. According to the invention, the synchronous operation of hundreds of thousands of data can be completed in seconds.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Latex mathematical formulas, and in particular to a method and application for batch parsing and calculating Latex mathematical formulas, and in particular solves the problem of efficient batch calculation of matrix data by Latex mathematical formulas containing predefined variables. Background Art

[0002] With the popularization of computer systems, the visualization of mathematical formulas has become increasingly common in the field of scientific research, among which the display of Latex expressions in web applications is the most common. Although the visualization scheme of mathematical formulas is relatively mature, there is no relatively universal solution for the calculation of mathematical formulas. At present, most solutions for mathematical formula calculation use customized programming algorithm programs and calculation tools. Common mathematical calculation tools such as matlab need to calculate natural language formulas, and the formulas need to be manually converted into function symbols supported by matlab, which has a high cost of use. The mathematical formula calculation supported by specific calculation programs is also customized support for inherent mathematical formulas, and cannot support general mathematical formulas. The essence of mathematical formula calculation is the specific language implementation of compiler principle. There is a big difference between the natural mathematical formula language expression and the formula function expression of programming language. Although computers have no difficulty in mathematical calculation, how to convert mathematical formulas expressed in natural language into function expressions that can be recognized by programming languages ​​is the process of lexical analysis, syntax analysis, and semantic analysis in compiler principle. The electronic calculators or mobile phone calculation programs used in people's daily lives can perform simple mathematical formula calculations such as addition, subtraction, multiplication and division. Most of their implementation schemes are based on the operator priority method and the implementation of reverse Polish expressions in compiler principles: this type of algorithm program generally performs lexical analysis on the expression first, parses the arithmetic operator and operand, and then converts the expression based on the reverse Polish expression rules. For n operators, an n-dimensional matrix is ​​defined to define the operator priority. The reverse Polish expression is calculated based on stack operations. When an operand is pushed into the stack, the subsequent operator compares the priority with the top operator of the stack, the low-level operator is pushed into the stack, and the high-level operator is popped out of the stack. The result after the operation is pushed into the stack again, and so on and so forth until all expressions are pushed into the stack. Finally, the top stack structure is the operation result. Since the main use scenario of this type of algorithm is simple mathematical formula calculation, its limitation is that the formula expression must meet its algorithm definition, and the above process must be repeated each time the formula is run. Therefore, the calculation efficiency is low in large-scale batch data calculation scenarios. At present, most scientific research systems use external programs to call MATLAB function programs for batch calculations of complex mathematical formulas. Although this solution can solve the calculation problem, it needs to rely on MATLAB programs for calculations. The calling process involves formula conversion, request calling, program customization, etc., which cannot be used immediately. The deployment and implementation are relatively complex, and the calculation efficiency is not high under large data volumes. At the same time, with the widespread promotion of web applications in the field of scientific research, most scientific research systems use latex expressions to store and express mathematical formulas. At the same time, due to the needs of scientific research data analysis, it is often necessary to perform batch formula calculations on large-scale matrix data. The present invention designs a general calculation algorithm and application system based on this demand scenario. Summary of the invention

[0003] The purpose of the present invention is to provide a method and application for batch parsing and calculating Latex mathematical formulas, so as to solve the problem that the existing Latex mathematical formulas have low calculation efficiency for matrix data.

[0004] In view of this demand, the present invention returns to the implementation process of compilation principle, optimizes based on the existing algorithm priority method, classifies operators into multiple types, simplifies the scale of operator matrix, and changes single-way stack operation into 1+n-way stack operation, which involves the escape analysis of latex expression, lexical analysis of mathematical expression (operator analysis, operand analysis, variable analysis), expression syntax analysis (whether it is a legal formula, scientific calculation method conversion), and semantic analysis calculation (reasons of formula errors).

[0005] The specific implementation method of the present invention to achieve the above object is as follows:

[0006] Step 1: Based on the input, determine the variable set, latex formula expression, variable data set, and load the default configuration:

[0007] Step 1.1: Support operators (addition, subtraction, right bracket, scientific notation, cube root, cosine, log, ln, exponentiation, root root, sin, square root, tan, division, terminator, left bracket, minus, multiplication, plus);

[0008] Step 1.2: Initially set the default operator precedence according to the operator type:

[0009] Step 1.2.1: Classify by terminator, left bracket, sign (+-), right bracket, primary operator, secondary operator, tertiary operator, and scientific operator

[0010] Step 1.2.2: Priority rules: the end symbol is lower than the end symbol, the end symbol and right bracket are lower than the left bracket, the right bracket is higher than all operators, the end symbol, right bracket, first-level, second-level, third-level operators, and scientific operators are lower than scientific operators, the end symbol and right bracket are lower than the symbol, the end symbol, left bracket, right bracket, symbol, first-level operator are lower than first-level operator, the end symbol, left bracket, right bracket, symbol, first-level, second-level operators are lower than second-level operators, the end symbol, left bracket, right bracket, symbol, first-level, second-level, third-level operators are lower than third-level operators.

[0011] Step 1.3: The default calculation precision is 15 decimal places, and the mathematical constants are configured (E, PI).

[0012] Step 2: Latex expression escape: Step 2.1: escape \\times to *; Step 2.2: escape \\div and \\over to / ; Step 2.3: escape \\sqrt to sqrt; Step 2.4: escape \\log to log; Step 2.5: escape \\ln to ln; Step 2.6: escape \\sin to sin; Step 2.7: escape \\cos to cos; Step 2.8: escape \\tan to tan; Step 2.9: escape _ and whitespace to nothing; Step 2.10: escape {to (; Step 2.11: escape \} to ); Step 2.12: escape \\pi to PI;

[0013] Step 3: Perform a unified expression conversion on the formula escaped in step 2, distinguishing between negative and minus signs, positive and plus signs, using minus to represent negative signs, plus to represent positive signs, and using E to represent scientific calculation method D;

[0014] Step 4: Division optimization: For continuous multiplication and division in an expression, multiplication should be performed first and then division to reduce precision loss. For example, 1+3 / 4 / 5*5 should be converted to 1+3*5 / 4 / 5.

[0015] Step 5: Initialize the operand mapping set, operator array, and check the legality of the expression: Step 5.1: Operator analysis and recording of position information; Step 5.2: Operand analysis and recording of position information; Step 5.3: Undefined variable or operator check and recording of position information; Step 5.4: Add a terminator to the end of the operator array by default;

[0016] Step 6: Scan the operator list in order and check the validity of each operator according to the operator type:

[0017] Step 6.1: Set the operator index position to 0, the operand index position to 0, the character index position to 0, the operator stack to empty, and the operand stack to empty; Step 6.2: Add the terminator to the operator stack; Step 6.3: Determine whether the character index is less than the operator array size; Step 6.4: If the character index is less than the operator array size, execute 6.5, otherwise terminate the traversal and execute step 7; Step 6.5: Get the current operator and operand based on the operator index position and the operand index position; if the current operand position is before the operator, the current operand is added to the operand stack, and the operand is added to the operand stack. The operand index is incremented by 1, and the process jumps to step 6.3; Step 6.6: On the contrary, if the current operand position is after the operator, the previous operator is taken out from the operator stack, and the priority of the current operator and the previous operator are compared. If the current operator priority is lower than or equal to the previous operator priority, the current operator is put into the operator stack, the operator index is incremented by 1, and the process jumps to step 6.3; Step 6.7: If the current operator priority is higher than the previous operator priority, the operator is popped out of the stack (position check) according to the operator type to avoid performance consumption caused by expression errors, and the judgment is completed and the process jumps to step 6.3;

[0018] Step 6.7.1: If the current operator is of the wrong type, end the process and print an error message; Step 6.7.2: If the current operator is of the terminator type, if the operation stack is not empty, print an error message; otherwise, take the calculation result from the top of the operand stack; Step 6.7.3: If the current operator is of the infix operator type, take out the two operands at the top of the operand stack. The operator position should be between the two operands. The operator and the operation operands are popped out of the stack, and the positions of the previous and next operands are recorded and pushed into the operand stack; if the position rule is not met, it is an error indication and an error message is printed; Step 6.7.4: If the current operator is of the prefix operator type, take out the corresponding operand from the operand stack. The operator position should be before the operand. The operator and the operation operands are popped out of the stack and the front position of the operator is recorded. Set the sum of the operands to the last position and push them into the operand stack; if the position rule is not met, it is an error indication and an error message is printed; step 6.7.5: if the current operator is a postfix operator type, take out the operands corresponding to the operand stack, the operator position should be after the operands, pop the operator and the operation operands, record the position before the first operand and the position after the operator, and push them into the operand stack; if the position rule is not met, it is an error indication and an error message is printed; step 6.7.6: if the current operator is a bracket operator type, take out the operands corresponding to the operand stack, if the previous operator is a left bracket and the next operator is a right bracket, perform an offset operation, pop the operator and the operation operands, record the position before the previous operator and the position after the current operator, push them into the operand stack, and add 1 to the operator index.

[0019] Step 7: Set up a list of operands of equal size according to the size of the data set, and replace the variables with the data set values ​​in equal positions.

[0020] Step 8: If the expression structure is legal, the operator stack and operand stack are calculated in parallel. The idea is very similar to step 6. The difference is that the dual stack is only responsible for the calculation position control, and the actual operands are stored synchronously using the batch calculation stack opNumBatchStack:

[0021] Step 8.1: Set the operator index position to 0, the operand index position to 0, the character index position to 0, the operator stack to 0, the operand stack to 0, and the calculation result array;

[0022] Step 8.2: The terminator is put into the operator stack;

[0023] Step 8.3: Determine whether the character index is less than the operator array size;

[0024] Step 8.4: If the character index is less than the operator array size, execute 8.5. Otherwise, end the traversal and execute step 9.

[0025] Step 8.5: Get the current operator and operand according to the operator index position and operand index position;

[0026] Step 8.5: If the current operand position precedes the operator, the current operand is put into the operand stack, and the corresponding position operand batch is put into opNumBatchStack, the operand index bit is increased by 1, and jump to step 8.3;

[0027] Step 8.6: On the contrary, the current operand position is after the operator, the previous operator is taken out from the operator stack, the priority of the current operator is compared with the previous operator, the current operator priority is lower than or equal to the previous operator priority, the current operator is put into the operator stack, the operator index bit is increased by 1, and jump to step 8.3;

[0028] Step 8.7: The current operator has a higher priority than the previous operator. Pop the operator according to the operator type. After the calculation is completed, jump to step 8.3.

[0029] Step 8.7.1: If the current operator is of the wrong type, end the process, print the error message, and input the operation result into the error message;

[0030] Step 8.7.2: If the current operator is a terminator type and the operation stack is not empty, print an error message; otherwise, take out the calculation results from the top of the stack of operateNumStack in batches, traverse opNumBatchStack synchronously, if there is no result at the corresponding position of the current result array, and the previous operation is error-free, take out one operand from the top of the operand stack of opNumBatchStack each time, and put it into the calculation result array at the corresponding position, otherwise skip the calculation;

[0031] Step 8.7.3: If the current operator is an infix operator type, take out the top two operands of the operand stack. The operator position should be between the two operands. Pop the operator and the operation operands from the stack, record the positions of the previous and next operands, push them into the operand stack, and synchronously traverse opNumBatchStack. If there is no result at the corresponding position of the current result array, and there is no error in the previous operation, take out the top two operands of the operand stack from opNumBatchStack each time, perform the operator operation, and push the calculation result and position information into opNumBatchStack. Otherwise, skip the calculation. If the position rule is not met, it is an error indication, print the error message, and the operation result input is pushed into the error message.

[0032] Step 8.7.4: If the current operator is a prefix operator type, take out the operands corresponding to the operand stack. The operator position should be located before the operands. Pop the operator and the operands from the stack, record the first position of the operator and the last position of the last operand, push them into the operand stack, and synchronously traverse opNumBatchStack. There is no result at the corresponding position of the current result array. There is no error in the previous operation. Each time, take out the operands corresponding to the top of the operand stack from opNumBatchStack, perform the operator operation, and push the calculation result and position information into opNumBatchStack. Otherwise, skip the calculation. If the position rule is not met, it is an error indication, print the error information, and the operation result input is pushed into the error information.

[0033] Step 8.7.5: If the current operator is a postfix operator type, take out the operands corresponding to the operand stack. The operator position should be after the operands. Pop the operator and the operands from the stack, record the position before the first operand and the position after the operator, push them into the operand stack, and synchronously traverse opNumBatchStack. If there is no result at the corresponding position of the current result array, there is no error in the previous operation. Each time, take out the operands corresponding to the top of the operand stack from opNumBatchStack, perform the operator operation, and push the calculation result and position information into opNumBatchStack. Otherwise, skip the calculation. If the position rule is not met, it is an error. Print the error message. Push the error message into the calculation result input. Push the error message into the calculation result input.

[0034] Step 8.7.6: If the current operator is a bracket operator type, take out the corresponding number of operands from the operand stack. If the previous operator is a left bracket and the next operator is a right bracket, perform an offset operation, pop the operator and the operation operands from the stack, record the position before the previous operator and the position after the current operator, push them into the operand stack, and synchronously traverse opNumBatchStack. If there is no result at the corresponding position of the current result array, there is no error in the previous operation. Each time, take out the corresponding number of operands at the top of the operand stack from opNumBatchStack, execute the operator operation, and push the calculation result and position information into opNumBatchStack. Otherwise, skip the calculation.

[0035] Step 9: All calculation results are placed in the result array, and the calculation is completed.

[0036] A web-based application of a method for batch parsing and calculating Latex mathematical formulas.

[0037] The present invention has at least the following beneficial effects:

[0038] The present invention greatly optimizes the syntax parsing process and batch computing efficiency of latex expressions, and can complete the synchronous computing of hundreds of thousands of data within seconds. At the same time, according to the scheme, a complete front-end and back-end computing page and system application based on Mathjax+Java is provided. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0040] Figure 1 Calculation process for latex expression

[0041] Figure 2 Checking the syntax of an expression

[0042] Figure 3 Double stack operation flow for expressions

[0043] Figure 4 For application system interface based on Mathjax and Java language

[0044] Figure 5 The following is a performance comparison chart of using batch stack operations and non-batch stack operations. DETAILED DESCRIPTION

[0045] In order to make the purpose, method scheme and advantages of the embodiments of the present invention clearer, the method scheme in the embodiments of the present invention is clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0046] Based on java language implementation:

[0047] Step 1: Based on the input, determine the variable set, latex formula expression, variable data set, and load the default configuration:

[0048] Step 1.1: Support operators (addition, subtraction, right bracket, scientific notation, cube root, cosine, log, ln, exponentiation, root root, sin, square root, tan, division, terminator, left bracket, minus, multiplication, plus):

[0049]

[0050]

[0051] Step 1.2: Initially set the default operator precedence according to the operator type:

[0052]

[0053]

[0054]

[0055]

[0056] Step 1.3: The default calculation precision is 15 decimal places, and the mathematical constants are configured (E, PI).

[0057] Step 2: Latex expression escape:

[0058]

[0059] Step 3: Convert the escaped formula in step 2 to a unified expression, distinguish between negative and minus signs, positive and plus signs, use minus to represent negative signs, use plus to represent positive signs, and use E to represent scientific calculation method D:

[0060]

[0061]

[0062] Step 4: Division optimization: For continuous multiplication and division in an expression, multiply first and then divide to reduce precision loss. For example, 1+3 / 4 / 5*5 should be converted to 1+3*5 / 4 / 5:

[0063]

[0064]

[0065]

[0066] Step 5: Initialize the operand mapping set, operator array, and expression validity check:

[0067] Step 5.1: Operator parsing and recording position information;

[0068] Step 5.2: Operand analysis and recording of position information;

[0069] Step 5.3: Check for undefined variables or operators and record the location information;

[0070] Step 5.4: By default, add a terminator to the end of the operator array;

[0071] Step 6: Scan the operator list in order and check the validity of each operator according to the operator type. Use Java code to explain in detail:

[0072]

[0073]

[0074]

[0075]

[0076]

[0077] Step 7: Set up a list of operands of equal size according to the size of the data set, and replace the variables with the data set values ​​in equal positions.

[0078] Step 8: If the expression structure is legal, the operator stack and operand stack are calculated in parallel. The idea is very similar to step 6. The difference is that the dual stack is only responsible for the calculation position control, and the actual operands are stored synchronously using the batch calculation stack opNumBatchStack:

[0079]

[0080]

[0081]

[0082]

[0083]

[0084]

[0085]

[0086]

[0087]

[0088] Step 9: All calculation results are placed in the result array, and the calculation is completed.

[0089] The above embodiment is only a programming language embodiment of the present invention, and is not a limitation of the technical solution of the present invention.

[0090] Technical solutions that can be implemented on the basis of the above embodiments without creative work should be deemed to fall within the scope of the present invention patent.

[0091] within the scope of protection of rights.

[0092] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for batch parsing and calculating Latex mathematical formulas, characterized in that: The following steps are involved: Step 1: According to the input, determine the variable set, latex formula expression, variable data set, and load the default configuration; Step 2: Latex expression escape; Step 3: Perform a unified expression conversion on the formula escaped in step 2, distinguishing between negative and minus signs, and positive and plus signs; Step 4: Division optimization: for continuous multiplication and division in an expression, multiply first and then divide to reduce precision loss; Step 5: Initialize the operand mapping set and operator array, and check the legality of the expression based on the position information; Step 6: Scan the operator list in order and check the validity of each operator according to the operator type: Step 7: Set up a list of operands of equal size according to the size of the data set, and replace the variables with the data set values ​​in equal positions. Step 8: If the expression structure is legal, perform parallel calculations on the operator stack and operand stack; Step 9: All calculation results are placed in the result array to complete the calculation.

2. The method for batch parsing and calculating Latex mathematical formulas according to claim 1, characterized in that: The step 1 comprises: Step 1.1: Determine the supporting operators; Step 1.2: Initially set the default operator precedence according to the operator type.

3. The method for batch parsing and calculating Latex mathematical formulas according to claim 2, characterized in that: The step 1.2 comprises: Step 1.2.1: Classify by terminator, left bracket, sign (+-), right bracket, primary operator, secondary operator, tertiary operator, and scientific operator; Step 1.2.2: Priority rules: the terminator is lower than the terminator; the terminator and right bracket are lower than the left bracket; the right bracket is higher than all operators; the terminator, right bracket, first-level, second-level, third-level operators, and scientific operators are lower than scientific operators; the terminator and right bracket are lower than the symbol; the terminator, left bracket, right bracket, symbol, and first-level operators are lower than first-level operators; the terminator, left bracket, right bracket, symbol, first-level, and second-level operators are lower than second-level operators; the terminator, left bracket, right bracket, symbol, first-level, second-level, and third-level operators are lower than third-level operators.

4. The method for batch parsing and calculating Latex mathematical formulas according to claim 1, characterized in that: The step 5 comprises: Step 5.1: Operator parsing and recording position information; Step 5.2: Operand analysis and recording of position information; Step 5.3: Check for undefined variables or operators and record the location information; Step 5.4: By default, a terminator is added to the end of the operator array.

5. The method for batch parsing and calculating Latex mathematical formulas according to any one of claims 1 to 4, characterized in that: The step 6 comprises: Step 6.1: Set the operator index position to 0, the operand index position to 0, the character index position to 0, the operator stack to 0, and the operand stack to 0; Step 6.2: The terminator is put into the operator stack; Step 6.3: Determine whether the character index is less than the operator array size; Step 6.4: If the character index is less than the operator array size, execute 6.

5. Otherwise, end the traversal and execute step 7. Step 6.5: Get the current operator and operand according to the operator index position and operand index position; if the current operand position is earlier than the operator, the current operand is put into the operand stack, the operand index bit is increased by 1, and jump to step 6.3; Step 6.6: Otherwise, the current operand is after the operator, the previous operator is taken out from the operator stack, the priority of the current operator is compared with that of the previous operator, the current operator is lower than or equal to the priority of the previous operator, the current operator is put into the operator stack, the operator index is increased by 1, and jump to step 6.3; Step 6.7: The current operator has a higher priority than the previous operator. Pop the stack according to the operator type, complete the judgment and jump to step 6.

3.

6. The method for batch parsing and calculating Latex mathematical formulas according to claim 5, characterized in that: The step 6.7 comprises: Step 6.7.1: If the current operator is of the wrong type, end the process and print the error message; Step 6.7.2: If the current operator is a terminator type and the operand stack is not empty, print an error message; otherwise, take the calculation result from the top of the operand stack; Step 6.7.3: If the current operator is an infix operator type, take out the top two operands of the operand stack. The operator position should be between the two operands. Pop the operator and the operands from the stack, record the positions of the previous and next operands, and push them into the operand stack. If the position rule is not met, it is an error indication and the error message is printed. Step 6.7.4: If the current operator is a prefix operator type, take out the operands corresponding to the operand stack. The operator position should be before the operands. Pop the operator and the operands from the stack, record the first position of the operator and the last position of the last operand, and push them into the operand stack. If the position rule is not met, it is an error indication and the error message is printed. Step 6.7.5: If the current operator is a postfix operator type, take out the operand corresponding to the operand stack. The operator position should be after the operand. Pop the operator and the operand from the stack, record the position before the first operand and the position after the operator, and push them into the operand stack. If the position rule is not met, it is an error indication and the error message is printed. Step 6.7.6: If the current operator is a bracket operator type, take out the corresponding number of operands from the operand stack. If the previous operator is a left bracket and the next operator is a right bracket, perform an offset operation, pop the operator and the operation operand from the stack, record the position before the previous operator and the position after the current operator, push them into the operand stack, and increase the operator index by 1.

7. The method for batch parsing and calculating Latex mathematical formulas according to claim 5, characterized in that: The step 8 comprises: Step 8.1: Set the operator index position to 0, the operand index position to 0, the character index position to 0, the operator stack to 0, the operand stack to 0, and the calculation result array; Step 8.2: The terminator is put into the operator stack; Step 8.3: Determine whether the character index is less than the operator array size; Step 8.4: If the character index is less than the operator array size, execute 8.

5. Otherwise, end the traversal and execute step 9. Step 8.5: Get the current operator and operand according to the operator index position and operand index position; if the current operand position is before the operator, the current operand is put into the operand stack, and the corresponding position operands are put into opNumBatchStack in batches, the operand index bit is increased by 1, and jump to step 8.3; Step 8.6: On the contrary, the current operand position is after the operator, the previous operator is taken out from the operator stack, the priority of the current operator is compared with the previous operator, the current operator priority is lower than or equal to the previous operator priority, the current operator is put into the operator stack, the operator index bit is increased by 1, and jump to step 8.3; Step 8.7: The current operator has a higher priority than the previous operator. Pop the stack according to the operator type. After the calculation is completed, jump to step 8.

3.

8. The method for batch parsing and calculating Latex mathematical formulas according to claim 7, characterized in that: The step 8.7 comprises: Step 8.7.1: If the current operator is of the wrong type, end the process, print the error message, and input the operation result into the error message; Step 8.7.2: If the current operator is a terminator type and the operation stack is not empty, print an error message; otherwise, take out the calculation results from the top of the stack of operateNumStack in batches, traverse opNumBatchStack synchronously, if there is no result at the corresponding position of the current result array, and the previous operation is error-free, take out one operand from the top of the operand stack of opNumBatchStack each time, and put it into the calculation result array at the corresponding position, otherwise skip the calculation; Step 8.7.3: If the current operator is an infix operator type, take out the top two operands of the operand stack. The operator position should be between the two operands. Pop the operator and the operation operands from the stack, record the positions of the previous and next operands, push them into the operand stack, and synchronously traverse opNumBatchStack. If there is no result at the corresponding position of the current result array, and there is no error in the previous operation, take out the top two operands of the operand stack from opNumBatchStack each time, perform the operator operation, and push the calculation result and position information into opNumBatchStack. Otherwise, skip the calculation. If the position rule is not met, it is an error indication, print the error message, and the operation result input is pushed into the error message. Step 8.7.4: If the current operator is a prefix operator type, take out the operands corresponding to the operand stack. The operator position should be located before the operands. Pop the operator and the operands from the stack, record the first position of the operator and the last position of the last operand, push them into the operand stack, and synchronously traverse opNumBatchStack. There is no result at the corresponding position of the current result array. There is no error in the previous operation. Each time, take out the operands corresponding to the top of the operand stack from opNumBatchStack, perform the operator operation, and push the calculation result and position information into opNumBatchStack. Otherwise, skip the calculation. If the position rule is not met, it is an error indication, print the error information, and the operation result input is pushed into the error information. Step 8.7.5: If the current operator is a postfix operator type, take out the operands corresponding to the operand stack. The operator position should be after the operands. Pop the operator and the operands from the stack, record the position before the first operand and the position after the operator, push them into the operand stack, and synchronously traverse opNumBatchStack. If there is no result at the corresponding position of the current result array, there is no error in the previous operation. Each time, take out the operands corresponding to the top of the operand stack from opNumBatchStack, perform the operator operation, and push the calculation result and position information into opNumBatchStack. Otherwise, skip the calculation. If the position rule is not met, it is an error. Print the error message. Push the error message into the calculation result input. Push the error message into the calculation result input. Step 8.7.6: If the current operator is a bracket operator type, take out the corresponding number of operands from the operand stack. If the previous operator is a left bracket and the next operator is a right bracket, perform an offset operation, pop the operator and the operation operand from the stack, record the position before the previous operator and the position after the current operator, push them into the operand stack, and synchronously traverse opNumBatchStack. If there is no result at the corresponding position in the current result array, there is no error in the previous operation. Each time, take out the corresponding number of operands from the top of the operand stack from opNumBatchStack, perform the operator operation, and The calculation results and position information are pushed into opNumBatchStack, otherwise the calculation is skipped.

9. A web-based application of the method according to any one of claims 1 to 8.