Scripting concepts

Variable definitions

A variable is a sequence of symbols. Allowed symbols are letters, digits, and the underscore. The first symbol must be a letter.

You can create a definition using the symbol :=.

my_variable:= 2x^2-3x+4

Note that the definition does not have to be a number, but can be any mathematical expression.

Operators

The following table lists the basic math operators

SymbolOperation
*Multiplication. See remark 1)
/Division
+Addition
Subtraction
^Power
=, >, <, >=, <=, <>Relational symbols (not evaluated)
==, >>, <<, >>=, <<=, <<>>Relational symbols (evaluated, see remark 2)
  1. The multiplication symbol is optional. So 3x is interpreted as 3*x. However, ab is interpreted as the variable ‘ab’ and not as a*b. You should add a times symbol or an extra space if you intend the multiplication.
  2. The relational symbols =, >, <, <=, and >= are used to construct mathematical relations without evaluating them. E.g. x^2=2x is an equation, whereas 2==3 is an expression that will be evaluated as False.

Constants

ConstantDescription
True, FalseBoolean constants
PiThe number π
EulerEEuler’s constant e
NaNNot-a-number
{}The empty set

Constructions

The scripting language of AlgebraKiT defines the following constructions to build expressions:

ConstructionDescription
( )Parenthesis
[ ]Function arguments
{ }List
` `Toggle between text (HTML) and math
[[ ]]List index

Some examples:

ExpressionDescription
Sin[2 x]The sine of 2x
v:= {1, 2a, x^y}Define variable v as a list of 3 items
v[[2]]Take the 2nd element of the list (which is 2a in this case).
Note that the first element has index 1, not 0.
Text[`this is a text`]A command that contains text

Some essential commands

The complete list of commands can be found in the Syntax guide. The following table lists the commands that are used most often.

CommandDescriptionExample
SimplifyApply mathematical rules to simplify the expression as much as possible.
Simplify[1*x*x] gives x^2
RandomIntGenerate a random integer number within a range.RandomInt[2,10] gives an integer number in the range 2 to 10.
RandSelectSelect a random element from the listRandSelect[{1,x,2y}] gives one of the three items in the list.
StrictEvaluate a boolean expression. An undetermined expression will result in FalseStrict[3>>2] gives True
Strict[x>>y] gives False

Was this helpful?

0 / 0