-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added rewrite for trigonometric functions as Besselj #24387
base: master
Are you sure you want to change the base?
Conversation
✅ Hi, I am the SymPy bot (version not found!). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like: This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.12. Click here to see the pull request description that was parsed.
|
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) before after ratio
[41d90958] [c7fe006d]
<sympy-1.11.1^0>
- 2.47±0ms 1.09±0.07ms 0.44 solve.TimeSparseSystem.time_linear_eq_to_matrix(20)
- 4.93±0.01ms 1.61±0.1ms 0.33 solve.TimeSparseSystem.time_linear_eq_to_matrix(30)
Full benchmark results can be found as artifacts in GitHub Actions |
@oscarbenjamin can you have a look? |
There are many people who could review this. It is usually better not to reference a particular person because it tends to discourage others from reviewing. |
Will surely keep that in mind! |
This PR needs to be reviewed. From a very quick skim of the diff it looks reasonable but I haven't checked anything in any detail. |
@@ -532,6 +532,10 @@ def _eval_rewrite_as_sec(self, arg, **kwargs): | |||
def _eval_rewrite_as_sinc(self, arg, **kwargs): | |||
return arg*sinc(arg) | |||
|
|||
def _eval_rewrite_as_besselj(self, arg, **kwargs): | |||
from sympy.functions.special.bessel import besselj | |||
return sqrt(pi*arg/2)*besselj(1*S.Half,arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to write 1*
.
@@ -943,6 +947,10 @@ def _eval_rewrite_as_sec(self, arg, **kwargs): | |||
def _eval_rewrite_as_csc(self, arg, **kwargs): | |||
return 1/sec(arg).rewrite(csc) | |||
|
|||
def _eval_rewrite_as_besselj(self, arg, **kwargs): | |||
from sympy.functions.special.bessel import besselj | |||
return sqrt(pi*arg/2)*besselj(-1*S.Half,arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. This can just be -S.Half
.
@@ -1298,6 +1306,10 @@ def _eval_rewrite_as_sqrt(self, arg, **kwargs): | |||
return None | |||
return y | |||
|
|||
def _eval_rewrite_as_besselj(self, arg, **kwargs): | |||
from sympy.functions.special.bessel import besselj | |||
return (sin(arg).rewrite(besselj)/cos(arg).rewrite(besselj)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass **kwargs
through to recursive rewrite calls.
The formulae here appear to be correct https://dlmf.nist.gov/10.16. |
@@ -217,6 +217,12 @@ def test_sin_rewrite(): | |||
assert sin(x).rewrite(cos) == cos(x - pi / 2, evaluate=False) | |||
assert sin(x).rewrite(sec) == 1 / sec(x - pi / 2, evaluate=False) | |||
assert sin(cos(x)).rewrite(Pow) == sin(cos(x)) | |||
assert sin(x).rewrite(besselj).subs(x,pi/4).n() == sin(x).subs(x,pi/4).n() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use standard PEP 8 whitespace rules here and throughout the diff? This means one space after a comma, like
assert sin(x).rewrite(besselj).subs(x,pi/4).n() == sin(x).subs(x,pi/4).n() | |
assert sin(x).rewrite(besselj).subs(x, pi/4).n() == sin(x).subs(x, pi/4).n() |
References to other Issues or PRs
resolves #24176
Brief description of what is fixed or changed
As mentioned, trigonometric functions were rewritten as Besselj.
Corresponding tests were also added.
Other comments
Release Notes