// 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. tan[_x] <-> sin[x]/cos[x] // Derivatives 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 is unit _x, _x] <-> _c D[_x^_y is unit, _x] <-> _y _x^(_y-1) D[_c is unit _x^_y is unit, _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] }