[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: In search of cool Scheme

From: Harvey J. Stein
Subject: Re: In search of cool Scheme
Date: 24 May 2001 09:12:38 -0400

"Hans O. Lowe" <address@hidden> writes:

 > Sometime on Wednesday, Harvey J. Stein wrote:
 > > Don't forget to add in a macro to do:
 > > 
 > >    (let ((x 3) (u 4)) (eval (differentiate '(* x (sin u)))))
 > > 
 > I didn't mean for it to be evaluation. The intent was to demonstrate
 > simple symbolic manipulation--returning symbols as results, much like
 > what Alejo shared.

My point is that you get to be able to evaluate the derivative at
specific points for free.  In other languages you'd have to write an
evaluator to be able to use the symbolic derivative.

In scheme you just do something like (depending on your macro facility):

(define-macro (diff-fcn form . args)
   `(lambda args ,(differentiate form)))

Then you can do:

(define fprime (diff-fcn '(* x (sin x))) x u)

(fprime 3 4)

Harvey Stein
Bloomberg LP

reply via email to

[Prev in Thread] Current Thread [Next in Thread]