Download or view derivatives.frink in plain text format
// 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]
// Bail-out condition for zeroth derivative
D[_n, _x, 0] <-> _n
// 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[arcsin[_x], _x] <-> 1/sqrt[1 - _x^2]
D[arccos[_x], _x] <-> -1/sqrt[1 - _x^2]
D[arctan[_x], _x] <-> 1/(1 + _x^2)
D[arccsc[_x], _x] <-> -1/(magnitude[_x] / sqrt[_x^2 - 1])
D[arcsec[_x], _x] <-> 1/(magnitude[_x] / sqrt[_x^2 - 1])
D[arccot[_x], _x] <-> -1/(1 + _x^2)
D[sinh[_x], _x] <-> cosh[_x]
D[cosh[_x], _x] <-> sinh[_x]
D[tanh[_x], _x] <-> 1/cosh[_x]^2
D[arcsinh[_x], _x] <-> 1/sqrt[_x^2 + 1]
D[arccosh[_x], _x] <-> -1/sqrt[_x^2 - 1]
D[arctanh[_x], _x] <-> 1/(1 - _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]
// This matches a function that depends on x. The excluding structureEquals
// test keeps it from looping forever when _u equals _x
D[_f[_u], _x] :: expressionContains[_u, _x] && ! structureEquals[_u, _x] <-> D[_u, _x] D[_f[_u], _u]
// This matches a function that does not depend on x
D[_f[_u], _x] :: freeOf[_u, _x] <-> 0
}
Download or view derivatives.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20203 days, 11 hours, 43 minutes ago.