[Haskell-cafe] Strange type behavior in GHCi 6.4.2

Grady Lemoine grady.lemoine at gmail.com
Thu Dec 28 14:06:25 EST 2006


I understand the distinction, and I find both techniques interesting,
but your AD code is a lot more convenient.  All I have to do is make
sure that my functions are sufficiently polymorphic, and I can get
derivatives *automatically* with very little programmer effort.  It
seems like a good way to inject worry-free calculus wherever it's
needed -- for instance, if I want gradient information about a
function, I can use AD and avoid having to choose a length scale,
consider accuracy issues, etc. like I would if I used a finite
difference approximation.

(Of course, this assumes that the function I'm differentiating
consists only of building blocks that I have AD definitions of.  In
particular, I'm not really sure how I want to define the Ord
operations for Dual, so that a function with an if statement based on
a comparison (e.g. Gaussian elimination with pivoting) can be
differentiated.  On the one hand, I'm not sure I want to include the
infinitesimal part in the definition, because it is in some sense how
fast the number is changing, not how big it is; on the other hand, if
I don't include the infinitesimal part, my definition of Ord won't be
consistent with equality...)

One question I have, though, for anyone on the list who knows the
answer -- if I give a function a polymorphic type signature, can it
affect performance?  That is, if I write two functions with the same
definitions but different user-specified type signatures,

foo1 :: (Floating a) => a -> a
foo1 = ...

and

foo2 :: Double -> Double
foo2 = ...

when I apply foo1 to a Double, will the compiler (GHC, specifically)
generate code that is just as efficient as if I used foo2?

Regards,

--Grady Lemoine

On 12/19/06, Dan Piponi <dpiponi at gmail.com> wrote:
> On 12/2/06, Chris Kuklewicz <haskell at list.mightyreason.com> wrote:
> > Grady Lemoine wrote:
> > > I've been playing around with Dan Piponi's work on automatic
> > > differentiation...
> > I played with such things, as seen on the old wiki:
> > http://haskell.org/hawiki/ShortExamples_2fSymbolDifferentiation
>
> I missed this while I was away on vacation so apologies for responding
> to something two weeks old. I just want to point out that the method
> I've been promoting is very distinct from symbolic differentiation. I
> wouldn't make a big deal about this except that besides playing well
> with Haskell, AD can help with many real world numerical problems, but
> people often dismiss it because it they confuse it with symbolic
> differentiation which they have already determined doesn't solve their
> problems.
> --
> Dan
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list