# Efficient graph plotting techniques

This topic is 2882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello everybody,

I've got a few questions concerning techniques to plot the graphs of functions.
I've written a bunch of libraries which can simplify algebraic equations and what not, and also evaluate user defined functions. When drawing these function however, I come accross several problems:

Right now I'm calculating a new y value say, every 3 pixels. This can take quite a while with longer functions, but still works rather fast since they are in RPN (postfix). Isn't there an easier/more efficient way to draw the graph? I imagine just calculating a few points and then interpolating the curve might work, but I don't know how prone to error that is.

I also have some problems when it comes to limits of functions. If I increase the step size dx for which I always calculate new y values, I might miss a limit, and the result of this can be seen in the second picture (the first picture is a close up):

http://i51.tinypic.com/2gu9px0.jpg

http://i55.tinypic.com/2vi2nw3.jpg

In the second pic, the curve should go all the way out of window, so I'd need to determine a value y1, which will serve as a sort of boundary, after which everything else is interpreted as +/-Infinity. Any ideas?

Cheers,
Chris

##### Share on other sites
One option would be to differentiate the function and use that to graph the curve (c.f. the way many line-drawing algorithms and rasterization algorithms work).

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 9
• 24
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633383
• Total Posts
3011591
• ### Who's Online (See full list)

There are no registered users currently online

×