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
- Host: GitHub
- URL: https://github.com/lucaferranti/forwardmodead
- Owner: lucaferranti
- License: mit
- Created: 2022-06-10T12:03:32.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-23T08:00:24.000Z (about 2 years ago)
- Last Synced: 2025-06-03T05:37:20.313Z (about 1 year ago)
- Topics: automatic-differentiation, chapel, dual-numbers, numerics
- Language: Chapel
- Homepage:
- Size: 85 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ForwardModeAD
[![license: MIT][mit-img]](LICENSE)[![docs-dev][dev-img]][dev-url]
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