Skip to content

Fix atan2(a, a)#1808

Draft
isuruf wants to merge 1 commit into
symengine:masterfrom
isuruf:atan2
Draft

Fix atan2(a, a)#1808
isuruf wants to merge 1 commit into
symengine:masterfrom
isuruf:atan2

Conversation

@isuruf
Copy link
Copy Markdown
Member

@isuruf isuruf commented Jun 20, 2021

No description provided.

r2 = div(mul(pi, i3), integer(-8));
r2 = div(mul(pi, i5), integer(8));
REQUIRE(eq(*r1, *r2));

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.

We should have a test for atan2(x, x)

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.

And also atan2(x, 0) etc to cover symbolic cases where the numerator or denominator could potentially be 0 or complex.

Comment thread symengine/functions.cpp
return add(div(pi, index), mul(div(pi, i2), sub(sign(den), one)));
} else {
return div(pi, index);
return sub(div(pi, index), mul(div(pi, i2), sub(sign(den), one)));
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.

Are complex values of num and den handled by this case?

Comment thread symengine/functions.cpp
else
return div(pi, i2);
}
return mul(div(pi, i2), sign(num));
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.

I don't think this is correct. If we do atan2(x, 0) this will become pi/2 * sign(x), but for x = 0 this is should be NaN. Sympy keeps this case unevaluated as atan2(x, 0).

@isuruf isuruf added this to the 0.10.0 milestone Jun 27, 2022
@isuruf isuruf modified the milestones: 0.10.0, 0.11.0 Mar 20, 2023
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.

2 participants