2020-12-14 10:43:03 +01:00
|
|
|
|
Overview of features
|
|
|
|
|
Operators: +, -, *, /, !, %
|
2021-06-03 01:01:20 +02:00
|
|
|
|
Groups: (), ⌈⌉, ⌊⌋, []
|
2022-06-03 00:10:20 +02:00
|
|
|
|
Vectors: (x, y, z, ...)
|
|
|
|
|
Matrices: [x, y, z; a, b, c; ...]
|
2020-12-14 10:43:03 +01:00
|
|
|
|
Pre-defined functions and constants
|
|
|
|
|
User-defined functions and variables
|
2021-05-24 00:25:36 +02:00
|
|
|
|
Understands fairly ambiguous syntax. Eg. 2sinx + 2xy
|
2022-06-03 00:10:20 +02:00
|
|
|
|
Complex numbers
|
|
|
|
|
|
|
|
|
|
Piecewise functions: f(x) = { f(x + 1) if x <= 1; x otherwise },
|
|
|
|
|
pressing enter before typing the final "}" will make a new line without
|
|
|
|
|
submitting. Semicolons are only needed when writing everything on the
|
|
|
|
|
same line.
|
|
|
|
|
|
|
|
|
|
Different number bases: Either with a format like 0b1101, 0o5.3, 0xff
|
|
|
|
|
or a format like 1101_2. The latter does not support letters, as they
|
2023-01-24 19:11:35 +01:00
|
|
|
|
would be interpreted as variables. The "base" command can be used to
|
|
|
|
|
tell the REPL to also show output in another number base. For example,
|
|
|
|
|
"base 16" would make it show results in hexadecimal as well as decimal.
|
2022-06-03 00:10:20 +02:00
|
|
|
|
|
|
|
|
|
Root finding using Newton's method (eg. x^2 = 64). Note: estimation and
|
2023-01-24 19:11:35 +01:00
|
|
|
|
limited to one root.
|
2022-06-03 00:10:20 +02:00
|
|
|
|
|
|
|
|
|
Derivation (prime notation) and integration (eg. integral(a, b, x dx)
|
|
|
|
|
The value of an integral is estimated using Simpson's 3/8 rule,
|
|
|
|
|
while derivatives are estimated using the symmetric difference
|
2022-09-30 02:16:05 +02:00
|
|
|
|
quotient (and derivatives of higher order can be a bit inaccurate as of now)
|
2022-06-03 00:10:20 +02:00
|
|
|
|
|
2020-12-14 10:43:03 +01:00
|
|
|
|
Syntax highlighting
|
|
|
|
|
Completion for special symbols on tab
|
2022-03-27 21:32:50 +02:00
|
|
|
|
Sum/prod functions
|
2020-12-14 10:43:03 +01:00
|
|
|
|
|
2022-06-03 00:10:20 +02:00
|
|
|
|
Load files that can contain predefined variable and function declarations.
|
|
|
|
|
(you can also have automatically loaded files)
|
|
|
|
|
|
2020-12-14 10:43:03 +01:00
|
|
|
|
Operators
|
|
|
|
|
+, -, *, /
|
|
|
|
|
! Factorial, eg. 5! gives 120
|
|
|
|
|
% Percent, eg. 5% gives 0.05, 10 + 50% gives 15
|
|
|
|
|
% Modulus (remainder), eg. 23 % 3 gives 2
|
2022-06-03 00:10:20 +02:00
|
|
|
|
and, or, not
|
2020-12-14 10:43:03 +01:00
|
|
|
|
|
|
|
|
|
Completion for special symbols
|
|
|
|
|
You can type special symbols (such as √) by typing the normal function or constant name and pressing tab.
|
|
|
|
|
|
2022-06-03 00:10:20 +02:00
|
|
|
|
* becomes ×
|
|
|
|
|
/ becomes ÷
|
|
|
|
|
and becomes ∧
|
2023-02-09 19:03:24 +01:00
|
|
|
|
not becomes ¬
|
|
|
|
|
or becomes ∨
|
2022-06-03 00:10:20 +02:00
|
|
|
|
[[ becomes ⟦⟧
|
|
|
|
|
_123 becomes ₁₂₃
|
|
|
|
|
asin, acos, etc. become sin⁻¹(), cos⁻¹(), etc
|
2020-12-14 10:43:03 +01:00
|
|
|
|
sqrt becomes √
|
|
|
|
|
deg becomes °
|
|
|
|
|
pi becomes π
|
|
|
|
|
sum becomes Σ()
|
2022-06-03 00:10:20 +02:00
|
|
|
|
prod becomes ∏()
|
|
|
|
|
integrate becomes ∫()
|
2020-12-14 10:43:03 +01:00
|
|
|
|
tau becomes τ
|
|
|
|
|
phi becomes ϕ
|
|
|
|
|
floor becomes ⌊⌋
|
|
|
|
|
ceil becomes ⌈⌉
|
|
|
|
|
gamma becomes Γ
|
|
|
|
|
( becomes ()
|
|
|
|
|
|
|
|
|
|
Variables
|
|
|
|
|
Variables are defined with the following syntax: name = value
|
|
|
|
|
Example: x = 3/4
|
|
|
|
|
|
2022-09-30 02:16:05 +02:00
|
|
|
|
Predefined variables
|
|
|
|
|
ans - receives the value computed of the most recent expression
|
|
|
|
|
|
2020-12-14 10:43:03 +01:00
|
|
|
|
Functions
|
|
|
|
|
Functions are defined with the following syntax: name(param1, param2, etc.) = value
|
|
|
|
|
Examples: f(x) = 2x+3; A(x, y) = (xy)/2
|
|
|
|
|
They are used like this: name(arg1, arg2, etc.)
|
2022-09-30 02:16:05 +02:00
|
|
|
|
Example: f(3) + 3A(2, 3)
|
2020-12-14 10:43:03 +01:00
|
|
|
|
|
|
|
|
|
Predefined functions
|
2022-06-03 00:10:20 +02:00
|
|
|
|
sin, cos, tan, cot, cosec, sec
|
|
|
|
|
sinh, cosh, tanh, coth, cosech, sech
|
|
|
|
|
asin, acos, atan, acot, acosec, asec
|
|
|
|
|
ashin, acosh, atanh, acoth, acosech, asech
|
2020-12-14 10:43:03 +01:00
|
|
|
|
abs, ceil or ⌈⌉, floor or ⌊⌋, frac, round, trunc
|
2022-06-03 00:10:20 +02:00
|
|
|
|
sqrt or √, cbrt, exp, log, ln, arg, Re, Im
|
2020-12-14 10:43:03 +01:00
|
|
|
|
gamma or Γ
|
2022-06-03 00:10:20 +02:00
|
|
|
|
asinh, acosh, atanh, acoth, acosech, asech
|
|
|
|
|
bitcmp, bitand, bitor, bitxor, bitshift
|
|
|
|
|
comb or nCr, perm or nPr
|
|
|
|
|
gcd, lcm
|
|
|
|
|
min, max, hypot
|
|
|
|
|
log - eg. log(1000, 10) is the same as log10(1000)
|
|
|
|
|
root - eg. root(16, 3) is the same as 3√16
|
|
|
|
|
average, perms, sort
|
|
|
|
|
transpose
|
|
|
|
|
matrix - takes a vector of vectors and returns a matrix
|
|
|
|
|
integrate - eg. integrate(0, pi, sin(x) dx)
|
2022-04-24 00:00:08 +02:00
|
|
|
|
sum Eg. sum(n=1, 4, 2n), example below
|
2020-12-14 10:43:03 +01:00
|
|
|
|
|
|
|
|
|
Sum function
|
|
|
|
|
The sum function lets you sum an expression with an incrementing variable.
|
|
|
|
|
It takes three arguments: start value, end value, and expression.
|
|
|
|
|
If you press tab after typing out "sum", it will be replaced with a sigma symbol.
|
2022-04-24 00:00:08 +02:00
|
|
|
|
The expression is what will be summed, and will be able to use the variable defined
|
|
|
|
|
in first argument (eg. n=1). The value of the variable increments by one.
|
|
|
|
|
Example: sum(n=1, 4, 2n) will be the same as 2*1 + 2*2 + 2*3 + 2*4 = 20
|
|
|
|
|
This can for example be used to calculate e: Σ(n=0, 10000, 1/n!) = 2.7182818284590455
|
2021-06-02 22:32:30 +02:00
|
|
|
|
More precision can be gotten by changing the "--precision" flag. Run `kalker --help` for more info.
|
2020-12-14 10:43:03 +01:00
|
|
|
|
|
2022-04-24 00:00:08 +02:00
|
|
|
|
The sum function can also be used to sum vectors, eg. sum(1, 2, 3) or sum(v) or sum[1, 2, 3].
|
|
|
|
|
|
|
|
|
|
Prod function
|
|
|
|
|
The prod function works the same way as the sum function but performs
|
|
|
|
|
multiplication instead of addition.
|
|
|
|
|
|
2020-12-14 10:43:03 +01:00
|
|
|
|
Constants
|
|
|
|
|
pi or π = 3.14159265
|
|
|
|
|
e = 2.71828182
|
|
|
|
|
tau or τ = 6.2831853
|
2021-06-02 22:32:30 +02:00
|
|
|
|
phi or ϕ = 1.61803398
|
2022-06-03 00:10:20 +02:00
|
|
|
|
|
|
|
|
|
Vectors
|
|
|
|
|
A vector in kalker is an immutable list of values, defined with the syntax (x, y, z)
|
|
|
|
|
which may contain an arbitrary amount of items. Generally, when an operation is
|
|
|
|
|
performed on a vector, it is done on each individual item. This means that (2, 4, 8) / 2
|
|
|
|
|
gives the result (1, 2, 4). An exception to this is multiplication with two vectors,
|
|
|
|
|
for which the result is the dot product of the vectors. When a vector is given to a
|
|
|
|
|
regular function, the function is applied to all of the items in the vector.
|
2022-09-30 02:16:05 +02:00
|
|
|
|
|
2022-06-03 00:10:20 +02:00
|
|
|
|
Indexing
|
|
|
|
|
A specific item can be retrieved from a vector using an indexer, with the
|
|
|
|
|
syntax vector[[index]]. Indexes start at 1.
|
2022-09-30 02:16:05 +02:00
|
|
|
|
|
2022-06-03 00:10:20 +02:00
|
|
|
|
Vector comprehensions (experimental)
|
|
|
|
|
Vectors can be created dynamically using vector comprehension notation, which is
|
|
|
|
|
similar to set-builder notation. The following example creates a vector containing
|
|
|
|
|
the square of every number between one and nine except five: [n^2 : 0 < n < 10 and n != 5].
|
|
|
|
|
A comprehension consists of two parts. The first part defines what should be done to each
|
|
|
|
|
number, while the second part defines the numbers which should be handled in the first
|
|
|
|
|
part. At the moment, it is mandatory to begin the second part with a range of the
|
|
|
|
|
format a < n < b where n defines the variable which should be used in the comprehension.
|
|
|
|
|
Several of these variables can be created by separating the conditions by a comma,
|
|
|
|
|
for example [ab : 0 < a < 5, 0 < b < 5].
|
|
|
|
|
|
|
|
|
|
Matrices
|
|
|
|
|
A matrix is an immutable two-dimensional list of values, defined with the syntax [x, y, z; a, b, c]
|
|
|
|
|
where semicolons are used to separate rows and commas are used to separate items. It is also
|
|
|
|
|
possible to press the enter key to create a new row, instead of writing a semicolon. Pressing
|
|
|
|
|
enter will not submit if there is no closing square bracket. Operations on matrices work the
|
|
|
|
|
same way as with vectors, except that two matrices multiplied result in matrix multiplication.
|
2022-09-30 02:16:05 +02:00
|
|
|
|
It is also possible to obtain the transpose of a matrix with the syntax A^T, where A is a matrix
|
2022-06-03 00:10:20 +02:00
|
|
|
|
and T is a literal T.
|
2022-09-30 02:16:05 +02:00
|
|
|
|
|
2022-06-03 00:10:20 +02:00
|
|
|
|
Indexing
|
|
|
|
|
A specific item can be retrieved from a matrix using an indexer, with the
|
|
|
|
|
syntax matrix[[rowIndex, columnIndex]]. Indexes start at 1.
|
|
|
|
|
|
|
|
|
|
Files
|
|
|
|
|
Kalker looks for kalker files in the system config directory.
|
|
|
|
|
|
|
|
|
|
Linux: ~/.config/kalker/
|
|
|
|
|
macOS: ~/Library/Application Support/kalker/ or ~/Library/Preferences/kalker
|
|
|
|
|
Windows: %appdata%/kalker/
|
|
|
|
|
|
|
|
|
|
If a file with the name default.kalker is found, it will be loaded automatically every time
|
|
|
|
|
kalker starts. Any other files in this directory with the .kalker extension can be loaded
|
2022-09-30 02:16:05 +02:00
|
|
|
|
at any time by doing load filename in kalker. Note that the extension should not be included here.
|