# Graphing with HC

**Graphing support was introduced with version 0.6 of HC, in 0.7, I added 3D graph support, in 0.9.2, I added support for multiple functions displayed on one graph, and in 2.0, I added support for parametric graphing and slope fields.**

HC uses the plplot library to generate the graphs, and uses the PNG driver on Linux et. al, or wingcc if on Windows.

**This is now supported both in the CLI and GUI versions.**

__Example usage for__

**2D graphs**Usage is simple; fire up your copy of hc and type something according to the following syntax:

(xmin, etc., are optional, the last will be used if none will be entered)graph(expr[,xmin,xmax,ymin,ymax])

and of course replace expr with the expression you want to use for your graph (for example x^2), and xmin, xmax, ymin and ymax with the coordinates of the "window" of the graph.

If on Linux/*nix, you will then be prompted to enter a filename to save the graph to; enter something ending in .png, for example graph.png.

Afterwards, simply open the newly generated graph.png with your favorite image viewer.

If on Windows, the graph should be displayed right away, using the wingcc driver.

__Example generated 2D graph__

## As you can see, hc also properly handles discontinuities.

If you want to graph multiple functions in one graph, use the gmul() function, which takes an arbitrary number of function expressions as its argument.

For example, to graph the functions x, x^2, x^3 and x^4 on the same graph, you would use:

(note : to set xmin, xmax, ymin, ymax, call graph() first with one of the functions and the corresponding xmin, etc.)gmul(x,x^2,x^3,x^4)

Which would show:

__Example usage for__

**3D graphs**Usage is very similar to 2D graphs; only you have to use the graph3() function, instead of graph().

Not surprisingly, the syntax for this function is:

(xmin, etc., are again optional)graph3(expr[,xmin,xmax,ymin,ymax,zmin,zmax])

Again, replace expr with a valid expression you want to use for your graph (for example (x^3*y-y^3*x)/390 (you could also use implied multiplication from version 0.9.3)), and xmin, xmax, ymin, ymax, zmin and zmax with the appropriate coordinates.

__Example generated 3D graph__

__Example usage for__

**Parametric equations**The corresponding function is:

(tmin,etc., are again optional)graphpeq(expr_x,expr_y[,tmin,tmax,xmin,xmax,ymin,ymax])

Similarly as for the previous functions, just replace expr_x and expr_y with valid expressions for x and y respectively in terms of t, and if you want to, you can specify the tmin,tmax, etc., intervals.

__Example generated parametric equation graph__

graphpeq(sin(t),cos(t),0,2pi,-1,1,-1,1)

__Example usage for__

**slope fields**The corresponding function is:

(xmin, xmax, etc. are optional)slpfld(expr[,xmin,xmax,ymin,ymax])

The principle stays the same as for the other functions -- replace expr with a valid expression in terms of x and y, and xmin, etc., with appropriate coordinates if you want.

__Example generated slope field__

slpfld(x+y)