Math graph plot

How can develop a system to draw on the screen the graph of a function?

I already have the analysis system of mathematical expression, now I want to draw the graph of expression.

How is the best way to implement this ?

At now, I'm thinking of doing the this..:

( this is just a ideia of code... )

Using al_put_pixel at each sample point is one approach, but what you'll get is a series of dots. You might have better luck using a line between each sample point to fill in the in-between spaces.

Also note that in Allegro, the origin is in the upper-left corner with x increasing to the right and y increasing to the bottom. The y coordinate is likely the inverse of how you typically think of the Cartesian plane.

Hi StevenVI

About coordinates, I know that..., I will make a simple calculus to fix this...

About use a line... if I need to drawn a parabola, or drawn a sine wave, I believe that for these cases, it would be better to put pixel by pixel, or would have some more efficient approach?

Sorry -- I'm not trying to confuse you, but I may be misunderstanding your intentions. If you want to draw a continuous curve, you'd want to use a line, because what you're actually doing is drawing a polygon that approximates the function using the finite pixels in your bitmap. Thus you'd use lines for each segment in the polygon.

If you want to just see each sample point rather than an approximate curve, then you'd want to use pixels.