# The &kalgebra; Handbook

## Introduction

&kalgebra; has numerous features that allow the user to perform all sorts of mathematical operations and show graphically. At one time, this program was MathML oriented. Now it can be used by anyone with a little mathematical knowledge to solve simple and advanced problems alike.

It includes such features as:

- A calculator for quick and easy evaluation of math functions.

- Scripting capability for advanced series of calculations

- Language capabilities including function definition and syntax autocompletion.

- Calculus functions including symbolic differentiation, vector calculus, and list manipulation.

- Function plotting with live cursor for graphical root finding and other types of analysis.

- 3D plotting for useful visualization of 3D functions.

- A built-in operator dictionary for quick reference to the many available functions.

Below is a screenshot of the &kalgebra; application in action:

Here's a screenshot of &kalgebra; main window &kalgebra; main window

When the user begins a &kalgebra; session, they are presented with a single window consisting of a Calculator tab, a 2D Graph tab, a 3D Graph tab and a Dictionary tab. Within each tab, you will find an input field to enter your functions or calculations, and a display field which shows the results.

At any time the user may manage their session with the main menu Session options:

&Ctrl; N Session New

- Opens a new &kalgebra; window.

&Ctrl;&Shift; F Session Full Screen Mode

- Toogle full screen mode for &kalgebra; window. The full screen mode can also be switched on and off using button at the top right part of &kalgebra; window.

&Ctrl; Q Session Quit

- Shuts the program down.

## Syntax

&kalgebra; uses an intuitive algebraic syntax for entering user functions, similar to that used on most modern graphing calculators. This section lists the fundamental built-in operators available in &kalgebra;. The author of &kalgebra; modeled this syntax after Maxima and maple for users that may be familiar with these programs.

For users that are interested in the inner workings of &kalgebra;, user entered expressions are converted to MathML on the backend. A rudimentary understanding of the capabilities supported by MathML will go a long way toward revealing the inner capabilities of &kalgebra;.

Here is a list of the available operators we have by now:

- + - * / : Addition, subtraction, multiplication and division.

- ^, **: Power, you can use them both. Also it is possible to use the unicode ² characters. Powers are one way to make roots too, you can do it like: a**(1/b)

- -> : lambda. It is the way to specify one or more free variables that will be bound in a function. For example, in the expression, `length:=(x,y)->(x*x+y*y)^0.5`, the lambda operator is used to denote that x and y will be bound when the length function is used.

- x=a..b : This is used when we need to delimit a range (bounded variable+uplimit+downlimit). This means that x goes from a to b.

- () : It is used to specify a higher priority.

- abc(params) : Functions. When the parser finds a function, it checks if abc is an operator. If it is, it will be treated as an operator, if it is not, it will be treated as a user function.

- := : Definition. It is used to define a variable value. You can do things like x:=3, x:=y being y defined or not or perimeter:=r->2*pi*r.

- ? : Piecewise condition definition. Piecewise is the way we can define conditional operations in &kalgebra;. Put another way, this is a way of specifying an if, elseif, else condition. If we introduce the condition before the '?' it will use this condition only if it is true, if it finds a '?' without any condition, it will enter in the last instance. Example: piecewise { x=0 ? 0, x=1 ? x+1, ? x**2 }

- { } : MathML container. It can be used to define a container. Mainly useful for working with piecewise.

- = > >= < <= : Value comparators for equal, greater, greater or equal, less and less or equal respectively

Now you could ask me, why should the user mind about MathML? That’s easy. With this, we can operate with functions like cos(), sin(), any other trigonometrical functions, sum() or product(). It does not matter what kind it is. We can use plus(), times() and everything which has its operator. Boolean functions are implemented as well, so we can do something like or(1,0,0,0,0).

## Using the Calculator

&kalgebra;'s calculator is useful as a calculator on steroids. The user may enter expressions for evaluation in Calculate or Evaluate mode, depending on the Calculator menu selection.

In evaluation mode &kalgebra; simplifies the expression even if it sees an undefined variable. When in calculation mode &kalgebra;, calculates everything and if it finds an undefined variable shows an error.

In addition to displaying the user entered equations and results in the Calculator display, all variables that are declared are displayed in a persistent frame to the right. By double clicking on a variable you will see a dialog that lets you change their values (just a way to trick the log).

The "ans" variable is special, every time you enter an expression, the "ans" variable value will be changed to the last result.

