difft – a symbolic differentiator, current version 0.1.12

Sources: current


The difft utility computes the derivative of a function, optionally printing each differentiation and reduction rule as it does so. It formats its output as LaTeX, a Gnuplot equation, a C file (ANSI C89), or MathML.

difft is a quick, batch-mode derivative calculator without the overhead or complexity of tools like Sage. It is an ISC-licensed open source UNIX utility written in ISO C99, with no compile- or run-time dependencies.


This gallery showcases the results of pipelining difft, LaTeX and dvipng, and Gnuplot.

Multivariate Function

A sample multivariate trigonometric function is

echo "(sin(x)*cos(y))" | difft -n -dx,y | latex
(sin(x) * cos(y).

Taking the partial derivative with respect to x and y (for all steps of differentiation: PNG, XHTML) produces

echo "(sin(x)*cos(y))" | difft -xx,y | latex
(sin(x) * cos(y))

echo "(sin(x)*cos(y))" | difft -xx,y -Tgnuplot | gnuplot
(sin(x) * cos(y))

Univariate Function

The cdf of the Gumbel distribution is

echo "(e^-(e^-x))" | difft -n -fF | latex

Its pdf (for all steps of differentiation: PNG, XHTML) is thus

echo "(e^-(e^-x))" | difft -xx,y | latex

echo "(e^-(e^-x))" | difft -xx,y -Tgnuplot | gnuplot


difft(1) symbolic differentiator


This utility was developed and is maintained at the Stockholm School of Economics, Department of Economics. Contact Kristaps Dzonsons with bug-reports, questions, comments, patches, and so on.


28-01-2012: version 0.1.12

Lifted signed-integer constraints on number of allocations. Added -Tc output format. Cleaned up documentation.

Copyright © 2011, 2012 Kristaps Dzonsons, $Date: 2012/01/28 20:45:58 $