Skip to main content

Simple fixed-point solver implemented in JAX

Project description

PyPI version CI CD

Fixed-point solver

FixedPointJAX is a simple implementation of a fixed-point iteration algorithm for root finding in JAX. The implementation allow the user to solve the system of fixed point equations by standard fixed point iterations and the SQUAREM accelerator, see Du and Varadhan (2020).

Installation

pip install fxp-jax

Usage

import jax
import jax.numpy as jnp
from jax import random

from fxp_jax import fxp_root

jax.config.update("jax_enable_x64", True)

accelerator = "squarem"

N = 100

a = random.uniform(random.PRNGKey(111), (N,1))
b = random.uniform(random.PRNGKey(112), (1,1))

def fun(x: jnp.ndarray) -> tuple[jnp.ndarray, jnp.ndarray]:
    y = a + x @ b
    return y, y - x

fxp = fxp_root(fun, accelerator=accelerator)

result = fxp.solve(jnp.zeros_like(a))

y, z = fxp.fun(result.x)

print('--------------------------------------------------------')
print(f'System of fixed-point equations is solved: {jnp.allclose(result.x, y)}.')
print(f'Roots are zero: {jnp.allclose(z, 0.0)}.')
print('--------------------------------------------------------')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fxp_jax-0.2.2.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fxp_jax-0.2.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file fxp_jax-0.2.2.tar.gz.

File metadata

  • Download URL: fxp_jax-0.2.2.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fxp_jax-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a1bbc8b820ba5e02d6be100b64895c698e3d3c186f92e6bb589f9ac412593790
MD5 181beb0efd14f8c26728ea048b9769e1
BLAKE2b-256 6d605621c8c1c57f77d33ae973f8f9e3752d9858517f1d850cf6d31157b52d41

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxp_jax-0.2.2.tar.gz:

Publisher: cd.yml on esbenscriver/fxp-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fxp_jax-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: fxp_jax-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fxp_jax-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 309a9504f49477f3d38a3eab1502f18648955680701e1062ccc7c3272b27d981
MD5 ca6a41e0a0a517e4ea911f2a27046b81
BLAKE2b-256 39ddd6d3284c6b2a84c696b4c99ba306b5a89f5bd7bc7c3df81923ec6221906b

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxp_jax-0.2.2-py3-none-any.whl:

Publisher: cd.yml on esbenscriver/fxp-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page