How are graphs plotted or sketched?

If you have a graph plotting software for example mathematica or matlab, or you want to see what the graph of $e^{2x}$ looks like, how do you plot/sketch such a graph?

If you proceed by using a finite number of points, and "extrapolating" and "interpolating", then how do you know that that method is reliable? There are infinitely many smooth(or non-smooth) graphs that can be drawn through a finite number of points.

  • 1
    $\begingroup$ Are you asking how to use the software or what the software does? The first question seems off-topic. The answer to the second question is that convergence of PL approximations is a consequence of continuity, and we generally assume that the functions we're interested in are continuous. (This may sometimes be false, e.g. near a singularity, and even then one has to worry about numerical instability when solving differential equations, for example. But for plotting a function like e^{2x} these issues don't arise.) $\endgroup$ – Qiaochu Yuan Jan 20 '11 at 23:44
  • $\begingroup$ what the software does, and why hand sketched graphs are reliable. $\endgroup$ – picakhu Jan 20 '11 at 23:48
  • 4
    $\begingroup$ Not all software packages check to see that their sketches are reliable. Sometimes the sketches generated by software can be very bad -- frequently it's a poor choice of scale, or poor perspective, or the software doesn't know where the "interesting stuff" is happening. Sometimes the software doesn't notice peculiarities of the function -- vertical asymptotes can cause trouble. "Good software" tends to use adaptive methods that find reasonable bounds on things like $|f(x)|$ and $|f'(x)|$ before attempting to sketch, but it really depends. $\endgroup$ – Ryan Budney Jan 20 '11 at 23:58
  • $\begingroup$ This is not a simple question. Even advanced plotting software like mathematica has its issues with some nasty oscillating function graphs so there is no method yet that always works. However if your function is smooth enough you can make a reasonable interpolation with polynoms and use this to draw the function. $\endgroup$ – Listing Jan 21 '11 at 0:03

Basically (keyword: "basically"), it works like this:

    SET x TO x1
        DRAW LINE BETWEEN f(x) and f(x-step)   // "linear interpolation"
        INCREASE x BY step

Where step is some small number... Something like 0.01, depending on how fast you want it. $step = \lim_{x\to 0^+}$ would be "perfectly smooth", but we don't have the resources for such measures, so we're stuck with anything between $10^{50}$ and $10^{-50}$.

They won't be "infinitely smooth". That would require infinite amounts of RAM and CPU. It only has to "look" smooth. It's only limited by your RAM/CPU, time (unless you feel like waiting a few trillion years), and most importantly, your screen resolution.

More complex plotters can determine the vertical asymptotes, but I don't need to get into that.

  • $\begingroup$ I understand this, but when is it reliable? $\endgroup$ – picakhu Jan 21 '11 at 3:41
  • $\begingroup$ See Ryan's comment above - a good graphing package will attempt to heuristically estimate the modulus of continuity. This is not possible (non-recursive) in the black-box model, but if the function is given explicitly enough, then by bounding the derivative you can bound the modulus of continuity and so draw a meaningful graph. $\endgroup$ – Yuval Filmus Jan 21 '11 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.