// This file contains transformation rules suitable for finding
// derivatives of expressions.
transformations derivatives
{
// This is a simple program that lets you define transformation rules
// and mathematical simplification rules and test them easily.
// Derivative of both sides of an equation.
D[_a === _b, _x] <-> D[_a, _x] === D[_b, _x]
// Derivative as inverse of integration.
D[Integrate[_f, _x], _x] <-> _f
// Multiple derivatives
// Bail-out condition for first derivative
D[_n, _x, 1] <-> D[_n, _x]
// Otherwise take one derivative and decrement.
D[_n, _x, _times is isInteger] <-> D[D[_n,_x], _x, _times-1]
// Degenerate cases
D[_c, _x] :: freeOf[_c, _x] <-> 0
D[_x, _x] <-> 1
// The following are shortcuts and aren't strictly needed, but they're
// closer to what a human would do and make the transformation path simpler.
// The constraints are necessary to prevent naive evaluation of, say, x^x.
D[(_c:1) _x^(_y:1), _x] :: freeOf[_c, _x] && freeOf[_y, _x] <-> (_c _y) _x^(_y-1)
//D[_a^_x, _x] <-> _a^_x ln[_a]
D[sin[_x], _x] <-> cos[_x]
D[cos[_x], _x] <-> -sin[_x]
D[tan[_x], _x] <-> 1/cos[_x]^2
D[ln[_x], _x] <-> 1/_x
D[e^_x, _x] <-> e^_x
// Chained derivative rules
D[_a + _b, _x] <-> D[_a,_x] + D[_b,_x]
// These rules can loop if _u or _v equals _x.
// Prevent that? Need excluding match?
D[_u _v, _x] <-> _u D[_v, _x] + _v D[_u, _x]
D[_u^_v, _x] <-> _v _u^(_v-1) D[_u, _x] + _u^_v ln[_u] D[_v,_x]
D[_f[_u], _x] <-> D[_u, _x] D[_f[_u], _u]
}