CodePlexProject Hosting for Open Source Software

If I is the identity matrix and J is the matrix with 1's above the main diagonal and 0's everywhere else, then a dual number has the form

a = aFor sufficiently smooth functions_{0}I + a_{1}J + a_{2}J^{2}+ ...

f(xI + J) = f(x) I + f'(x) J + f"(x)/2! JThis allows us compute derivatives without taking limits of difference quotients.^{2}+ ...

(xI + J)We can read off the derivatives of f(x) = x^{3}= x^{3}I + 3 x^{2}J + 3 x J^{2}+ J^{3}.

This can be written in C++ as

double x = 0.5; dual::number<double, 3> X(x, 1), Y; Y = X*X*X; ensure (Y._(0) == x*x*x); ensure (Y._(1) == 3*x*x); ensure (Y._(2) == 6*x);

Yes, those really are =='s. Dual numbers automatically calculate derivatives to bit-precision, not just machine precision.

Last edited Nov 5, 2013 at 8:03 PM by keithalewis, version 7