I trying to do a small program to display a fucntion graphically.
for example:
y=x^2
to:
a xy axis represented by dots(.) and the function lines represented with (#)
It will be very helpfull if you give me some guidelines or steps that i must follow! Thanks!
well, if you want to hard code a function, then just write double f(double x){ return x*x; }
and for(double x = x_min; x < x_max; x += step) draw_line(x, f(x), x+step, f(x+step));(which can be optimized so that you don't calculate every f(x) twice)
the difficulty arises when you want to parse the function from user input. that itself isn't too complicated, but what do you do when user enters 1/x ? with my code you'd get http://i56.tinypic.com/fwqdsm.png which is obviously not right. I have no idea how to prevent that without constructing a mechanism that can solve any equation.