Chapter 2. 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).