Partial Derivatives in LISP
Results 1 to 2 of 2

Thread: Partial Derivatives in LISP

  1. #1
    Senior Member
    Join Date
    Oct 2005

    Partial Derivatives in LISP

    So my old friend and archnemisis is building a calculator, but with LISP (more specifically, the SCHEME dialect). He has come to a problem with partial derivatives, and I must admit it is a devil of a problem.

    He programmed a derivative to return several things conditionally
    (define (deriv (lambda (x) (f)) dx)
    	(cond (= f (^ x n)) (* n (^ f (- n 1)))
    	      (= f (ln (abs x))) (^ x -1)
    	      (= f (sin x)) (cos x)
    	      (= f (cos x)) (* (sin x) (-1))
    	      (= f (tan x)) ((^ sec 2) x)
    	      (= f (csc x)) (* (* (-1) (csc x)) (cot x))
    	      (= f (sec x)) (* (sec x) (tan x))
    	      (= f (cot x)) (* ((^ csc 2) x) (-1))
    	      (= f (exp x)) (exp x)
    	      (= f (^ a x)) (* (ln a) (^ a x))))
    Thus one has to enter the function (lambda (x) (f)) and has returned several things (he plans to tackle integrals the same way).

    I can't figure out for the life of me how to help him make a partial derivative without creating errors!

  2. #2
    Elite Hacker
    Join Date
    Mar 2003
    I have done a little bit of scheme programming with DrScheme, but that definition seems to not even be close to syntactically correct for the environment I'm working in. Perhaps if it were close to working I could help get it working? Or maybe it's just the differences in the development environment which cause it to not be close to working for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

 Security News


       Security Trends


           Buying Guides