libsexpr - functions
libsexpr recognizes most of the mathematical functions included in the standard C library (there's a list below) in parsed expressions.
Adding new functions/unary operators and binary operators is quite
straightforward: a C function implementing the operator has to be written.
It has to accept one or two arguments of type double and return
a double. Then the function has to be added to the function list
in mathfunc.c file and the library needs to be recompiled.
Functions add and neg can serve as trivial examples
(they're also in file mathfunc.c).
A few examples of expressions:
a2 | a^2 |
ex2+5 | exp(x^2 + 5) |
sin x | sin(x) or sin x |
cos 2x | cos(2*x) (parens required) |
ctg x | 1/tg(x) |
Functions and unary operators:
- -
- negation
- abs
- absolute value
- cbrt
- cube root
- cos
- cosine
- cosh
- hiperbolic cosine
- exp
- exponential function
- ln, log
- natural logarithm
- log10
- base 10 logarithm
- tan, tg
- tangent
- tanh
- hiperbolic tangent
- sin
- sine
- sinh
- hiperbolic sine
- sqrt
- square root
Binary operators:
- +
- addition
- -
- subtraction
- *
- multiplication
- /
- division
- ^
- raising to the power of