An open API service indexing awesome lists of open source software.

https://github.com/lucaferranti/forwardmodead

forward mode automatic differentiation using dual numbers
https://github.com/lucaferranti/forwardmodead

automatic-differentiation chapel dual-numbers numerics

Last synced: 5 months ago
JSON representation

forward mode automatic differentiation using dual numbers

Awesome Lists containing this project

README

          

# ForwardModeAD
[![license: MIT][mit-img]](LICENSE)[![docs-dev][dev-img]][dev-url]![lifecycle](https://img.shields.io/badge/lifecycle-maturing-orange)

Lightweight library for forward-mode automatic differentiation using dual numbers and functions overloading.
It can compute the derivative, gradient and jacobian of any function, as long as it is written as a combination of [overloaded functions](https://forwardmodead.readthedocs.io/en/latest/api/overloaded.html).

As a showcase, in a few lines we can implement the Newton method for root finding.

```chapel
use ForwardModeAD;

proc f(x) {
return exp(-x) * sin(x) - log(x);
}

var tol = 1e-6, // tolerance to find the root
cnt = 0, // to count number of iterations
x0 = initdual(0.5), // initial guess
valder = f(x0); // initial function value and derivative

while abs(value(valder)) > tol {
x0 -= value(valder) / derivative(valder);
valder = f(x0);
cnt += 1;
writeln("Iteration ", cnt, " x = ", value(x0), " residual = ", value(valder));
}
```

### Installation

If you are writing you application with Mason, all you have to do is run

```
mason add ForwardModeAD
```

to add the library as dependency.

To use the library you will need to import it with

```chapel
use ForwardModeAD;
```

and you are ready to go.

### Documentation

- [latest][dev-url] : documentation of the latest version on main

### Contributing

If you encounter bugs or have feature requests, feel free to [open an issue](https://github.com/lucaferranti/ForwardModeAD/issues/new). Pull requests are also welcome. More details in the [contribution guidelines](https://forwardmodead.readthedocs.io/en/latest/contributing.html)

### License

MIT (c) Luca Ferranti

[mit-img]: https://img.shields.io/badge/license-MIT-yellow.svg
[dev-img]: https://img.shields.io/badge/docs-latest-blue.svg
[dev-url]: https://forwardmodead.readthedocs.io