## TOC »

This is a Chicken Scheme egg which implements automatic differentiation by lifting mathematical operations. This egg uses a hack to declare all lifted operations as both a macro and a procedure. The macro provides specialization for the two-argument case. This package originates in Jeff Siskind's QobiScheme.

#### Derivatives

derivative-R fprocedure
derivative-F fprocedure

These take a function f from a real number to a real number and produce a function which returns the derivative of f. Both forward and reverse mode are supported.

As above but these take functions that accept a vector of reals and return a real number. This will produce a vector of partial derivatives. Both forward and reverse mode are supported.

#### Operations

``` + - * / = > < >= <= add1 sub1 signum exp log sin cos atan expt sqrt abs
max min positive? negative? odd? even? zero? real? exact? inexact?
inexact->exact exact->inexact finite?```

These operations are lifted.

``` tan acos asin quotient modulo remainder numerator denominator gcd lcm
floor ceiling truncate round```

These operations are not lifted.

lift-real->real f df/dx xprocedure
lift-real*real->real f df/dx1 df/dx2 x1 x2procedure

These are useful if you want to lift your own functions. They take the original function, functions that produce partial derivatives and values for each of the arguments of the original function.

### Examples

``` ((derivative-F (lambda (x) (* x x))) 2)
=> 4.0```
``` ((gradient-F (lambda (x) (+ (* (vector-ref x 0) (vector-ref x 0))
(/ (vector-ref x 1) (vector-ref x 1)))))
'#(2 3))
=> #(4.0 0.0)```

```  Copyright 1993-1995 University of Toronto. All rights reserved.
`  Contact Andrei Barbu, andrei@0xab.com.`
```  This program is free software: you can redistribute it and/or modify