{"id":19141623,"url":"https://github.com/djmaxus/autodj","last_synced_at":"2025-07-27T02:35:49.028Z","repository":{"id":57751558,"uuid":"524774673","full_name":"djmaxus/autodj","owner":"djmaxus","description":"Automatic Differentiation Library","archived":false,"fork":false,"pushed_at":"2025-04-06T14:03:14.000Z","size":244,"stargazers_count":10,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-05-06T23:46:55.126Z","etag":null,"topics":["automatic-differentiation","calculus","computational-mathematics","derivatives","dual-numbers","gradient","jacobian","mathematics"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/autodj","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djmaxus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-14T20:36:45.000Z","updated_at":"2025-04-07T06:37:57.000Z","dependencies_parsed_at":"2024-01-15T13:20:38.967Z","dependency_job_id":"2d41456b-4223-42e7-b1e7-d75861ba2efe","html_url":"https://github.com/djmaxus/autodj","commit_stats":{"total_commits":151,"total_committers":2,"mean_commits":75.5,"dds":"0.19867549668874174","last_synced_commit":"3e6c46342cfa6882985da4a2c10ba14d04998292"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/djmaxus/autodj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djmaxus%2Fautodj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djmaxus%2Fautodj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djmaxus%2Fautodj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djmaxus%2Fautodj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djmaxus","download_url":"https://codeload.github.com/djmaxus/autodj/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djmaxus%2Fautodj/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267289598,"owners_count":24064730,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automatic-differentiation","calculus","computational-mathematics","derivatives","dual-numbers","gradient","jacobian","mathematics"],"created_at":"2024-11-09T07:24:06.091Z","updated_at":"2025-07-27T02:35:48.967Z","avatar_url":"https://github.com/djmaxus.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Automatic Differentiation Library\r\n\r\n[![crates.io](https://img.shields.io/crates/v/autodj.svg)](https://crates.io/crates/autodj)\r\n[![docs](https://docs.rs/autodj/badge.svg)](https://docs.rs/autodj/)\r\n[![CI](https://github.com/djmaxus/autodj/actions/workflows/ci.yml/badge.svg)](https://github.com/djmaxus/autodj/actions/workflows/ci.yml)\r\n[![audit](https://github.com/djmaxus/autodj/actions/workflows/audit.yml/badge.svg)](https://github.com/djmaxus/autodj/actions/workflows/audit.yml)\r\n\r\n**AUTO**matic **D**erivatives \u0026 **J**acobians\r\nby [djmaxus](https://djmaxus.github.io/) and [you](https://github.com/djmaxus/autodj/issues)\r\n\r\n- [Functionality](#functionality)\r\n  - [Single variables](#single-variables)\r\n  - [Multiple variables](#multiple-variables)\r\n    - [Static number of variables](#static-number-of-variables)\r\n    - [Dynamic number of variables](#dynamic-number-of-variables)\r\n  - [Generic dual numbers](#generic-dual-numbers)\r\n- [Motivation](#motivation)\r\n- [Project goals](#project-goals)\r\n- [Anticipated features](#anticipated-features)\r\n- [Comparison with `autodiff`](#comparison-with-autodiff)\r\n\r\n## Functionality\r\n\r\n### Single variables\r\n\r\n```rust\r\nuse autodj::prelude::single::*;\r\n\r\nlet x : DualF64 = 2.0.into_variable();\r\n\r\n// Arithmetic operations are required by trait bounds\r\nlet _f = x * x + 1.0.into();\r\n\r\n// Arithmetic rules itself are defined in `Dual` trait\r\n// on borrowed values for extendability\r\nlet f = (x*x).add_impl(\u00261.0.into());\r\n\r\n// Dual can be decomposed into a value-derivative pair\r\nassert_eq!(f.decompose(), (5.0, 4.0));\r\n\r\n// fmt::Display resembles Taylor expansion\r\nassert_eq!(format!(\"{f}\"), \"5+4∆\");\r\n```\r\n\r\n### Multiple variables\r\n\r\nMultivariate differentiation is based on **multiple dual components**.\r\nSuch an approach requires **no repetitive and \"backward\" differentiations**.\r\nEach partial derivative is tracked separately from the start,\r\nand no repetitive calculations are made.\r\n\r\nFor built-in multivariate specializations,\r\nindependent variables can be created consistently using `.into_variables()` method.\r\n\r\n#### Static number of variables\r\n\r\n```rust\r\nuse autodj::prelude::array::*;\r\n\r\n// consistent set of independent variables\r\nlet [x, y] : [DualNumber\u003cf64,2\u003e; 2] = [2.0, 3.0].into_variables();\r\n\r\nlet f = x * (y - 1.0.into());\r\n\r\nassert_eq!(f.value()        , \u0026 4.);\r\nassert_eq!(f.dual().as_ref(), \u0026[2., 2.]);\r\nassert_eq!(format!(\"{f}\")   , \"4+[2.0, 2.0]∆\");\r\n```\r\n\r\n#### Dynamic number of variables\r\n\r\n```rust\r\nuse autodj::prelude::vector::*;\r\nuse std::ops::Add;\r\n\r\nlet x = vec![1., 2., 3., 4., 5.].into_variables();\r\n\r\nlet f : DualF64 = x.iter()\r\n                   .map(|x : \u0026DualF64| x.mul_impl(\u00262.0.into()))\r\n                   .reduce(Add::add)\r\n                   .unwrap();\r\n\r\nassert_eq!(f.value(), \u002630.);\r\n\r\nf.dual()\r\n .as_ref()\r\n .iter()\r\n .for_each(|deriv| assert_eq!(deriv, \u00262.0) );\r\n```\r\n\r\n### Generic dual numbers\r\n\r\n```rust\r\n// A trait with all the behavior defined\r\nuse autodj::fluid::Dual;\r\n// A generic data structure which implements Dual\r\nuse autodj::solid::DualNumber;\r\n```\r\n\r\n## Motivation\r\n\r\nI do both academic \u0026 business R\u0026D in the area of computational mathematics.\r\nAs well as many of us, I've written a whole bunch of sophisticated Jacobians\r\n_by hand_.\r\n\r\nOne day, I learned about automatic differentiation based on dual numbers.\r\nAlmost the same day, I learned about Rust as well :crab:\r\n\r\nThen, I decided to:\r\n\r\n- Make it automatic and reliable as much as possible\r\n- Use modern and convenient ecosystem of Rust development\r\n\r\n## Project goals\r\n\r\n- Develop open-source automatic differentiation library\r\n  for both _academic_ and _commercial_ computational mathematicians\r\n- Gain experience of Rust programming\r\n\r\n## Anticipated features\r\n\r\nYou are very welcome to introduce [issues](https://github.com/djmaxus/autodj/issues/new/choose)\r\nto promote most wanted features or to report a bug.\r\n\r\n- [x] Generic implementation of dual numbers\r\n- Number of variables to differentiate\r\n  - [x] single\r\n  - multiple\r\n    - [x] static\r\n    - [x] dynamic\r\n    - [x] sparse\r\n  - [ ] Jacobians (efficient layouts in memory to make matrices right away)\r\n- [x] Named variables (UUID-based)\r\n- [ ] Calculation tracking (partial derivatives of intermediate values)\r\n- Third-party crates support (as features)\r\n  - [x] `num-traits`\r\n  - [x] linear algebra crates (`nalgebra` etc.)\r\n- [x] `no_std` support\r\n- Advanced features\r\n  - [x] Arbitrary number types beside `f64`\r\n  - [ ] Inter-operability of different dual types (e.g., single and multiple dynamic)\r\n  - [ ] Numerical verification (or replacement) of derivatives (by definition)\r\n  - [ ] Macro for automatic extensions of regular (i.e. non-dual) functions\r\n  - [ ] Optional calculation of derivatives\r\n    - [ ] Backward differentiation probably\r\n    - [ ] Iterator implementation as possible approach to lazy evaluation\r\n\r\n## Comparison with [`autodiff`](https://crates.io/crates/autodiff)\r\n\r\nAs far as I noticed, `autodj` currently has the following differences\r\n\r\n- Multiple variables out of the box\r\n- `fmt::Display` for statically-known number of variables\r\n- Left-to-right flow of many operations such as `.into-variables()`, `.eval()`, etc.\r\n- Number type is restricted to `f64`\r\n- No utilization of `num` and `nalgebra` crates\r\n\r\nSome differences are planned to be eliminated as noted in the [roadmap](#anticipated-features).\r\n\r\nWithin this crate, you may study \u0026 launch test target `/tests/autodiff.rs`\r\nto follow some differences.\r\n\r\n```shell\r\ncargo test --test autodiff -- --show-output\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjmaxus%2Fautodj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjmaxus%2Fautodj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjmaxus%2Fautodj/lists"}