Skip to content

Instantly share code, notes, and snippets.

@jdh30
Last active February 25, 2017 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdh30/3230e3928e927a8756bc271efd6ea75c to your computer and use it in GitHub Desktop.
Save jdh30/3230e3928e927a8756bc271efd6ea75c to your computer and use it in GitHub Desktop.
Rewrite rules for simple differentiation in Mathematica syntax
D[_, _] := 0
D[x_, x_] := 1
D[f_ + g_, x_] := D[f, x] + D[g, x]
D[f_ - g_, x_] := D[f, x] - D[g, x]
D[f_ g_, x_] := f D[g, x] + g D[f, x]
D[f_ / g_, x_] := f D[1/g, x] + 1/g D[f, x]
D[f_^g_, x_] := f^(g - 1) (g D[f, x] + f Log[f] D[g, x])
D[Log[f_], x_] := D[f, x] / f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment