# Partial Derivatives in LISP

• November 25th, 2005, 09:06 PM
Arkimedes
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
Code:

```(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!
• November 27th, 2005, 12:41 AM
skiddieleet
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.