Of course, the most important function is:

`(help)`

- Outputs a listing of all the available classes, their properties, default values, and types. Also lists the input and output variables.

Remember, Guile lets you enter expressions and see their values interactively. This is the best way to learn how to use anything that confuses you--just try it and see how it works!

`(set!`

*variable value*)- Change the value of

to*variable*

.*value* `(define`

*variable value*)- Define new

with initial*variable*

.*value* `(list`

*[ element1 element2 ... ]*)- Returns a list consisting of zero or more elements.
`(append`

*[ list1 list2 ... ]*)- Concatenates zero or more lists into a single list.
`(`

*function [ arg1 arg2 ... ]*)- This is how you call a Scheme

in general.*function* `(define (`

*function [ arg1 arg2 ... ]*)*body*)- Define a new

with zero or more arguments that returns the result of given*function*

when it is invoked.*body*

`(define-param`

*name**default-value*)- Define a variable

whose value can be set from the command line, and which assumes a value*name*

if it is not set. To set the value on the command-line, include*default-value*

on the command-line when the program is executed. In all other respects,*name*=*value*

is an ordinary Scheme variable.*name* `(set-param!`

*name**new-default-value*)- Like
`set!`

, but does nothing if

was set on the command line.*name*

Scheme includes full support for complex numbers and arithmetic;
all of the ordinary operations (`+`

, `*`

,
`sqrt`

, etcetera) just work. For the same reason, you can
freely use complex numbers in libctl's vector and matrix functions,
below.

To specify a complex number *a*+*b*i, you simply use the
syntax

if *a*+*b*i*a* and *b* are
constants, and `(make-rectangular `

otherwise. (You can also specify numbers in "polar" format
a*e*a* *b*)^{ib} by the syntax

or *a*@*b*`(make-polar `

.)
*a*
*b*)

There are a few special functions provided by Scheme to manipulate
complex numbers. `(real-part `

and
*z*)`(imag-part `

return the real and imaginary parts
of *z*)

, respectively. *z*```
(magnitude
```

returns the absolute value and *z*)```
(angle
```

returns the phase angle. libctl also provides a
*z*)`(conj `

function, below, to return the complex
conjugate.
*z*)

`(vector3`

)*x [y z]*- Create a new 3-vector with the given components. If the

or*y*

value is omitted, it is set to zero.*z* `(vector3-x`

*v*)`(vector3-y`

*v*)`(vector3-z`

*v*)- Return the corresponding component of the vector

.*v* `(vector3+`

*v1 v2*)`(vector3-`

*v1 v2*)`(vector3-cross`

*v1 v2*)- Return the sum, difference, or cross product of the two vectors.
`(vector3*`

*a b*)- If

and*a*

are both vectors, returns their dot product. If one of them is a number and the other is a vector, then scales the vector by the number.*b* `(vector3-dot`

*v1 v2*)- Returns the dot product of

and*v1*

.*v2* `(vector3-cross`

*v1 v2*)- Returns the cross product of

and*v1*

.*v2* `(vector3-cdot`

*v1 v2*)- Returns the conjugated dot product:
*v1** dot*v2*. `(vector3-norm`

*v*)- Returns the length
`(sqrt (vector3-cdot v v))`

of the given vector. `(unit-vector3`

)*x [y z]*`(unit-vector3`

*v*)- Given a vector or, alternatively, one or more components, returns a unit vector in that direction.
`(vector3-close?`

*v1 v2 tolerance*)- Returns whether or not the corresponding components of the two
vectors are within

of each other.*tolerance* `(vector3=`

*v1 v2*)- Returns whether or not the two vectors are numerically equal.
Beware of using this function after operations that may have some
error due to the finite precision of floating-point numbers; use
`vector3-close?`

instead. `(rotate-vector3`

*axis theta v*)- Returns the vector

rotated by an angle*v*

(in radians) in the right-hand direction around the*theta*

vector (whose length is ignored). You may find the functions*axis*`(deg->rad`

and*theta-deg*)`(rad->deg`

useful to convert angles between degrees and radians.*theta-rad*)

`(matrix3x3`

*c1 c2 c3*)- Creates a 3x3 matrix with the given 3-vectors as its columns.
`(matrix3x3-transpose`

*m*)`(matrix3x3-adjoint`

*m*)`(matrix3x3-determinant`

*m*)`(matrix3x3-inverse`

*m*)- Return the transpose, adjoint (conjugate transpose), determinant, or inverse of the given matrix.
`(matrix3x3+`

*m1 m2*)`(matrix3x3-`

*m1 m2*)`(matrix3x3*`

*m1 m2*)- Return the sum, difference, or product of the given matrices.
`(matrix3x3*`

*v m*)`(matrix3x3*`

*m v*)- Returns the (3-vector) product of the matrix

by the vector*m*

, with the vector multiplied on the left or the right respectively.*v* `(matrix3x3*`

*s m*)`(matrix3x3*`

*m s*)- Scales the matrix

by the number*m*

.*s* `(rotation-matrix3x3`

*axis theta*)- Like
`rotate-vector3`

, except returns the (unitary) rotation matrix that performs the given rotation. i.e.,`(matrix3x3* (rotation-matrix3x3 axis theta) v)`

produces the same result as`(rotate-vector3 axis theta v)`

.

`(make`

*class [ properties ... ]*)- Make an object of the given

. Each property is of the form*class*`(`

. A property need not be specified if it has a default value, and properties may be given in any order.*property-name property-value*) `(object-property-value`

*object property-name*)- Return the value of the property whose name (symbol) is

in*property-name*

. For example,*object*`(object-property-value a-circle-object 'radius)`

