For the firstquestion, usually we calculate some function value at some discrete point and connect them sequentially to approximate the graph of the function. The following code fragment can show you the main idea
x(0) = x0 + LowX
y(0) = f(x(0)) - y0
MoveTo (x(0), y(0))
for i = 1 to N
x(i) = x(i - 1) + delta
y(i) = f(x(i))
Line (x(i-1), y(i - 1))-(x(i), y(i))
next i
where (x0, y0) is the screen coordinate of the origin, LowX is the lower bound of the x, delta is increaments of x, f() is the function.