From: Tamas Papp
Subject: lightweight symbolic differentiation
Date: 
Message-ID: <87ejhr4bz3.fsf@pu100877.student.princeton.edu>
I am working with Newton-Raphson-type rootfinding/optimization
algorithms, and know the functions in advance.  The functions are
getting more complicated, and differentiation by hand (especially for
the 2nd derivative) is getting error-prone.

I thought that since this is Lisp, I should be able to automate this
at compile time.

(defmacro first-derivative (variable other-arguments formula)
  `(lambda (,variable ,@other-arguments)
     (differentiate ,formula ,variable)))

(first-derivative (x '(y z) 
                   (+ (* x (expt y z)) (expt x 2))))

I am looking for an existing version of first-derivative.  I know that
several symbolic packages are _written_ in Lisp for a general
audience, but I need something _in_ CL.  Handling operations (+ - * /
expt log) would suffice, simplification and handling constants would
be excellent.  I could roll my own, but I am sure it has been done, I
just don't know about it.  Then I could hack together something that
defines x-f(x)/f'(x) from the formula for f.

Thanks,

Tamas

From: Paul Khuong
Subject: Re: lightweight symbolic differentiation
Date: 
Message-ID: <1188078733.960195.42990@r34g2000hsd.googlegroups.com>
On Aug 25, 4:04 pm, Tamas Papp <······@gmail.com> wrote:
> I am working with Newton-Raphson-type rootfinding/optimization
> algorithms, and know the functions in advance.  The functions are
> getting more complicated, and differentiation by hand (especially for
> the 2nd derivative) is getting error-prone.

Why don't you use automatic differentiation (e.g. forward-mode)? The
code would be simple, and efficient. You just have to shadow the
operators you want to implement for your automatic differentiation.

Paul Khuong
From: ······@gmail.com
Subject: Re: lightweight symbolic differentiation
Date: 
Message-ID: <1188103191.644673.224430@r23g2000prd.googlegroups.com>
On Aug 26, 3:04 am, Tamas Papp <······@gmail.com> wrote:

> I am working with Newton-Raphson-type rootfinding/optimization
> algorithms, and know the functions in advance.  The functions are
> getting more complicated, and differentiation by hand (especially for
> the 2nd derivative) is getting error-prone.
>
> I know that several symbolic packages are _written_ in Lisp for
> a general audience, but I need something _in_ CL. ...


No. Don't do this. Evaluate f' numerically. Use Richardson
extrapolation. It is a good, straightforward technique. It
will serve you well in the future, when you need partial
derivatives and Jacobians and so on.

In most cases of interest f can't be expressed in a form
amenable to symbolic differentiation. So don't bother. But
if for some reason you really need a symbolic representation
of f, you can find an approximation for f in terms of orthogonal
polynomials and use that.
From: ddd
Subject: Re: lightweight symbolic differentiation
Date: 
Message-ID: <slrnfd5g2n.2ub.marc@localhost.localdomain>
> On Aug 26, 3:04 am, Tamas Papp <······@gmail.com> wrote:
>
>> I am working with Newton-Raphson-type rootfinding/optimization
>> algorithms, and know the functions in advance.  The functions are
>> getting more complicated, and differentiation by hand (especially for
>> the 2nd derivative) is getting error-prone.
>>
>> I know that several symbolic packages are _written_ in Lisp for
>> a general audience, but I need something _in_ CL. ...
>

In Norvigs book Principles of Artificial Intelligence Programming is
such a program.  Also have a look at R. Fatemans www pages, he has
some papers and code about symbolic differentiation.
Also Fateman has some autodiff code.  That may be a better solution
for you.
From: Madhu
Subject: Re: lightweight symbolic differentiation
Date: 
Message-ID: <m3hcmnl2r1.fsf@robolove.meer.net>
* Tamas Papp <··············@pu100877.student.princeton.edu> :
| I am looking for an existing version of first-derivative.  I know that
| several symbolic packages are _written_ in Lisp for a general
| audience, but I need something _in_ CL.  Handling operations (+ - * /
| expt log) would suffice, simplification and handling constants would
| be excellent.  I could roll my own, but I am sure it has been done, I
| just don't know about it.  Then I could hack together something that
| defines x-f(x)/f'(x) from the formula for f.

Its a standard exercise in teaching lisp programming (first homework
assignment), so a lot of these exist.  If you dont want half ass
solutions, you're probably better off using a symbolic package or
something like simlab

Also see 
Message-ID: <·····················@newssvr27.news.prodigy.com>


| Thanks,
|
| Tamas
From: Tamas Papp
Subject: Re: lightweight symbolic differentiation
Date: 
Message-ID: <87abse51wg.fsf@pu100877.student.princeton.edu>
Madhu <·······@meer.net> writes:

> * Tamas Papp <··············@pu100877.student.princeton.edu> :
> | I am looking for an existing version of first-derivative.  I know that
> | several symbolic packages are _written_ in Lisp for a general
> | audience, but I need something _in_ CL.  Handling operations (+ - * /
> | expt log) would suffice, simplification and handling constants would
> | be excellent.  I could roll my own, but I am sure it has been done, I
> | just don't know about it.  Then I could hack together something that
> | defines x-f(x)/f'(x) from the formula for f.
>
> Its a standard exercise in teaching lisp programming (first homework
> assignment), so a lot of these exist.  If you dont want half ass
> solutions, you're probably better off using a symbolic package or
> something like simlab
>
> Also see 
> Message-ID: <·····················@newssvr27.news.prodigy.com>

Hi Madhu,

Sorry for my ignorance, but how do I find this message using the
message-id above?  I am not subscribed to news.prodigy.com but
news.individual.net, using gnus.

Tamas
From: Timofei Shatrov
Subject: Re: lightweight symbolic differentiation
Date: 
Message-ID: <46d11c13.1040025@news.readfreenews.net>
On Sun, 26 Aug 2007 06:57:03 +0200, Tamas Papp <······@gmail.com> tried to
confuse everyone with this message:

>Madhu <·······@meer.net> writes:
>
>> Also see 
>> Message-ID: <·····················@newssvr27.news.prodigy.com>
>
>Hi Madhu,
>
>Sorry for my ignorance, but how do I find this message using the
>message-id above?  I am not subscribed to news.prodigy.com but
>news.individual.net, using gnus.

It is unlikely that any newsserver would carry the message posted in 2004
anyway. You can use http://groups.google.com/advanced_search to find Usenet
posts by Message-ID.


-- 
|Don't believe this - you're not worthless              ,gr---------.ru
|It's us against millions and we can't take them all... |  ue     il   |
|But we can take them on!                               |     @ma      |
|                       (A Wilhelm Scream - The Rip)    |______________|