{"id":20157237,"url":"https://github.com/robinka/tadiff","last_synced_at":"2025-09-10T13:34:39.976Z","repository":{"id":44216267,"uuid":"213066016","full_name":"RobinKa/tadiff","owner":"RobinKa","description":"Numeric and symbolic automatic differentation for javascript and typescript","archived":false,"fork":false,"pushed_at":"2022-12-30T18:48:31.000Z","size":67,"stargazers_count":8,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-06T22:49:42.606Z","etag":null,"topics":["automatic-differentiation","derivative","javascript","math","numeric","reverse-mode","symbolic","typescript"],"latest_commit_sha":null,"homepage":"https://warlock.ai/tadiff-frontend/","language":"TypeScript","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/RobinKa.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":"2019-10-05T20:21:13.000Z","updated_at":"2024-01-14T16:45:07.000Z","dependencies_parsed_at":"2023-01-31T13:25:18.156Z","dependency_job_id":null,"html_url":"https://github.com/RobinKa/tadiff","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RobinKa/tadiff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinKa%2Ftadiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinKa%2Ftadiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinKa%2Ftadiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinKa%2Ftadiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobinKa","download_url":"https://codeload.github.com/RobinKa/tadiff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinKa%2Ftadiff/sbom","scorecard":{"id":121834,"data":{"date":"2025-08-11","repo":{"name":"github.com/RobinKa/tadiff","commit":"5ae25aad62a95b68f6a8885f0f589ddbee181dcd"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-x2fc-mxcx-w4mf","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T02:37:22.703Z","repository_id":44216267,"created_at":"2025-08-16T02:37:22.703Z","updated_at":"2025-08-16T02:37:22.703Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274470569,"owners_count":25291605,"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-09-10T02:00:12.551Z","response_time":83,"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","derivative","javascript","math","numeric","reverse-mode","symbolic","typescript"],"created_at":"2024-11-13T23:44:44.732Z","updated_at":"2025-09-10T13:34:39.943Z","avatar_url":"https://github.com/RobinKa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tora's Automatic Differentiation\r\nReverse-mode automatic differentiation for javascript and typescript. Supports symbolic and numeric modes. Only scalars are supported right now.\r\n\r\n[Demo](https://warlock.ai/tadiff-frontend/)\r\n[GitHub](https://github.com/RobinKa/tadiff)\r\n\r\n# Installation\r\n`npm install tadiff`\r\n\r\nCan also be built by cloning this repository and running `npm run build`. Tests can be run with `npm run test`.\r\n\r\n# Usage\r\nImport the module in typescript `import * as tad from \"tadiff\"` or in javascript `const tad = require(\"tadiff\");`\r\n\r\n## 1. Build an expression\r\nBuilding a math expression can be done by constructing the tree with the expression classes manually. This can get verbose very quickly so\r\nalternatively a string parser is available.\r\n\r\nWith expression objects:\r\n```ts\r\nimport * as tad from \"tadiff\"\r\n\r\nconst varA = new tad.Variable(\"a\")\r\nconst varB = new tad.Variable(\"b\")\r\nconst expr = new tad.Divide(new tad.Multiply(new tad.Constant(4), new tad.Exp(new tad.Multiply(varA, varB))), new tad.Abs(new tad.Tan(varB)))\r\n```\r\n\r\nWith string parser:\r\n```ts\r\nimport * as tad from \"tadiff\"\r\n\r\nconst expr = tad.parseExpression(\"4 * exp(a * b) / abs(tan(b))\")\r\n\r\n// Get the variables of the expression.\r\n// Stored as variables[\"a\"] and variables[\"b\"].\r\nconst vars = tad.getAllVariables(expr)\r\n```\r\n\r\nThe expression can now be used for numeric evaluation using numbers. Values for all variables have to be passed. The expression can also be printed symbolically.\r\n\r\n```ts\r\nconsole.log(expr.evaluateToString())\r\n\r\nconst evalContext = {\r\n    variableValues: {\r\n        \"a\": 2,\r\n        \"b\": 3\r\n    }\r\n}\r\n\r\nconsole.log(expr.evaluate(evalContext))\r\n```\r\n\r\n## 2. Differentiate an expression\r\nTo differentiate an expression we first get all derivatives of an expression using `getAllDerivatives`. An output derivative has to be passed, this is typically just `1`.\r\nThis will produce all derivatives for all variables within the expression, although each variable has multiple derivatives which have to be summed up using `getDerivativeForExpression`.\r\nNote that this will give back an expression for the derivative. There is nothing special about this expression and it can be used just like any other expression, for example\r\nit can be used to build higher order derivatives.\r\n\r\n```ts\r\nconst derivativeA = tad.getDerivativeForExpression(variables[\"a\"], tad.getAllDerivatives(expr, new tad.Constant(1)))\r\nconst derivativeB = tad.getDerivativeForExpression(variables[\"b\"], tad.getAllDerivatives(expr, new tad.Constant(1)))\r\n```\r\n\r\nIt is also possible to have derivatives within the expression itself.\r\n\r\n```ts\r\nconst derivativeExpr = tad.parseExpression(\"4 * D(x, cos(x * y))\")\r\n```\r\n\r\n## 3. Interop with mathjs\r\nThis library uses mathjs for some of its operations such as parsing and simplification.\r\nTo convert from tadiff expressions to mathjs expressions use `expressionToNode`.\r\nTo convert from mathjs expressions to tadiff expressions use `nodeToExpression`. Here we will also have to pass a `tad.Variable` for each of the variable symbols occuring in the node tree.\r\n\r\nA good use-case of converting to mathjs nodes is to simplify the tadiff expressions as no simplification is done in tadiff. `expressionToNode`\r\nautomatically calls the simplify function.\r\n\r\n# Expressions\r\nListed below are the available expressions as both the tadiff classes and the string that can be used for string parsing.\r\n\r\n| Operation | Class | String parsing |\r\n| --------- | :---: | :---------------: |\r\n| Constant number | Constant | a number (eg. `5`, `3.45`) |\r\n| Variable | Variable | letters (eg. `v`, `px3`) |\r\n| Differentiation | Derivative | `D(x, f(x))` |\r\n| Addition | Add | `+` |\r\n| Subtraction | Subtract | `-` |\r\n| Multiplication | Multiply | `*` |\r\n| Division | Divide | `/` |\r\n| Exponentiation | Power | `^` |\r\n| Sine | Sin | `sin` |\r\n| Cosine | Cos | `cos` |\r\n| Tan | Tan | `tan` |\r\n| Natural logarithm | Log | `log` |\r\n| Negation | Negate | `-` |\r\n| Natural exponential | Exp | `exp` |\r\n| Sign | Sign | `sign` |\r\n| Absolute value | Abs | `abs` |\r\n| Square root | Power(..., 0.5) | `sqrt` |\r\n\r\n# Adding new operations\r\nCreating new operations requires implementing the `tad.Expression` interface. Most importantly the used inputs are passed through the constructor and need\r\nto be returned from `getDependencies`.\r\n`evaluateImpl` will need to return the numeric result. `evaluateToString` returns a symbolic string. `getDependencyDerivatives` needs to return\r\nthe derivatives for the dependencies in the same order as `getDependencies`. For more information look at the `expressions.ts` source code as\r\nmost expressions are only around 20 lines long.\r\nIf you do implement a new operation I would be happy to accept a pull request for it.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinka%2Ftadiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinka%2Ftadiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinka%2Ftadiff/lists"}