Algebrakit Scripting Language

Algebrakit offers a scripting language to give you more control over defining random exercise parameters. This scripting language provides commands to manipulate mathematical expressions, check conditions, work with lists, and much more.

Warning

The Algebrakit scripting language is an advanced concept. If you have no experience with programming, it is better to use the form for random exercise parameters.

Script Variables

A variable is a sequence of letters, digits. The first symbol must be a letter.

You can assign a math expression to a variable using the definition symbol ":="

Example
# Simple variable definitions
v:= 5
v2:= 10

# Variables can have math expressions as definition
expr:= v*x^2+v2*x
equation:= expr=0

Example of a script defining four variables. Note how you can write comments after the #-symbol.

Operators

Operators are the symbols to create mathematical expressions.

Symbols Description
*, / Multiplication and division
+, - Addition and subtraction
^ Power
=, <, >, <=, >=, <> Relation symbols
==, <<, >>, <==, >==, <<>> Relation symbols (evaluated)

The multiplication symbol is optional, so 3x is equivalent to 3*x. Be careful when you multiply variables, though. ab is the two-letter variable 'ab' and not a*b. You can add a space and write a b to resolve this ambiguity.

Use relation symbols to construct equations and inequalities.

  • x^2=2x is an equation
  • 2==3 is an expression that evaluates to False.

Constants

The following symbols represent mathematical constants.

Symbols Description
True, False Boolean constants
Pi The number π\pi
EulerE Euler's constant ee
Infinity Mathematical infinity \infty
{} Empty set \emptyset
NaN Not a Number

Parentheses

Parentheses in math expressions can have several meanings. The Algebrakit scripting language uses alternative delimiters to prevent ambiguity.

Delimiter Description
(...) Standard parentheses (grouping)
[...] Function evaluation
{...} List
[[...]] List index or argument selector

Here are some examples:

Expression Description
Sqrt[2x] 2x\sqrt{2x}
a(b+c) a×(b+c)a\times(b+c)
a[b+c] Function aa evaluated at b+cb+c
v:={1, 2a, x^y} Define variable vv as a list of 3 items
v[[2]] The second element of the list (2a2a)

Other notations

Here are some other notations that do not fall under the previous categories.

Expression Description
' ', 'm' Write units using single quotes, the unit m\text{m} (meter)
`...` Switch to regular text using backticks