Skip to content

MAINT: ensure zero sign is returned for tangd at multiples of 180 and for cotdg at multiples of 90#153

Open
j-bowhay wants to merge 1 commit into
scipy:mainfrom
j-bowhay:tandg_special
Open

MAINT: ensure zero sign is returned for tangd at multiples of 180 and for cotdg at multiples of 90#153
j-bowhay wants to merge 1 commit into
scipy:mainfrom
j-bowhay:tandg_special

Conversation

@j-bowhay
Copy link
Copy Markdown
Member

Reference issue

towards scipy/scipy#20731

What does this implement/fix?

Ensures the following special values from the IEE spec are returned
image
I will have a follow-up PR for the poles.

Additional information

AI Generation Disclosure

No AI

@j-bowhay
Copy link
Copy Markdown
Member Author

CI failures are unrelated

@dschmitz89 dschmitz89 changed the title MAINT: ensure zero sign is returned for tangd at multiples of 180 and forcotdp at multiples of 90 MAINT: ensure zero sign is returned for tangd at multiples of 180 and for cotdg at multiples of 90 May 20, 2026
Comment thread include/xsf/cephes/tandg.h
Comment on lines 105 to +107
/* modulo 180 */
x = x - 180.0 * std::floor(x / 180.0);
double k = std::floor(x / 180.0);
x = x - 180.0 * k;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to simplify here with std::fmod?

@j-bowhay
Copy link
Copy Markdown
Member Author

It is also worth noting the cotdg is not listed in the IEE standard but it is fairly straight forward to determine what special values it should return based on how tangd is defined. I also checked these against Julia

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.

3 participants