From: Raymond Toy <toy.raymond@gm...>  20140530 20:40:53

>>>>> "Jaime" == Jaime Villate <villate@...> writes: Jaime> On 30052014 17:08, Raymond Toy wrote: >> The plot routines fundamentally just >> uniformly sample the x range. The adaptive routine just looks to see >> if the plot is sufficiently smooth and, if not, subdivides the >> interval until it is, or finds a discontinuity. >> >> Can't remember the exact details, but I've seen samples where, say, >> the xrange is [5, 5] and the sampling never finds the >> discontinuity. But if you change the xrange to, say, [4, 5] the >> discontinuity shows up very clearly. Jaime> Another example are the plots of these two functions with a Jaime> discontinuity at x=1: Jaime> plot2d(x*sqrt(x2+1/x)/(x1),[x,0,2]); Jaime> plot2d(unit_step(x1),[x,0,2],[y,1,2]); Jaime> plot2d shows the discontinuity in the first one, but not in the second one. There's a slight difference between these two plots. For the first, evaluation of the function at 1 produces an error that is caught. For the second, unit_step is defined everywhere. I think it's fairly difficult to determine if an apparent discontinuity is really a discontinuity or a very steep slope. By default the adapt depth is 5, so after 5 splittings of an interval, adaptive plotting gives up, and just pretends it is smooth. I instrumented the plotter to print out a bit of info. For the first plot the limit is reached in the intervals [0, .00215...], [.0215..., .00431...], [.00431..., .00646...], [.00646..., .00862...], [.9957..., .9978...], [.9978..., 1.0], [1.0, 1.002...], [1.002..., 1.004...] For the second, the limit is reached at the interval [1.0, 1.00215...], [1.00215..., 1.00431...]. Increasing adapt_depth will make plotting more expensive but also narrow down the areas where the discontiniuty is. Ray 