8.15.0.4

1 Introduction🔗

The sicm language defines generic mathematical functions that can operate on a wide variaty of data. For example the following multiplies, adds and applies numbers, symbols, functions and tuples:

Example:
> (simplify ((up (* (+ 4 'a) 'b (λ (x) (/ 1 x)))
                 (/ (λ (t) (exp t)) (λ (q) (+ 4 'a q))))
             't))

'(up (/ (+ (* a b) (* 4 b)) t) (/ (exp t) (+ 4 a t)))

Standard the output will be some internal representation of the data.

Example:
> (+ 4 'a)

'(*number*        . #hasheq((expression . (+ 4 a))))

Usually it is more interesting to see the result as a list of symbols and numbers. To this end you could set up the repl to automatically print the simplified expressions:
(let ([P (current-print)]) (current-print (λ (a) (P (simplify a)))))
However, some simplifications can take a long time. Functions are opaque to the simplifier, so unless applied to a symbol, the output will not be any more informative.

Representing literal mathematical objects is possible: for example 'f could represent a number, a vector, a function, etc. To make it clear that it represents a function it should be defined with (literal-function 'f). If just the quoted symbol 'f is used the default is to treat it as (literal-number 'f).

All sicm generic functions can work with units. So for example:

Example:
> (with-units->expression SI (/ (* :G earth-mass) (expt earth-radius 2)))

'(& 9.826521323507148 (* &meter (expt &second -2)))

calculates the acceleration due to gravity at sealevel. Important constants such as :G have been predefined.

Solvers for linear equations, linear least square, polynomial roots and other can be found in sicm/solve. Some slightly-nonlinear systems also can also be solved:

Example:
> (solve-incremental
   (list (make-equation '(-  3 (+ x y))  (list 'A))
         (make-equation '(-  5 (- x y))  (list 'B))
         (make-equation '(-  3 (+ (* (sqrt x) z) (square y)))  (list 'C)))
   '(x y z))

'(() () (((= z 1) (C B A)) ((= y -1) (B A)) ((= x 4) (B A))) ())

For numeric calculations different tools can be found in sicm/numerics.

Example:
> (multidimensional-minimize (λ (v)
                               (+ (expt (- (ref v 0) 2) 2)
                                  (expt (+ (ref v 1) 1) 2)))
                             '(4 3))

'(1.9999956979475337 -1.0000045718674924)

Example:
> ((make-definite-integrator (λ (x)(/ x)) 1.0 2.0) 'integral)

0.6931471805599415