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
Symbol | Operation |
---|---|
* | Multiplication. See remark 1) |
/ | Division |
+ | Addition |
– | Subtraction |
^ | Power |
=, >, <, >=, <=, <> | Relational symbols (not evaluated) |
==, >>, <<, >>=, <<=, <<>> | Relational symbols (evaluated, see remark 2) |
- 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.
- 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
Constant | Description |
---|---|
True, False | Boolean constants |
Pi | The number π |
EulerE | Euler’s constant e |
NaN | Not-a-number |
{} | The empty set |
Constructions
The scripting language of AlgebraKiT defines the following constructions to build expressions:
Construction | Description |
---|---|
( ) | Parenthesis |
[ ] | Function arguments |
{ } | List |
` ` | Toggle between text (HTML) and math |
[[ ]] | List index |
Some examples:
Expression | Description |
---|---|
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.
Command | Description | Example |
---|---|---|
Simplify | Apply mathematical
rules to simplify the expression as much as possible. |
Simplify[1*x*x] gives x^2 |
RandomInt | Generate a random integer number within a range. | RandomInt[2,10] gives an integer number in the range 2 to 10. |
RandSelect | Select a random element from the list | RandSelect[{1,x,2y}] gives one of the three items in the list. |
Strict | Evaluate a boolean expression. An undetermined expression will result in False | Strict[3>>2]
gives True Strict[x>>y] gives False |
Was this helpful?
0 / 0