{"id":17143824,"url":"https://github.com/asem000/finitediffx","last_synced_at":"2025-09-07T02:33:56.704Z","repository":{"id":93673611,"uuid":"608002091","full_name":"ASEM000/finitediffX","owner":"ASEM000","description":"Finite difference tools in JAX","archived":false,"fork":false,"pushed_at":"2024-02-04T04:01:10.000Z","size":167,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T11:12:00.593Z","etag":null,"topics":["finite-difference-method","jax","python"],"latest_commit_sha":null,"homepage":"https://finitediffx.readthedocs.io/en/latest/index.html","language":"Python","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/ASEM000.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-03-01T05:32:29.000Z","updated_at":"2025-04-07T09:18:02.000Z","dependencies_parsed_at":"2023-09-22T17:33:43.957Z","dependency_job_id":null,"html_url":"https://github.com/ASEM000/finitediffX","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASEM000%2FfinitediffX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASEM000%2FfinitediffX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASEM000%2FfinitediffX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ASEM000%2FfinitediffX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ASEM000","download_url":"https://codeload.github.com/ASEM000/finitediffX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703198,"owners_count":21148118,"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":["finite-difference-method","jax","python"],"created_at":"2024-10-14T20:42:23.543Z","updated_at":"2025-04-13T11:12:05.628Z","avatar_url":"https://github.com/ASEM000.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch5 align=\"center\"\u003e\n\u003cimg width=\"200px\" src=\"assets/logo.svg\"\u003e \u003cbr\u003e\n\n\u003cbr\u003e\n\n[**Installation**](#installation)\n|[**Examples**](#examples)\n\n![Tests](https://github.com/ASEM000/pytreeclass/actions/workflows/tests.yml/badge.svg)\n![pyver](https://img.shields.io/badge/python-3.8%203.9%203.10%203.11_-red)\n![pyver](https://img.shields.io/badge/jax-0.4+-red)\n![codestyle](https://img.shields.io/badge/codestyle-black-black)\n[![Downloads](https://static.pepy.tech/badge/FiniteDiffX)](https://pepy.tech/project/FiniteDiffX)\n[![codecov](https://codecov.io/github/ASEM000/FiniteDiffX/branch/main/graph/badge.svg?token=VD45Y4HLWV)](https://codecov.io/github/ASEM000/FiniteDiffX)  \n[![Documentation Status](https://readthedocs.org/projects/finitediffx/badge/?version=latest)](https://finitediffx.readthedocs.io/en/latest/?badge=latest)\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ASEM000/FiniteDiffX/blob/main/FiniteDiffX%20Examples.ipynb)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/m/ASEM000/FiniteDiffX)\n![PyPI](https://img.shields.io/pypi/v/FiniteDiffX)\n[![CodeFactor](https://www.codefactor.io/repository/github/asem000/finitediffx/badge)](https://www.codefactor.io/repository/github/asem000/finitediffx)\n\n\u003c/h5\u003e\n\nDifferentiable finite difference tools in `jax`\n\n## 🛠️ Installation\u003ca id=\"installation\"\u003e\u003c/a\u003e\n\n```python\npip install FiniteDiffX\n```\n\n**Install development version**\n\n```python\npip install git+https://github.com/ASEM000/FiniteDiffX\n```\n\n**If you find it useful to you, consider giving it a star! 🌟**\n\n\u003cbr\u003e\n\n## ⏩ Quick Example\u003ca id=\"examples\"\u003e\u003c/a\u003e\n\n```python\nimport jax.numpy as jnp\nimport finitediffx as fdx\n\n# lets first define a vector valued function F: R^3 -\u003e R^3\n# F = F1, F2\n# F1 = x^2 + y^3\n# F2 = x^4 + y^3\n# F3 = 0\n# F = [x**2 + y**3, x**4 + y**3, 0]\n\nx, y, z = [jnp.linspace(0, 1, 100)] * 3\ndx, dy, dz = x[1] - x[0], y[1] - y[0], z[1] - z[0]\nX, Y, Z = jnp.meshgrid(x, y, z, indexing=\"ij\")\nF1 = X**2 + Y**3\nF2 = X**4 + Y**3\nF3 = jnp.zeros_like(F1)\nF = jnp.stack([F1, F2, F3], axis=0)\n\n# ∇.F : the divergence of F\ndivF = fdx.divergence(\n    F,\n    step_size=(dx, dy, dz),\n    keepdims=False,\n    accuracy=6,\n    method=\"central\",\n)\n```\n\n`jax.grad`, `jax.value_and_grad` finite difference counterpart to be used on\n[unimplemented rules in `jax`](https://github.com/google/jax/discussions/16584) or\n[on non-traceable `numpy` code](https://github.com/google/jax/issues/15425)\n\n```python\n\nimport jax\nfrom jax import numpy as jnp\nimport numpy as onp  # Not jax-traceable\nimport finitediffx as fdx\nimport functools as ft\nfrom jax.experimental import enable_x64\n\nwith enable_x64():\n\n    @fdx.fgrad\n    @fdx.fgrad\n    def np_rosenbach2_fdx_style_1(x, y):\n        \"\"\"Compute the Rosenbach function for two variables in numpy.\"\"\"\n        return onp.power(1-x, 2) + 100*onp.power(y-onp.power(x, 2), 2)\n\n    @ft.partial(fdx.fgrad, derivative=2)\n    def np2_rosenbach2_fdx_style2(x, y):\n        \"\"\"Compute the Rosenbach function for two variables.\"\"\"\n        return onp.power(1-x, 2) + 100*onp.power(y-onp.power(x, 2), 2)\n\n    @jax.grad\n    @jax.grad\n    def jnp_rosenbach2(x, y):\n        \"\"\"Compute the Rosenbach function for two variables.\"\"\"\n        return jnp.power(1-x, 2) + 100*jnp.power(y-jnp.power(x, 2), 2)\n\n    print(np_rosenbach2_fdx_style_1(1.,2.))\n    print(np2_rosenbach2_fdx_style2(1.,2.))\n    print(jnp_rosenbach2(1., 2.))\n# 402.0000951997936\n# 402.0000000002219\n# 402.0\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasem000%2Ffinitediffx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasem000%2Ffinitediffx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasem000%2Ffinitediffx/lists"}