I am developing a 2D plotting program for functions of 1 variable. It is designed to be very simple so that the user should not have to select the initial plot limits (or "range").
Are there known algorithms that can find the most interesting plot limits, knowing only the function f(x) ?
Notes:
- The definition of interesting plot limits is not well defined here. This is part of the question: what is the most interesting part of the plot?
- I already have an algorithm to determine the range of x values where the function f has finite values.
- I am using Javascript, but any language is ok.
- I don't want to use existing libraries.
- The function f is restricted to expressions that the user can write with the basic math operators
+ - * / ^and functionsexp log abs sqrt sin cos tan acos asin atan ceil floor. - Using the Google graphs, you can get some examples of automatic limits. Typing
graph sin(x)works pretty well, butgraph exp(x)andgraph log(x)don't really give the best results. Also,graph sin(x*100)*exp(-x^2)does not choose the limits I would qualify as the most informative. But it would be good enough for me.
UPDATE:
I found that PlotRange in Mathematica does that automatically very well (see here). Is the source code available, or a reference explaining the algorithm? I could not find it anywhere.
UPDATE:
I started using an adaptative refinement algorithm to find informative plot ranges, inspired from this site. It is not working perfectly yet, but the current progress is implemented in my project here. You can try plotting a few functions and see how it works. When I have a fully working version I can post an answer.