Graphing equations using open-source software KAlgebra
Posted by Greten on 20 May 2013 under Tools
In one of my earlier posts, I discussed how to use GraphCalc to graph functions. GraphCalc is a wonderful free/open-source software (FOSS) that is very useful in mathematics education. However, despite being a FOSS program, it supports only Windows and not FOSS operating systems such as GNU/Linux and its forks. It has a Linux installer, but only for its very first version (version 0.0.1 with 53KB installer compare to Window's version 4.0.1 with 856KB installer). For that, I decided to find another FOSS graphing calculator. Using the Ubuntu Software Center, I discovered KAlgebra.
KAlgebra is is similar to GraphGalc in several ways but also have lots of differences. I would say it is better in GraphCalc in graphing 2D functions but has lots of rooms for improvement in 3D functions.
Features of KAlgebra
- Graph functions in 2 dimension (x and y, with y as dependent variable or vice versa) or in 3 dimensions (x, y, and z, with z as dependent variable).
- Unlimited 2D functions in one coordinate system (actually, I am not sure if it's unlimited but I tried more than 30 and I already got tired trying to test the limit of KAlgebra).
- Alter the smoothness of the graph with options poor, normal, fine, and very fine (the 'poor' graph is still smoother than the 2D graph of GraphCalc).
- Show or hide grid lines in 2D graph.
- Both 2D and 3D graphs can be zoomed-in or zoomed-out (using the mouse wheel between the left and right buttons).
- Save the graph as SVG or as PNG image file (by pressing CTRL + S).
Limitations of KAlgebra
- Only one graph in 3D at a time.
- The 3D graph is confined in a cube with size somewhere in between 7 units x 7 units x 7 units and 8 units x 8 units x 8 units . I could not determine the exact size because the 3D graph does not have any grid to indicate the units. If the graph extends beyond the cube, it is abruptly cut.
- For 3D functions that do not extend to infinity in any direction (e.g. top-half of a sphere: f(x,y) = C - x2 - y2), if the surface is set to either Lines or Solid, there is some "ray of light" projection that extends to the down-right direction.
- The z-axis of the 3D graph can only be rotated on the plane that is normal to the plane of the monitor and parallel to the top-down direction no matter how you drag the graph around with mouse i.e. the blue line representing z-axis is always vertical.
Graphing 2D Functions
The functions in KAlgebra must be encoded in the form of y = f(x). Suppose you want to graph:
x + y = 2
You need to do some algebraic manipulations first so that y is alone on one side of the equation. In this example, all we need to do is to transpose x to the other side.
y = 2 - x
Then, go to the 2D tab of KAlgebra and encode in the input field everything on the other side of the equal sign opposite that of y. You need to encode it as follows:
x -> 2 - x
You may encode it with or without space between the characters except for the '->' part, which must not have space between the dash and the greater than sign. However, in most functions, the entire 'x->' part can be skipped. It basically tells KAlgebra that x is the independent variable. If you encode just 2 - x, then KAlgebra can immediately tell that x is the independent variable and automatically append 'x->'.
You will see a small preview underneath the input field. Between the input and the small preview, there is a drop down menu through which you can choose the color of the graph.
When you click the OK button, the input field and the small preview will be replaced by a list of functions, and the graph will go to the main Cartesian coordinate system.
At this point, you may either Edit the function you just encoded by double-clicking it on the list, or Add a new function by clicking the +Add tab at the bottom of the list. Clicking on either of these will replace the list with the input and preview interface that was there earlier.
Suppose we add a new function, let's say:
y = cos(x)
After encoding it, seeing the preview and clicking the OK button, the two functions are now in the same Cartersian coordinate system.
You will notice that one of the functions is always active (has gray background) and its graph is thicker. You can click the functions in the list and see which one becomes thicker. You can use this to tell which graph belongs to which function in case you made several graphs. However, one limitation (aside from those already mentioned) is that one function is always active. Thus, one graph is always thicker.
The graph of constants is either a horizontal line or a vertical line. Horizontal line if the equation is y = constant and vertical line if x = constant.
Graphing constants on KAlgebra can be confusing at first because you need to encode the variable opposite that of the one you write in equation form. For example, you want to graph:
x = -1
To graph the equation above, you need to encode the following in the in the input field.
y -> -1
Basically, we are telling KAlgebra that y is the independent variable. The value of x will always be -1 regardless of the value of y. On the other hand, if you want to graph:
y = 2
To graph this equation, you need to encode the following in the in the input field.
x -> 2
Shown in the screenshot below are the graphs of constants x = -1 and y = 2.
Graphing inverse of a function
You can graph the inverse of a function by replacing all instances of x with y in the input field. For example, to graph y = sec(x), you need to encode the following in the input field.
x -> sec(x)
To graph the inverse of the secant function, you need to encode the following in the input field. You may do this either as a new function or by editing an already graphed secant function.
y -> sec(y)
Note that the inverse of a fraction may or may not be also a function. KAlgebra will still graph it nonetheless. The screenshot below shows the graph of the inverse of secant function.
Adjusting 2D Viewport
You can adjust the viewport of the graph by (1) clicking the right arrow at the bottom-right corner until the Viewport Tab becomes visible and (2) clicking on it (the Viewport Tab).
You will then open an interface with four input fields. The Left and Top corresponds to the coordinates of the top-left corner, while Width and Height corresponds to the dimensions of the Cartesian coordinate system that is visible on the interface.
In this example, we want the top-right corner of the Cartesian coordinate system to fall on point (-12,10), its width to be 24 units and its height to be 20 units.
You will notice that the width and height are double of that of left and top values respectively. This is how we do it if we want the point (0,0) to be at the center of the interface, but it is not in any way required.
KAlgebra may sometime not follow the exact width and height you indicated depending on how you adjusted the window e.g., you have a non-square rectangular interface, but the width and height you encoded have equal units. Of course, you can drag the sides and corners of the window to make the interface square.
Graphing 3D functions
In graphing 3D function, there is no 'x ->' in the input field. You do not get to tell KAlgebra which variables are dependent and which are independent. Variables x and y are always independent and z is always dependent.
Suppose we want to graph:
All we need to do is to encode everything on the side of equal sign opposite that of z in the input field. Since we cannot type fractions and exponents, we need to type it as follows: we replace the fraction with its decimal form, apply distributive property, and encode exponents with karet sign.
0.5x^2 + 0.5y^2
The output 3D graph is shown in the screenshot below.
If you are using Ubuntu, you can download and install KAlgebra using Ubuntu Software Center. I am not sure about other Linux distributions. As of today, 20 May 2013, there seems to be no way of downloading KAlgebra as per this bug report in KDE's website.
I tried searching Google if there are other ways of downloading and installing KAlgebra but I could not find anything that will install it. There are some discussions about downloading the source code and compiling them but I don't have experience with this so I did not try them. Apparently, there are no KAlgebra versions for Windows, Mac and other proprietary operating systems.
Last updated on 20 May 2013.
Learn from others
Share your thoughts
* Required. Your email will never be displayed in public.