chickadee » AD

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

This page is maintained in the package's github repository.

AD

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.

gradient-R fprocedure
gradient-F fprocedure

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)

License

  Copyright 1993-1995 University of Toronto. All rights reserved.
  Copyright 1996 Technion. All rights reserved.
  Copyright 1996 and 1997 University of Vermont. All rights reserved.
  Copyright 1997-2001 NEC Research Institute, Inc. All rights reserved.
  Copyright 2002-2012 Purdue University. All rights reserved.
  Contact Andrei Barbu, andrei@0xab.com.
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License
  along with this program.  If not, see http://www.gnu.org/licenses.

Contents »