Liking cljdoc? Tell your friends :D

incanter.symbolic

A library for performing symbolic math, a port from SICP (http://mitpress.mit.edu/sicp/).

A library for performing symbolic math, a port from SICP (http://mitpress.mit.edu/sicp/).
raw docstring

all-fn-listclj

source

chain-listclj

source

derivclj/smacro

(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

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
sourceraw docstring

deriv*clj

(deriv* exp v)
(deriv* exp vr degree)

Main sub-function for 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) (deriv* '(* x y) 'x) (deriv* '(* (* x y) '(+ x 3)) x) (deriv* '(* (* x y) (+ x 3)) 'y)

(deriv* '(* x y (+ x 3)) 'x) (deriv* '(* x y (+ x 3)) 'y)

(deriv* '(* x y (+ x 3)) 'x 2) (deriv* '(* x y (+ x 3)) 'x 3)

Main sub-function for 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)
  (deriv* '(* x y) 'x)
  (deriv* '(* (* x y) '(+ x 3)) x)
  (deriv* '(* (* x y) (+ x 3)) 'y)

  (deriv* '(* x y (+ x 3)) 'x)
  (deriv* '(* x y (+ x 3)) 'y)

  (deriv* '(* x y (+ x 3)) 'x 2)
  (deriv* '(* x y (+ x 3)) 'x 3)
sourceraw docstring

deriv-fnclj/smacro

(deriv-fn [& args] expr v)
(deriv-fn [& args] expr v degree)

Examples: (use '(incanter core symbolic))

(deriv-fn [x y] (+ (* x y) x) x)

((deriv-fn [x y] (+ (* x y) x) x) 5 9)

(use 'incanter.charts) (doto (function-plot sin -5 5) (add-function (deriv-fn [x] (sin x) x) -5 5) (add-function (deriv-fn [x] (sin x) x 2) -5 5) view)

(let [f (fn [x] (pow x 2)) df (deriv-fn [x] (pow x 2) x)] (doto (function-plot f -5 5) (add-function df -5 5) view))

(let [f (fn [x] (pow x 3)) df (deriv-fn [x] (pow x 3) x)] (doto (function-plot f -5 5) (add-function df -5 5) view))

;; NOT WORKING YET

(let [f (fn [x] (/ 1 x )) df (deriv-fn [x] (/ 1 x) x)] (doto (function-plot f 0.5 5) (add-function df 0.5 5) view))

Examples:
  (use '(incanter core symbolic))

  (deriv-fn [x y] (+ (* x y) x) x)

  ((deriv-fn [x y] (+ (* x y) x) x) 5 9)

  (use 'incanter.charts)
  (doto (function-plot sin -5 5)
     (add-function (deriv-fn [x] (sin x) x) -5 5)
     (add-function (deriv-fn [x] (sin x) x 2) -5 5)
     view)

  (let [f (fn [x] (pow x 2))
        df (deriv-fn [x] (pow x 2) x)]
    (doto (function-plot f -5 5)
      (add-function df -5 5)
      view))


  (let [f (fn [x] (pow x 3))
        df (deriv-fn [x] (pow x 3) x)]
    (doto (function-plot f -5 5)
      (add-function df -5 5)
      view))


  ;; NOT WORKING YET

  (let [f (fn [x] (/ 1 x ))
        df (deriv-fn [x] (/ 1 x) x)]
    (doto (function-plot f 0.5 5)
      (add-function df 0.5 5)
      view))
sourceraw docstring

deriv-fn*clj

(deriv-fn* [& args] expr v)
(deriv-fn* [& args] expr v degree)

Examples: (use '(incanter core symbolic))

(deriv-fn* '[x y] '(+ (* x y) x) 'x)

((deriv-fn* '[x y] '(+ (* x y) x) 'x) 5 9)

Examples:
  (use '(incanter core symbolic))

  (deriv-fn* '[x y] '(+ (* x y) x) 'x)

  ((deriv-fn* '[x y] '(+ (* x y) x) 'x) 5 9)
sourceraw docstring

fn-listclj

source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close