{"id":16722130,"url":"https://github.com/masonprotter/modelingtoolkitderiv","last_synced_at":"2026-02-08T12:33:35.364Z","repository":{"id":133640930,"uuid":"125901531","full_name":"MasonProtter/ModelingToolkitDeriv","owner":"MasonProtter","description":"Package for taking derivatives on ModellingToolkit Operations","archived":false,"fork":false,"pushed_at":"2018-03-19T22:10:51.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-04T13:52:10.192Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","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/MasonProtter.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-19T18:17:07.000Z","updated_at":"2018-03-19T22:10:52.000Z","dependencies_parsed_at":"2023-06-14T15:45:15.756Z","dependency_job_id":null,"html_url":"https://github.com/MasonProtter/ModelingToolkitDeriv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MasonProtter/ModelingToolkitDeriv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonProtter%2FModelingToolkitDeriv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonProtter%2FModelingToolkitDeriv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonProtter%2FModelingToolkitDeriv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonProtter%2FModelingToolkitDeriv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MasonProtter","download_url":"https://codeload.github.com/MasonProtter/ModelingToolkitDeriv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasonProtter%2FModelingToolkitDeriv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29230370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T12:28:20.184Z","status":"ssl_error","status_checked_at":"2026-02-08T12:28:19.510Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-12T22:33:40.967Z","updated_at":"2026-02-08T12:33:35.343Z","avatar_url":"https://github.com/MasonProtter.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ModellingToolkitDeriv\nPackage for taking derivatives on ModellingToolkit Operations using automatic differentiation in the expression tree\n\n## Examples:\n```julia\njulia\u003e using ModelingToolkit, ModelingToolkitDeriv\n\njulia\u003e @IVar t; \n\njulia\u003e f(t) = t^2;\n\njulia\u003e g(t) = log(t);\n```\nTo take the derivative of `f` with repsect to `t`, we simply call the `D` operator on `f` and evaluate the resulting function at a `t` of our choosing\n```julia\njulia\u003e D(f)(t)\n0 + (2 * (t + 0) ^ 1) * 1\n\njulia\u003e ans |\u003e simplify_constants\n2 * t ^ 1\n```\nThis system has the product rule and chain rule built in\n\n```julia\njulia\u003e D(t -\u003e f(t)*g(t))(t) |\u003e simplify_constants\nt ^ 2 * (1 / t) + (2 * t ^ 1) * log(t)\n\njulia\u003e D(t -\u003e g(t)^2)(t) |\u003e simplify_constants\n(2 * log(t) ^ 1) * (1 / t)\n```\n\nand avoids perturbation confusion (allowing it to take higher derivatives)\n```julia\njulia\u003e D(D(f))(t) |\u003e simplify_constants\n2 * t ^ 0\n\njulia\u003e D(D(g))(t) |\u003e simplify_constants\n-1 / t ^ 2\n```\nOne can also take expoentials of the derivative operator to specify $n^\\mathrm{th}$ order derivatives\n```julia\njulia\u003e (D^2)(f)(t) |\u003e simplify_constants\n2 * t ^ 0\n\njulia\u003e (D^3)(g)(t) |\u003e simplify_constants\n(-1 / (t ^ 2) ^ 2) * (2 * t ^ 1)\n```\nNote: Currently due to a bug I don't understand, D^4 or higher powers seems to hang indefinitely. \n\n\nAdding new functions to take derivatives of is simple. For instance, currently trig functions are not supported. To support them, simply define methods so they know how to accept `Differential` arguments using the `unaryOp(f, dfdx)` or `binaryOp(f,dfdx,dfdy)` functions depending on the arity of the function you wish to take derivatives of.\n\n```julia\njulia\u003e D(x-\u003e sin(x))(t)\nERROR: MethodError: no method matching sin(::ModelingToolkitDeriv.Differential)\n\njulia\u003e Base.sin(x::Differential) = unaryOp(sin, cos)(x)\n\njulia\u003e D(x-\u003e sin(x))(t) |\u003e simplify_constants\ncos(t)\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasonprotter%2Fmodelingtoolkitderiv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasonprotter%2Fmodelingtoolkitderiv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasonprotter%2Fmodelingtoolkitderiv/lists"}