Skip to content

ENH: add one_minus_square - #1051

Open
NeilGirdhar wants to merge 1 commit into
data-apis:mainfrom
NeilGirdhar:one-minus-square
Open

NeilGirdhar wants to merge 1 commit into
data-apis:mainfrom
NeilGirdhar:one-minus-square

Conversation

@NeilGirdhar

Copy link
Copy Markdown
Contributor

Compute 1 - x**2 as (1 + x) * (1 - x), which avoids catastrophic cancellation when |x| is close to 1. On JAX >= 0.11.2, delegate to jax.lax.one_minus_square, whose derivative is defined as -2x and so stays accurate near zero.

Reference issue

Closes #1050

AI Generation Disclosure

Yes, Claude. I reviewed the change. Please let me know if that's okay.

Compute `1 - x**2` as `(1 + x) * (1 - x)`, which avoids catastrophic
cancellation when `|x|` is close to 1. On JAX >= 0.11.2, delegate to
`jax.lax.one_minus_square`, whose derivative is defined as `-2x` and so
stays accurate near zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add one_minus_square

1 participant