A adj A = det A I
> (setq A (sum (product a (tensor x x)) (product b (tensor x y)) (product c (tensor y x)) (product d (tensor y y)) )) > (setq A1 (adjunct A x y)) > (setq AA1 (contract23 (product A A1))) > (setq I (sum (tensor x x) (tensor y y))) > (equal AA1 (product (determinant A x y) I)) t
> (and t t t) t > (and t nil t) nil
> (append (list a b) (list c d)) (a b c d)
> (atom a) t > (atom (list a b c)) nil
> (car (list a b c)) a
> (cdr (list a b c)) (b c)
> (complex-conjugate (sum a (product b i))) (sum a (product -1 b i))
> (setq A (sum (product a (tensor x x)) (product b (tensor x y)) (product c (tensor y x)) (product d (tensor y y)) )) > (component A x y) b
(cond (a1 b1) (a2 b2)... ) returns b of first non-nil a
> (define foo (cond ((zerop arg) "zero") (t "not zero"))) > (foo 0) zero > (foo 1) not zero
> (cons a b) (a . b)
Form: contract12, contract13, contract23, etc. For example (contract12 x) contracts, or sums over, the first and second indices.
> (setq A (sum (product a (tensor x x)) (product b (tensor x y)) (product c (tensor y x)) (product d (tensor y y)) )) > (contract12 A) (sum a d)
> (derivative (cos x) x) (product -1 (sin x))
This function returns the exponential form of the cosine function.
> (printcars (COS x)) sum (product 1/2 (power e (product -1 i x))) (product 1/2 (power e (product i x)))
> (define foo (cons arg2 arg1)) > (foo a b) (b . a) > foo (cons arg2 arg1)
> (derivative (power x 2) x) (product 2 x)
see adjunct
The dot function returns the inner product of scalars and tensors. It is equivalent to an outer product followed by a contraction on the inner indices.
> (setq A (sum (product A11 (tensor 1 1)) (product A22 (tensor 2 2)))) > (setq X (sum (product X1 (tensor 1)) (product X2 (tensor 2)))) > (setq AX1 (dot A X)) > (setq AX2 (contract23 (product A X))) > (equal AX1 AX2) t > (printcars AX1) sum (product A11 X1 (tensor 1)) (product A22 X2 (tensor 2))
The arguments are multiplied left to right, i.e. (dot a b c) = (dot (dot a b) c).
> (derivative (power e x) x) (power e x)
> (equal a a) t
> (setq foo (quote (sum a a))) > foo (sum a a) > (eval foo) (product 2 a)
Exit simple lisp and return to the shell. Control-C also does this.
> (exit) %
> (exp x) (power e x)
Normally, garbage collection occurs when simple lisp runs out of memory. The gc function causes garbage collection to occur immediately. It returns the number of free cells, 1 cell = 12 bytes.
> (gc) 496053
> (define foo (prog (k) (setq k 1) loop (print k) (setq k (sum k 1)) (cond ((lessp k 4) (goto loop))) )) > (foo) 1 2 3
> (greaterp 1 0) t > (greaterp 0 1) nil
The symbol "i" represents the square root of minus one.
> (product i i) -1
Returns t if the argument is an integer, nil otherwise.
> (integerp 2) t > (integerp 2/3) nil
> (integral (power x 2) x) (product 1/3 (power x 3))
The integral function uses a list of expression forms, much like a table of integrals. To extend the capability of the integral function, refer to the file "startup" and follow suit with "add-integral".
See the "hydrogen atom wave functions" example.
See the "hydrogen atom wave functions" example.
Returns the number of cars in a list.
> (length (list a b c)) 3
> (lessp 0 1) t > (lessp 1 0) nil
> (list a b c) (a b c)
> (not nil) t
> (null nil) t
> (numberp 1) t
> (or nil t nil) t > (or nil nil nil) nil
> (power a (sum b c)) (product (power a b) (power a c))
> (print "hello") hello
> (printcars (list a b c)) a b c
> (product a b a) (product b (power a 2))
The "product" function expands products of sums. When applied to tensors, the result is an outer product.
> (setq A (sum (product a11 (tensor 1 1)) (product a12 (tensor 1 2)) (product a21 (tensor 2 1)) (product a22 (tensor 2 2)) )) > (setq X (sum (product x1 (tensor 1)) (product x2 (tensor 2)) )) > (printcars (product A X)) sum (product a11 x1 (tensor 1 1 1)) (product a11 x2 (tensor 1 1 2)) (product a12 x1 (tensor 1 2 1)) (product a12 x2 (tensor 1 2 2)) (product a21 x1 (tensor 2 1 1)) (product a21 x2 (tensor 2 1 2)) (product a22 x1 (tensor 2 2 1)) (product a22 x2 (tensor 2 2 2))
The more familiar inner product is obtained by contraction.
> (printcars (contract23 (product A X))) sum (product a11 x1 (tensor 1)) (product a12 x2 (tensor 1)) (product a21 x1 (tensor 2)) (product a22 x2 (tensor 2))
Use "prog" when more than one expression must be evaluated in a function.
> (define foo (prog () (print arg1) (print arg2) )) > (foo a b) a b
Quote means "don't evaluate."
> (quote (sum a a)) (sum a a)
An apostrophe does the same thing.
> '(sum a a) (sum a a)
> (define foo (prog () (return "hello"))) > (foo) hello
The "run" function evaluates the expressions in a file.
> (run "example1") E=K+V for psi5? t
> (setq foo 1) > foo 1
> (derivative (sin x) x) (cos x)
The SIN function returns the exponential form of the sine function. In some cases it is better to use SIN and COS because many trigonometric simplifications occur automatically.
> (printcars (SIN x)) sum (product -1/2 i (power e (product i x))) (product 1/2 i (power e (product -1 i x)))
> (sum (power (COS x) 2) (power (SIN x) 2)) 1
> (sum a b a) (sum b (product 2 a))
(subst a b c) means substitute a for b wherever it appears in c.
> (subst a b (list a b c)) (a a c)
> (product (tensor x) (tensor y)) (tensor x y) > (product (tensor y) (tensor x)) (tensor y x)
Form: transpose12, transpose13, transpose23, etc. For example (transpose12 x) transposes the first and second indices.
> (setq A (sum (product a (tensor x x)) (product b (tensor x y)) (product c (tensor y x)) (product d (tensor y y)) )) > (printcars (transpose12 A)) sum (product a (tensor x x)) (product b (tensor y x)) (product c (tensor x y)) (product d (tensor y y))
> (zerop 0) t > (zerop 1) nil