libMesh/libmesh — pull request #238 by dschwen (2014-04-28 19:56:30+00:00)
Title: Add automatic differentiation to fparser

This patch adds an automatic differentiation (AD) module to fparser. It implements a class that inherits from ```FunctionParserBase``` (instantiation for ```double``` is ```FunctionParserAD```) and adds the method

```
int AutoDiff(const std::string& var);
```

which takes the derivative of the parsed function with respect to variable var. It should be called after setting up the function object with ::Parse(). This method can be called multiple times (with the same or different vars) to generate higher order derivatives.

## TODO

* I haven't tested if this plays well with the copy-on-write stuff in fparser (i.e. using a copy constructor to create a copy of an existing function and taking the derivative of that)
* Only a subset of opcodes (operators/functions) are implemented so far (+-*/ sqrt pow ^2 log log2 sin cos exp)
* In this PR I also re-anable the FP optimizer on OSX (it works just fine, and is essential to distill down the crazy long auto diff expressions - see example program)