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)
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
Example 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.)
Which would show:
Example multiple functions graph

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)
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 3D graph

Example usage for Parametric equations
The corresponding function is:
(tmin,etc., are again optional)
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
Example parametric graph

Example usage for slope fields
The corresponding function is:
(xmin, xmax, etc. are optional)
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
Example slope field graph

Back to HC's main page