Very nice to have!<br><br>FYI- there is at least one more quantification-based automatic differentiation implementation in Hackage:<br><br><a href="http://comonad.com/haskell/monoids/dist/doc/html/monoids/Data-Ring-Module-AutomaticDifferentiation.html" target="_blank">http://comonad.com/haskell/monoids/dist/doc/html/monoids/Data-Ring-Module-AutomaticDifferentiation.html</a><br>
<br>My implementation is/was focused upon use with monoids and other more-limited-than-Num classes and only included the equivalent of your &#39;lift&#39; and &#39;diffUU&#39; operations, however.<br><br>-Edward Kmett<br>
<br>
<div class="gmail_quote">On Thu, Apr 2, 2009 at 10:28 PM, Bjorn Buckwalter <span dir="ltr">&lt;<a href="mailto:bjorn.buckwalter@gmail.com" target="_blank">bjorn.buckwalter@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">I&#39;m pleased to announce the initial release of the Haskell fad<br>library, developed by Barak A. Pearlmutter and Jeffrey Mark Siskind.<br>
Fad provides Forward Automatic Differentiation (AD) for functions<br>polymorphic over instances of &#39;Num&#39;. There have been many Haskell<br>implementations of forward AD, with varying levels of completeness,<br>published in papers and blog posts[1], but alarmingly few of these<br>
have made it into hackage -- to date Conal Elliot&#39;s vector-spaces[2]<br>package is the only one I am aware of.<br><br>Fad is an attempt to make as comprehensive and usable a forward AD<br>package as is possible in Haskell. However, correctness is given<br>
priority over ease of use, and this is in my opinion the defining<br>quality of fad. Specifically, Fad leverages Haskell&#39;s expressive<br>type system to tackle the problem of _perturbation confusion_,<br>brought to light in Pearlmutter and Siskind&#39;s 2005 paper &quot;Perturbation<br>
Confusion and Referential Transparency&quot;[3]. Fad prevents perturbation<br>confusion by employing type-level &quot;branding&quot; as proposed by myself<br>in a 2007 post to haskell-cafe[4]. To the best of our knowledge all<br>
other forward AD implementations in Haskell are susceptible to<br>perturbation confusion.<br><br>As this library has been in the works for quite some time it is<br>worth noting that it hasn&#39;t benefited from Conal&#39;s ground-breaking<br>
work[5] in the area. Once we wrap our heads around his beautiful<br>constructs perhaps we&#39;ll be able to borrow some tricks from him.<br><br>As mentioned already, fad was developed primarily by Barak A.<br>Pearlmutter and Jeffrey Mark Siskind. My own contribution has been<br>
providing Haskell infrastructure support and wrapping up loose ends<br>in order to get the library into a releasable state. Many thanks<br>to Barak and Jeffrey for permitting me to release fad under the BSD<br>license.<br>
<br>Fad resides on GitHub[6] and hackage[7] and is only a &quot;cabal install<br>fad&quot; away! What follows is Fad&#39;s README, refer to the haddocks for<br>detailed documentation.<br><br>Thanks,<br>Bjorn Buckwalter<br>
<br><br>[1] <a href="http://www.haskell.org/haskellwiki/Functional_differentiation" target="_blank">http://www.haskell.org/haskellwiki/Functional_differentiation</a><br>[2] <a href="http://www.haskell.org/haskellwiki/Vector-space" target="_blank">http://www.haskell.org/haskellwiki/Vector-space</a><br>
[3]:  <a href="http://www.bcl.hamilton.ie/~qobi/nesting/papers/ifl2005.pdf" target="_blank">http://www.bcl.hamilton.ie/~qobi/nesting/papers/ifl2005.pdf</a><br>[4]: <a href="http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/" target="_blank">http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/</a><br>
[5]: <a href="http://conal.net/papers/beautiful-differentiation/" target="_blank">http://conal.net/papers/beautiful-differentiation/</a><br>[6] <a href="http://github.com/bjornbm/fad/" target="_blank">http://github.com/bjornbm/fad/</a><br>
[7] <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fad" target="_blank">http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fad</a><br><br><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
<br>  Copyright  : 2008-2009, Barak A. Pearlmutter and Jeffrey Mark Siskind<br>  License    : BSD3<br><br>  Maintainer : <a href="mailto:bjorn.buckwalter@gmail.com" target="_blank">bjorn.buckwalter@gmail.com</a><br>  Stability  : experimental<br>
  Portability: GHC only?<br><br>Forward Automatic Differentiation via overloading to perform<br>nonstandard interpretation that replaces original numeric type with<br>corresponding generalized dual number type.<br><br>Each invocation of the differentiation function introduces a<br>
