• incanter

# deriv

## incanter.symbolic

• (deriv exp v)
• (deriv exp v degree)
Macro for symbolic differentiation. with 2 args, takes 1st degree deriv.
with 3, takes arbitrary degrees. contains all deriv rules for basic funcs.

Examples:

(use '(incanter core symbolic))

(deriv (+ x 3) x) ; => 1
(deriv (* x y) x) ; => y
(deriv (* (* x y) (+ x 3)) x) ; => (+ (* (+ x 3) y) (* x y))
(deriv (* (* x y) (+ x 3)) y) ; => (* (+ x 3) x)

(deriv (* x y (+ x 3)) x) ; => (+ (* y (+ x 3)) (* y x))
(deriv (* x y (+ x 3)) y) ; => (* (+ x 3) x)

(deriv (sin x) x) ; => (cos x)
(deriv (cos x) x) ; => (* -1 (sin x))

(deriv (sin (* x y)) y) ; => (* x (cos (* x y)))

(deriv (pow x 3) x) ; => (* 3 (pow x 2))
(deriv (** x 3) x) ; => (* 3 (pow x 2))

(deriv (pow x 3) x 2) ; => (* 3 (* 2 x))

(deriv (* x y (+ x 3)) x 2) ; => (+ y y)
(deriv (* x y (+ x 3)) x 3) ; => 0

(deriv (+ (* 3 x) (* 8 x)) x) ; => 11

;; NOT WORKING YET

(deriv (/ 1 x) x) ; => (* (deriv* (* (x)) x) (* -1 (pow (* (x)) -2)))
^-- need to fix

### Source incanter/symbolic.clj:140 top

```(defmacro deriv
"Macro for symbolic differentiation. with 2 args, takes 1st degree deriv.
with 3, takes arbitrary degrees. contains all deriv rules for basic funcs.

Examples:

(use '(incanter core symbolic))

(deriv (+ x 3) x) ; => 1
(deriv (* x y) x) ; => y
(deriv (* (* x y) (+ x 3)) x) ; => (+ (* (+ x 3) y) (* x y))
(deriv (* (* x y) (+ x 3)) y) ; => (* (+ x 3) x)

(deriv (* x y (+ x 3)) x) ; => (+ (* y (+ x 3)) (* y x))
(deriv (* x y (+ x 3)) y) ; => (* (+ x 3) x)

(deriv (sin x) x) ; => (cos x)
(deriv (cos x) x) ; => (* -1 (sin x))

(deriv (sin (* x y)) y) ; => (* x (cos (* x y)))

(deriv (pow x 3) x) ; => (* 3 (pow x 2))
(deriv (** x 3) x) ; => (* 3 (pow x 2))

(deriv (pow x 3) x 2) ; => (* 3 (* 2 x))

(deriv (* x y (+ x 3)) x 2) ; => (+ y y)
(deriv (* x y (+ x 3)) x 3) ; => 0

(deriv (+ (* 3 x) (* 8 x)) x) ; => 11

;; NOT WORKING YET

(deriv (/ 1 x) x) ; => (* (deriv* (* (x)) x) (* -1 (pow (* (x)) -2)))
^-- need to fix
"
([exp v]
`(deriv* '~exp '~v))
([exp v degree]
`(deriv* '~exp '~v ~degree)))```
Vars in incanter.symbolic/deriv: defmacro concat list seq
Used in 0 other vars