. (Returns`false`

if

is not a property of*property-name*

.)*object*

`(conj`

*x*)- Return the complex conjugate of a number

(for some reason, Scheme doesn't provide such a function).*x* `(interpolate`

*n list*)- Given a

of numbers or 3-vectors, linearly interpolates between them to add*list*

new evenly-spaced values between each pair of consecutive values in the original list.*n* `(print`

*expressions...*)- Calls the Scheme
`display`

function on each of its arguments from left to right (printing them to standard output). Note that, like`display`

, it does*not*append a newline to the end of the outputs; you have to do this yourself by including the`"\n"`

string at the end of the expression list. In addition, there is a global variable`print-ok?`

, defaulting to`true`

, that controls whether`print`

does anything; by setting`print-ok?`

to false, you can disable all output. `(begin-time`

*message-string statements...*)- Like the Scheme
`(begin ...)`

construct, this executes the given sequence of statements one by one. In addition, however, it measures the elapsed time for the statements and outputs it as

, followed by the time, followed by a newline. The return value of*message-string*`begin-time`

is the elapsed time in seconds. `(minimize`

*function tolerance*)- Given a

of one (number) argument, finds its minimum within the specified fractional*function*

. If the return value of*tolerance*`minimize`

is assigned to a variable`result`

, then`(min-arg result)`

and`(min-val result)`

give the argument and value of the function at its minimum. If you can, you should use one of the variant forms of`minimize`

, described below. `(minimize`

*function tolerance guess*)- The same as above, but you supply an initial

for where the minimum is located.*guess* `(minimize`

*function tolerance arg-min arg-max*)- The same as above, but you supply the minimum and maximum function
argument values within which to search for the minimum. This is the
most preferred form of
`minimize`

, and is faster and more robust than the other two variants. `(minimize-multiple`

*function tolerance arg1 .. argN*)- Minimize a

of N numeric arguments within the specified fractional*function*

.*tolerance*

..*arg1*

are an initial guess for the function arguments. Returns both the arguments and value of the function at its minimum. A list of the arguments at the minimum are retrieved via*argN*`min-arg`

, and the value via`min-val`

. `maximize`

,`maximize-multiple`

- These are the same as the

functions except that they maximizes the function instead of minimizing it. The functions*minimize*`max-arg`

and`max-val`

are provided instead of`min-arg`

and`min-val`

. `(find-root`

*function tolerance arg-min arg-max*)- Find a root of the given

to within the specified fractional*function*

.*tolerance*`arg-min`

and`arg-max`

**bracket**the desired root; the function must have opposite signs at these two points! `(find-root-deriv`

*function tolerance arg-min arg-max [arg-guess]*)- As
`find-root`

, but

should return a*function*`cons`

pair of (*function-value . function-derivative*); the derivative information is exploited to achieve faster convergence via Newton's method, compared to`find-root`

. The optional argument

should be an initial guess for the root location.*arg-guess* `(derivative`

*function x [dx tolerance]*)`(deriv`

*function x [dx tolerance]*)`(deriv`

*function x [dx tolerance]*)`(derivative2`

*function x [dx tolerance]*)`(deriv2`

*function x [dx tolerance]*)- Compute the numerical derivative of the given

at*function*

to within*x**at best*the specified fractional

(defaulting to the maximum achievable tolerance), using Ridder's method of polynomial extrapolation.*tolerance*

should be a*dx**maximum*displacement in

for derivative evaluation; the*x*

should change by a significant amount (much larger than the numerical precision) over*function*

.*dx*

defaults to 1% of*dx*

or*x*`0.01`

, whichever is larger.If the return value of

`derivative`

is assigned to a variable`result`

, then`(derivative-df result)`

and`(derivative-df-err result)`

give the derivative of the function and an estimate of the numerical error in the derivative, respectively.The

`derivative2`

function computes both the first and second derivatives, using minimal extra function evaluations; the second derivative and its error are then obtained by`(derivative-d2f result)`

and`(derivative-d2f-err result)`

.`deriv`

and`deriv2`

are identical to`derivative`

and`derivative2`

, except that they directly return the value of the first and second derivatives, respectively (no need to call`derivative-df`

or`derivative-d2f`

). (They don't provide the error estimate, however, or the ability to compute first and second derivatives simulataneously.) `(integrate`

*f a b tolerance*)- Return the definite integral of the function

from*f*

to*a*

, to within the specified fractional*b*

, using an adaptive trapezoidal rule.*tolerance*This function can compute multi-dimensional integrals, in which case

is a function of*f**N*variables and

and*a*

are either lists or vectors of length*b**N*, giving the (constant) integration bounds in each dimension. (Non-constant integration bounds, i.e. non-rectilinear integration domains, can be handled by an appropriate mapping of the function

.)*f* `(fold-left`

*op init list*)- Combine the elements of

using the binary "operator" function*list*

, with initial value*(op x y)*

, associating from the left of the list. That is, if*init*

consist of the elements*list*`(`

, then*a b c d*)`(fold-left`

computes*op init list*)`(op (op (op (op init a) b) c) d)`

. For example, if

contains numbers, then*list*`(fold-left + 0`

returns the sum of the elements of*list*)

.*list* `(fold-right`

*op init list*)- As
`fold-left`

, but associate from the right. For example,`(op a (op b (op c (op d init))))`

. `(memoize`

*func*)- Return a function wrapping around the function

that "memoizes" its arguments and return values. That is, it returns the same thing as*func*

, but if passed the same arguments as a previous call it returns a cached return value from the previous call instead of recomputing it.*func*

Go to the next, previous, or main section.