There is a formula editor for indicators, the formula is saved as a text string. Then, when calculating the index, the formula is disassembled into a structure in the form of a tree and calculated. How to check that the entered formula has not been saved previously for some other indicator? For example, a formula of the form (a+b)*c is equal to ac+bc . I would be grateful for any help, at least a link to any literature.

Closed due to the fact that the issue is too general for the participants jfs , AK ♦ , Harry , pavel , aleksandr barakin 14 Jan '17 at 1:32 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 7
    Oh. You are asked to write a system of symbolic mathematics, like Wolfram'a? If this is a student project, this is a cool project, congratulations. If this is a job at work, ask for senior position and tripling of salary. - VladD
  • This is the task for the work, and the system is almost ready, I want to fasten the identity check, so I wrote that I would be happy with any reference to the literature. - Aleksei Chibisov
  • Google “symbolic mathematics systems”, and this task is very difficult if you take it seriously. For example, you will have to know that the formulas sin(x)^2 and 1 - cos(x)^2 same. - VladD
  • one
    I know only one reliable way to solve this problem, without going into symbolic calculations - to calculate the value of both functions on the entire domain and to compare. In compilers, there is a similar task (to simplify expressions, to open parentheses), and there it has not yet been fully decided. - KoVadim
  • one
    @Anton Shchyrov subtract from one tree another? How is this done? - Aleksei Chibisov

1 answer 1

I think that with 100% guarantees the task cannot be solved.
In my opinion, should do so.
1. To learn how to describe the scope of a function's parameters definition according to the principle “general-particular”, where by “general” we mean the type of variable and its boundaries, and by “special” we mean exceptions (zones of special attention).
2. To learn how to describe the domain of definition of a function of several parameters (the decisive rule "hit-do not hit").
3. Write a generator for each parameter and check for the domain of definition.
4. Write tests for cross-checking of functions, separately for parameters and areas of definition.
5. Write a test for checking the values ​​of functions.
6. Read additional literature on unit tests.
7. Learn how to make clear reports on the results of the test (the hesitant consumer should see the forest behind the trees).