stan-dev / stan-dev/math

add `cospi()`, `sinpi()`, `tanpi()`

Open
#2,376 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Stan math contains numerically stable versions of functions in error prone areas such as log1p, I suggest wrapping Boost's implementations of cospi(), sinpi(), tanpi(). These are useful when the input is a multiple of 0.5.

For example,

> stanFunction("cos", x = c(pi * 0.5, pi * 1.5)) # compiles and returns non-zero values
[1]  6.123234e-17 -1.836970e-16
> cospi(c(0.5, 1.5))
[1] 0 0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating Stan Math's existing numerically stable wrappers, such as log1p, and the entry points used to wrap Boost implementations. Add cospi(), sinpi(), and tanpi() with behavior that is exact or stable for inputs that are multiples of 0.5, then verify results like cospi(0.5) and cospi(1.5) against the examples in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.