distinct perturbation, which requires a distinct dual number type.<br>In order to prevent these from being confused, tagging, called<br>branding in the Haskell community, is used.  This seems to prevent<br>perturbation confusion, although it would be nice to have an actual<br>
proof of this.  The technique does require adding invocations of<br>lift at appropriate places when nesting is present.<br><br>For more information on perturbation confusion and the solution<br>employed in this library see:<br>
&lt;<a href="http://www.bcl.hamilton.ie/~barak/papers/ifl2005.pdf" target="_blank">http://www.bcl.hamilton.ie/~barak/papers/ifl2005.pdf</a>&gt;<br>&lt;<a href="http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/" target="_blank">http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/</a>&gt;<br>
<br><br>Installation<br>============<br>To install:<br>   cabal install<br><br>Or:<br>   runhaskell Setup.lhs configure<br>   runhaskell Setup.lhs build<br>   runhaskell Setup.lhs install<br><br><br>Examples<br>========<br>
Define an example function &#39;f&#39;:<br><br>&gt; import Numeric.FAD<br>&gt; f x = 6 - 5 * x + x ^ 2  -- Our example function<br><br>Basic usage of the differentiation operator:<br><br>&gt; y   = f 2              -- f(2) = 0<br>
&gt; y&#39;  = diff f 2         -- First derivative f&#39;(2) = -1<br>&gt; y&#39;&#39; = diff (diff f) 2  -- Second derivative f&#39;&#39;(2) = 2<br><br>List of derivatives:<br><br>&gt; ys = take 3 $ diffs f 2  -- [0, -1, 2]<br>
<br>Example optimization method; find a zero using Newton&#39;s method:<br><br>&gt; y_newton1 = zeroNewton f 0   -- converges to first zero at 2.0.<br>&gt; y_newton2 = zeroNewton f 10  -- converges to second zero at 3.0.<br>
<br><br>Credits<br>=======<br>Authors: Copyright 2008,<br>Barak A. Pearlmutter &lt;<a href="mailto:barak@cs.nuim.ie" target="_blank">barak@cs.nuim.ie</a>&gt; &amp;<br>Jeffrey Mark Siskind &lt;<a href="mailto:qobi@purdue.edu" target="_blank">qobi@purdue.edu</a>&gt;<br>
<br>Work started as stripped-down version of higher-order tower code<br>published by Jerzy Karczmarczuk &lt;<a href="mailto:jerzy.karczmarczuk@info.unicaen.fr" target="_blank">jerzy.karczmarczuk@info.unicaen.fr</a>&gt;<br>
which used a non-standard standard prelude.<br><br>Initial perturbation-confusing code is a modified version of<br>&lt;<a href="http://cdsmith.wordpress.com/2007/11/29/some-playing-with-derivatives/" target="_blank">http://cdsmith.wordpress.com/2007/11/29/some-playing-with-derivatives/</a>&gt;<br>
<br>Tag trick, called &quot;branding&quot; in the Haskell community, from<br>Bjorn Buckwalter &lt;<a href="mailto:bjorn.buckwalter@gmail.com" target="_blank">bjorn.buckwalter@gmail.com</a>&gt;<br>&lt;<a href="http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/" target="_blank">http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/</a>&gt;<br>
<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>