Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
1  
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.) –  Qiaochu Yuan Jan 20 '11 at 23:44
    
what the software does, and why hand sketched graphs are reliable. –  picakhu Jan 20 '11 at 23:48
4  
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. –  Ryan Budney Jan 20 '11 at 23:58
    
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. –  Listing Jan 21 '11 at 0:03
add comment

1 Answer 1

up vote 1 down vote accepted

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

BEGIN
    DECLARE x
    SET x TO x1
    WHILE x IS LESS THAN TO x2
        DRAW LINE BETWEEN f(x) and f(x-step)   // "linear interpolation"
        INCREASE x BY step
    END WHILE
END

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.

share|improve this answer
    
I understand this, but when is it reliable? –  picakhu Jan 21 '11 at 3:41
    
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. –  Yuval Filmus Jan 21 '11 at 4:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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