Skip to content

Implement sin and cos#4

Merged
timholy merged 2 commits into
mainfrom
tmm/sincos
Jul 15, 2026
Merged

Implement sin and cos#4
timholy merged 2 commits into
mainfrom
tmm/sincos

Conversation

@tmcgrath325

Copy link
Copy Markdown
Collaborator

This implements sin and cos for GVar. Since the resulting distributions are not Gaussians, these will return a new GVar that approximates the target distribution by matching its mean and variance.

One thing to note is that the center of sin(a) is not necessarily equal to sin(a.center) (and the same goes for cos). A derivation and some tests of the result against empirical solutions can be found here.

@timholy

timholy commented Apr 18, 2025

Copy link
Copy Markdown
Member

Thanks! This looks great, the only things this needs are tests. I've added a general-purpose harness in #5 and improved it in #6. (Note that the implementation of exp also changed, and that might have an impact on some of the things you're using this for? In general I suspect the bounds are wider than previously.)

If you rebase this PR on current main, hopefully that should make the tests very easy to implement.

tmcgrath325 and others added 2 commits July 15, 2026 00:38
`sin` and `cos` of a `GVar` return the exact first three moments of the
transformed Gaussian, obtained from its characteristic function, and
propagate the reliability diagnostics as `exp` does. `sincos` returns the
pair.

Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
@timholy timholy merged commit b007529 into main Jul 15, 2026
2 checks passed
@timholy timholy deleted the tmm/sincos branch July 15, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants