This mathematical function (any), the program should solve it itself and build its graph. How to solve a similar problem

Closed due to the fact that the question is too common for participants 0xdb , Sergey , Alex Chermenin , iksuy , Fat-Zer 25 May '18 at 12:45 .

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 .

  • 2
    is any straight? most likely no way - DreamChild
  • specify the question. You are interested in how to draw a graph or how to get the coordinates of points on a graph. - dzukp
  • Need to draw. In general, the task is to write "an application for constructing mathematical functions." - Alexander Startsev

5 answers 5

@Alexander Startsev , you first need to make a simple decomposition of the task. You need the following functionality (at a minimum):

  • Enter where the function is obtained
  • Parser function
  • The function value calculator that works with parser output and a set of arbitrary values
  • Graph Builder
  • Generator set values ​​for the graph. Because there is clearly no rocket science, the simplest is to simply get a large set of function points without approximation.

Here are specific questions on the above components will be much easier to answer.

    You cannot plot an arbitrary function. Consider, for example, how you implement a graph of the Dirichlet function.

      For an arbitrary function - probably in 2 passes.

      On the first, we calculate the values ​​that we somehow aggregate and remember.

      Then we analyze, for example, a range of values, etc.

      Then we read the memorized values ​​and draw (of course, it is possible that instead of memorizing, we re-read the values).

        int f(x) { return x*x; } for(int i=-100; i < 100;i++) { putPoint(x,f(x))//рисует точку с коорд (x,y) } 

        where f (x) is your function. In my example, this is y = x ^ 2; This cycle will draw 100 points from your graph.

        • And, for example, if the function will be hyperbole? - Alexander Startsev

        I hope you don't mean "how to write tungsten"? We need specifics, for which functions to build, what is the error, etc. At least the level of the task. If something like (x^2 + 1)/x — relatively simple functions — is expected at the input, then this is one if you need a functional like in a Makov grapher — with parametric and implicit equations, integration, etc. - then it is much more difficult