The following are example functions that can be entered in the input field of the calculator window:

- sin(pi)

- k:=33

- sum(k*x : x=0..10)

- f:=p->p*k

- f(pi)

The following shows a screenshot of the calculator window after entering the above example expressions:

Screenshot of &kalgebra; calculator window with example expressions &kalgebra; calculator window

A user can control the execution of a series of calculations using the Calculator menu options:

&Ctrl; L Calculator Load Script

- Executes the instructions in a file sequentially. Useful if you want to define some libraries or resume some previous work.

&Ctrl; G Calculator Save Script

- Saves the instructions you have typed since the session began to be able to reuse. Generates text files so it should be easy to fix using any text editor, like Kate.

&Ctrl; S Calculator Export Log

- Saves the log with all results into an &HTML; file to be able to print or publish.

## 2D Graphs

To add a new 2D graph on &kalgebra;, select the 2D Graph tab and click the Add tab to add a new function. Your focus will go to an input text box where you can type your function.

### Syntax

If you want to use a typical f(x) function it is not necessary to specify it, but if you want a f(y) or a polar function, you will have to add y-> and q-> as the bounded variables.

Examples:

- sin(x)

- x²

- y->sin(y)

- q->3*sin(7*q)

- t->vector{sin t, t**2}

If you have entered the function click on the OK button to display the graph in the main window.

### Features

You can set several graphs on the same view. Just use the Add button when you are in List mode. You can set each graph its own color.

The view can be zoomed and moved with the mouse. Using the wheel you can zoom in and out. You can also select an area with the left button of the mouse and this area will be zoomed in. Move the view with the arrow keys.

The viewport of 2D graphs can be explicitly defined using the Viewport tab on a 2D Graph tab.

In the List tab, you can open an Editing tab to edit or remove a function with double-click and check or uncheck the check box next to the function name to show or hide it.

In the 2D Graph menu you find these options:

- Show or hide the grid

- Keep the aspect ratio while zooming

- Zoom in (&Ctrl; +) and zoom out (&Ctrl; -)

- Save (&Ctrl; S) the graph as image file

- Reset the view to the original zoom

- Select a resolution for the graphs

Below is a screenshot of a user who's cursor is at the rightmost root of the function, sin(1/x). The user who graphed it used very fine resolution to make this graph (as it oscillates at higher and higher frequency near the origin). There is also a live cursor feature where whenever you move your cursor over a spot, it shows you the x and y values in the bottom left corner of the screen. A live "tangent line" is plotted on the function at the live cursor location.

Here's a screenshot of &kalgebra; 2D graph window &kalgebra; 2D graph window

## 3D Graphs

To draw a 3D Graph with &kalgebra; select the 3D Graph tab and you will see an input field at the bottom where you will type your function. Z cannot be defined yet. For the moment &kalgebra; only supports 3D graphs explicitly dependent only on the x and y, such as (x,y)->x*y, where z=x*y.

Examples:

- (x,y)->sin(x)*sin(y)

- (x,y)->x/y

The view can be zoomed and moved with the mouse. Using the wheel you can zoom in and out. Hold the &LMB; and move the mouse to rotate the graph.

The left and right arrow keys rotate the graph around the z axis, the up and down arrow keys rotate around the horizontal axis of the view. Press W to zoom in the plot and S to zoom it out.

In the 3D Graph menu you find these options:

- Save (&Ctrl; S) the graph as image file

- Reset the view to the original zoom in the 3D graph menu

- You can draw the graphs with dots, lines or solid styles in the 3D graph menu

Below is a screenshot of the so-called "sombrero" function. This particular graph is shown using the 3D graph line-style.

Here's a screenshot of &kalgebra; 3D graph window &kalgebra; 3D graph window

## Dictionary

The dictionary provides a list of all &kalgebra; built in functions. It can be used to find the definition of an operation and its input parameters. It's a useful place to go to find the many capabilities of &kalgebra;.

Below is a screenshot of the &kalgebra; dictionary lookup of the cosine function.

Here's a screenshot of the &kalgebra; dictionary window &kalgebra; dictionary window
&commands;

## Credits and License

- Program copyright 2005-2009 &Aleix.Pol;

Documentation copyright 2007 &Aleix.Pol; &Aleix.Pol.mail;

&underFDL; &underGPL;
&documentation.index;