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.
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 ":="
# 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 equation2==3
is an expression that evaluates toFalse
.
Constants
The following symbols represent mathematical constants.
Symbols | Description |
---|---|
True, False |
Boolean constants |
Pi |
The number |
EulerE |
Euler's constant |
Infinity |
Mathematical infinity |
{} |
Empty set |
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] |
|
a(b+c) |
|
a[b+c] |
Function evaluated at |
v:={1, 2a, x^y} |
Define variable as a list of 3 items |
v[[2]] |
The second element of the list () |
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 (meter) |
`...` | Switch to regular text using backticks |