nuim-bcl / fad Goto Github PK
View Code? Open in Web Editor NEWThis project forked from bjornbm/fad
Forward Automatic Differentiation in Haskell
License: BSD 3-Clause "New" or "Revised" License
This project forked from bjornbm/fad
Forward Automatic Differentiation in Haskell
License: BSD 3-Clause "New" or "Revised" License
Copyright : 2008-2009, Barak A. Pearlmutter and Jeffrey Mark Siskind License : BSD3 Maintainer : [email protected] Stability : experimental Portability: GHC only? Forward Automatic Differentiation via overloading to perform nonstandard interpretation that replaces original numeric type with corresponding generalized dual number type. Each invocation of the differentiation function introduces a distinct perturbation, which requires a distinct dual number type. In order to prevent these from being confused, tagging, called branding in the Haskell community, is used. This seems to prevent perturbation confusion, although it would be nice to have an actual proof of this. The technique does require adding invocations of lift at appropriate places when nesting is present. For more information on perturbation confusion and the solution employed in this library see: <http://www.bcl.hamilton.ie/~barak/papers/ifl2005.pdf> <http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/> Installation ============ To install: cabal install Or: runhaskell Setup.lhs configure runhaskell Setup.lhs build runhaskell Setup.lhs install Examples ======== Define an example function 'f': > import Numeric.FAD > f x = 6 - 5 * x + x ^ 2 -- Our example function Basic usage of the differentiation operator: > y = f 2 -- f(2) = 0 > y' = diff f 2 -- First derivative f'(2) = -1 > y'' = diff (diff f) 2 -- Second derivative f''(2) = 2 List of derivatives: > ys = take 3 $ diffs f 2 -- [0, -1, 2] Example optimization method; find a zero using Newton's method: > y_newton1 = zeroNewton f 0 -- converges to first zero at 2.0. > y_newton2 = zeroNewton f 10 -- converges to second zero at 3.0. Credits ======= Authors: Copyright 2008, Barak A. Pearlmutter <[email protected]> & Jeffrey Mark Siskind <[email protected]> Work started as stripped-down version of higher-order tower code published by Jerzy Karczmarczuk <[email protected]> which used a non-standard standard prelude. Initial perturbation-confusing code is a modified version of <http://cdsmith.wordpress.com/2007/11/29/some-playing-with-derivatives/> Tag trick, called "branding" in the Haskell community, from Bjorn Buckwalter <[email protected]> <http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/>
The expression
diff (\x→[x..]!!0) 0
yields zero instead of the more correct 1.
This is due to the definition of [x..] in the Standard Prelude.
It is impossible to make a Tower Complex be a member of the Complex class. This is due to the way Complex is defined in the Standard Prelude.
Nesting functions that do AD exposes “forall” types for the branding; these cannot be inferred by the type system, and are tedious and error-prone.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.