{"id":18847846,"url":"https://github.com/jacobwilliams/diff","last_synced_at":"2026-03-19T06:42:06.081Z","repository":{"id":14299761,"uuid":"17008323","full_name":"jacobwilliams/diff","owner":"jacobwilliams","description":"Numerical Differentiation of a User Defined Function","archived":false,"fork":false,"pushed_at":"2022-05-22T20:58:33.000Z","size":674,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-23T00:40:08.376Z","etag":null,"topics":["differentiation","numerical-differentiation"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacobwilliams.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":"2014-02-20T03:45:05.000Z","updated_at":"2022-05-22T20:29:50.000Z","dependencies_parsed_at":"2022-09-16T00:51:37.566Z","dependency_job_id":null,"html_url":"https://github.com/jacobwilliams/diff","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jacobwilliams/diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fdiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fdiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fdiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fdiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobwilliams","download_url":"https://codeload.github.com/jacobwilliams/diff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fdiff/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273649059,"owners_count":25143631,"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-04T02:00:08.968Z","response_time":61,"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":["differentiation","numerical-differentiation"],"created_at":"2024-11-08T03:09:51.278Z","updated_at":"2026-02-13T16:03:44.831Z","avatar_url":"https://github.com/jacobwilliams.png","language":"Fortran","readme":"diff\n============\n\nNumerical Differentiation of a User Defined Function\n\n### Status\n\n[![GitHub release](https://img.shields.io/github/release/jacobwilliams/diff.svg)](https://github.com/jacobwilliams/diff/releases/latest)\n[![Build Status](https://github.com/jacobwilliams/diff/actions/workflows/CI.yml/badge.svg)](https://github.com/jacobwilliams/diff/actions)\n[![codecov](https://codecov.io/gh/jacobwilliams/diff/branch/master/graph/badge.svg)](https://codecov.io/gh/jacobwilliams/diff)\n[![last-commit](https://img.shields.io/github/last-commit/jacobwilliams/diff)](https://github.com/jacobwilliams/diff/commits/master)\n\n### Overview\n\nThis code is a modern Fortran update of the DIFF subroutine found here: `ftp://math.nist.gov/pub/repository/diff/`\n\nThe DIFF subroutine computes the first, second or third derivative of a real function of a single real variable.  The user provides the function, a real interval `[xmin,xmax]` on which the function is continuous, and a point `x0` lying in `[xmin,xmax]`. Optionally, the user may provide an estimate of the absolute or relative accuracy of function evaluation in `[xmin,xmax]` and the absolute or relative error tolerance that is acceptable in the computed derivative. The subroutine returns the computed derivative and an estimated upper bound on the absolute error of the computed derivative. The method used is Neville's process of extrapolating from a sequence of interpolating polynomials with interpolating points distributed symmetrically about `x0` or, if this is not possible, to one side of `x0`.\n\nThe original sourcecode was produced by the National Bureau of Standards, and is presumed to be in the public domain.\n\n### Compiling\n\nA [Fortran Package Manager](https://github.com/fortran-lang/fpm) manifest file is included, so that the library and test cases can be compiled with FPM. For example:\n\n```\nfpm build --profile release\nfpm test --profile release\n```\n\nTo use `diff` within your fpm project, add the following to your `fpm.toml` file:\n```toml\n[dependencies]\ndiff = { git=\"https://github.com/jacobwilliams/diff.git\" }\n```\n\n### Example Usage\n\n```fortran\n    program example\n\n    use diff_module\n    use iso_fortran_env, only: wp =\u003e real64 !use double precision\n\n    implicit none\n\n    integer,parameter  :: iord  = 1\n    real(wp),parameter :: x0    = 0.12345_wp\n    real(wp),parameter :: xmin  = 0.0_wp\n    real(wp),parameter :: xmax  = 1.0_wp\n    real(wp),parameter :: eps   = 1.0e-9_wp\n    real(wp),parameter :: acc   = 0.0_wp\n\n    real(wp) :: deriv, error\n    integer  :: ifail\n    type(diff_func) :: d\n\n    call d%set_function(sin_func) !set function\n    call d%compute_derivative(iord,x0,xmin,xmax,eps,acc,deriv,error,ifail)\n\n    write(*,'(A)') ''\n    write(*,'(A,I5)')     'ifail                :', ifail\n    write(*,'(A,E25.16)') 'estimated derivative :', deriv\n    write(*,'(A,E25.16)') 'actual derivative    :', cos(x0)\n    write(*,'(A,E25.16)') 'estimated error      :', error\n    write(*,'(A,E25.16)') 'actual error         :', cos(x0) - deriv\n    write(*,'(A)') ''\n\n    contains\n\n        function sin_func(me,x) result(fx)\n\n        implicit none\n\n        class(diff_func),intent(inout) :: me\n        real(wp),intent(in) :: x\n        real(wp) :: fx\n\n        fx = sin(x)\n\n        end function sin_func\n\n    end program example\n```\n\nWhich produces:\n\n```\nifail                :   0\nestimated derivative :   0.9923897210998529E+00\nactual derivative    :   0.9923897211114882E+00\nestimated error      :   0.5805992701806732E-09\nactual error         :   0.1163524832037410E-10\n```\n\n### Documentation\n\n * The API documentation for the current ```master``` branch can be found [here](https://jacobwilliams.github.io/diff/).  This is generated by processing the source files with [FORD](https://github.com/Fortran-FOSS-Programmers/ford).\n\n### Notes\n\nAlan Miller's [to_f90](http://jblevins.org/mirror/amiller/to_f90.f90) program was used to assist in the conversion to modern Fortran.\n\n### See also\n\n * DIFF has been incorporated into the [NumDiff](https://github.com/jacobwilliams/NumDiff) library.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwilliams%2Fdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobwilliams%2Fdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwilliams%2Fdiff/lists"}