{"id":15059726,"url":"https://github.com/rajasharan/elm-automatic-differentiation","last_synced_at":"2026-01-28T21:02:09.722Z","repository":{"id":62419455,"uuid":"109597581","full_name":"rajasharan/elm-automatic-differentiation","owner":"rajasharan","description":"Automatic differentiation (a.k.a algorithmic differentiation) in reverse mode for elm","archived":false,"fork":false,"pushed_at":"2017-11-05T16:50:47.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T19:48:38.593Z","etag":null,"topics":["algorithmic-differentiation","automatic-differentiation","backpropagation","elm","elm-lang"],"latest_commit_sha":null,"homepage":"","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rajasharan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-05T16:48:12.000Z","updated_at":"2017-11-05T16:54:59.000Z","dependencies_parsed_at":"2022-11-01T16:31:44.220Z","dependency_job_id":null,"html_url":"https://github.com/rajasharan/elm-automatic-differentiation","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajasharan%2Felm-automatic-differentiation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajasharan%2Felm-automatic-differentiation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajasharan%2Felm-automatic-differentiation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajasharan%2Felm-automatic-differentiation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rajasharan","download_url":"https://codeload.github.com/rajasharan/elm-automatic-differentiation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243681083,"owners_count":20330155,"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","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":["algorithmic-differentiation","automatic-differentiation","backpropagation","elm","elm-lang"],"created_at":"2024-09-24T22:47:02.669Z","updated_at":"2026-01-28T21:02:09.677Z","avatar_url":"https://github.com/rajasharan.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Automatic differentiation in reverse mode for elm\n\nThis library calculates the paritial derivatives of a multi-variable function\nusing the method of automatic differentiation in reverse mode. The result is returned\nas a dictionary of keys and their corresponding derivative values (gradient vector).\n\n- a.k.a [algorithmic differentiation](https://en.wikipedia.org/wiki/Automatic_differentiation)\n- a.k.a [backpropagation](https://en.wikipedia.org/wiki/Backpropagation)\n\n## Usage\n### Install\n```sh\nelm-package install rajasharan/elm-automatic-differentiation\n```\n\n### Import\n```elm\nimport Dict exposing (Dict)\nimport AD.Reverse as AD\n  exposing\n    ( pow, sqr, exp\n    , add, mul\n    , (|+|), (|.|), (|*|), (|^|)\n    , autodiff\n    )\n```\n\n### API usage\n```elm\n-- build a computation graph for your function, for e.g.,\n-- f(x,y) = (x+y)^2 . e^(2.(y+1)) + sin (x+y)^2\nf : Float -\u003e Float -\u003e AD.Node\nf x y =\n  let\n      a = AD.Variable \"x\" x\n      b = AD.Variable \"y\" y\n      u = pow (a |+| b) (AD.Const 2)\n      v = (b |+| AD.Const 1)\n      w = sqr (exp v)\n      z = u |*| w |+| AD.sin u\n  in\n      z\n\n-- result is a dictionary of keys and their corresponding derivative values\nresult : Dict String Float\nresult = autodiff (f 3 2)\n\n-- [(\"x\",4044.1999630459845),(\"y\",24215.639637682732)]\n-- this means:\n-- ∂f/∂x = 4044.19996 at (x=3, y=2)\n-- ∂f/∂y = 24215.6396 at (x=3, y=2)\n```\n\n#### Another example\n```elm\n-- g(x) = x^2\ng : Float -\u003e AD.Node\ng x =\n  let\n      a = AD.Variable \"x\" x\n  in\n      a |^| (AD.Const 2)\n\nresult2 = autodiff (g 6)\n-- [(\"x\", 12)]\n-- ∂g/∂x = 12 at (x=6)\n```\n\n## Further Reading\n* [Rufflewind's Scratchpad - Reverse-mode automatic differentiation: a tutorial](https://rufflewind.com/2016-12-30/reverse-mode-automatic-differentiation)\n* [Daniel Brice - Automatic Differentiation in Haskell](https://www.youtube.com/watch?v=q1DUKEOUoxA)\n* [github.com/friedbrice/AutoDiff](https://github.com/friedbrice/AutoDiff)\n\n### [License](/LICENSE)\nThe MIT License (MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajasharan%2Felm-automatic-differentiation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frajasharan%2Felm-automatic-differentiation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajasharan%2Felm-automatic-differentiation/lists"}