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,
)
result = fxp.solve(guess=jnp.zeros_like(a), accelerator=accelerator)

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.0.tar.gz (4.1 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.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fxp_jax-0.2.0.tar.gz
  • Upload date:
  • Size: 4.1 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.0.tar.gz
Algorithm Hash digest
SHA256 6cfe84fde5f58a3d246d5256141d9f840089a3eef61485d12fa19f3737017492
MD5 bc33ff406bfe86bea12644fdf45ea4bf
BLAKE2b-256 de3e52a961187e6db455046dbd3d91b85629028da8faf76ce927c33c02e2b985

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxp_jax-0.2.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: fxp_jax-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe093cab22b776d910522a2fa0a6cda6186f896fed39c66ee7b18bcaefc48b91
MD5 52604015dddf4b48ef1e7ac150ce3d71
BLAKE2b-256 4a9cf4bd7e37ae6b09bff817120139b7473d9d11497baee3726fb37b4be91bfd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fxp_jax-0.2.0-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