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!