Giter Site home page Giter Site logo

epsilon's Introduction

C/C++ CI

epsilon

This library can be used to compute derivatives of any order to machine precision.

If ε is not 0 and ε2 = 0 then for any sufficiently differentiable function f, f(x + ε) = f(x) + f'(x) ε + f''(x) ε2/2 + · · · = f(x) + f'(x) ε. The coefficient of ε is the derivative of f.

For example, if f(x) = x2 then (x + ε)2 = x2 + 2 x ε + ε2 = x2 + 2 x ε, so the derivative of x2 is 2 x. No need to take limits of difference quotients.

Of course ε cannot be a real number, but the 2 x 2 matrix ε = [0 1; 0 0] satisfies these conditions. This is a special case of a Toeplitz matrix. The class epsilon implements the arithmetic datatype required to compute derivatives to any order.

In order to use this library you must define functions that take generic arguments. For example:

template<class X>
X f(X x)
{
    return x*x + 2*x + 3;
}

Now you can use epsilon to compute derivatives.

double x = 1.23;
auto y = f(epsilon<3>(x, 1));
assert (y[0] == f(x));
assert (y[1] == 2*x + 2); // f'(x)
assert (y[2] == 2);       // f''(x)

epsilon's People

Contributors

keithalewis avatar s-telescope avatar

Stargazers

 avatar

Watchers

 avatar  avatar

epsilon's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.