Skip to content
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

[GSoC] Functions: Fixes incorrect evaluation caused due to subfactorial in limit_seq expression #19515

Merged
merged 4 commits into from
Jun 9, 2020

Conversation

sachin-4099
Copy link
Contributor

@sachin-4099 sachin-4099 commented Jun 8, 2020

Fixes: #9308

Brief description of what is fixed or changed

Incorrect limit_seq evaluation takes place because of subfactorial in limit_seq expression.

Ideally, we should have _eval_rewrite_as_factorial() and _eval_rewrite_as_gamma() functionalities for subfactorial.

This is implemented using the equation:

image

For further details: https://en.wikipedia.org/wiki/Derangement#Limit_of_ratio_of_derangement_to_permutation_as_n_approaches_%E2%88%9E

After this, we can simply rewrite the subfactorial term present in limit_seq expression to gamma, so that the evaluations take place correctly.

Other Comments

Regression Test has been added.

Release Notes

  • functions
    • Adds _eval_rewrite_as_factorial() and _eval_rewrite_as_gamma() functionalities for subfactorial

@sympy-bot
Copy link

sympy-bot commented Jun 8, 2020

Hi, I am the SymPy bot (v160). 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:

  • functions
    • Adds _eval_rewrite_as_factorial() and _eval_rewrite_as_gamma() functionalities for subfactorial (#19515 by @sachin-4099)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

Fixes: #9308

#### Brief description of what is fixed or changed

**Incorrect limit_seq evaluation** takes place because of **subfactorial in limit_seq expression.**

Ideally, we should have `_eval_rewrite_as_factorial()` and `_eval_rewrite_as_gamma()`  functionalities for `subfactorial`.

This is implemented using the equation:

![image](https://user-images.githubusercontent.com/46645803/84059488-56a67100-a9d8-11ea-9705-fbea54aece7c.png)

For further details: https://en.wikipedia.org/wiki/Derangement#Limit_of_ratio_of_derangement_to_permutation_as_n_approaches_%E2%88%9E

After this, we can simply rewrite the `subfactorial` term present in `limit_seq expression` to `gamma`, so that the evaluations take place correctly.

#### Other Comments
Regression Test has been added.


#### Release Notes


<!-- BEGIN RELEASE NOTES -->
* functions
  * Adds `_eval_rewrite_as_factorial()` and `_eval_rewrite_as_gamma()`  functionalities for `subfactorial`
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@sachin-4099 sachin-4099 changed the title [GSoC] Functions: Fixes incorrect evaluation caused due to subfactorial in limit expression [GSoC] Functions: Fixes incorrect evaluation caused due to subfactorial in limit_seq expression Jun 8, 2020
@codecov
Copy link

codecov bot commented Jun 8, 2020

Codecov Report

Merging #19515 into master will decrease coverage by 0.000%.
The diff coverage is 63.636%.

@@              Coverage Diff              @@
##            master    #19515       +/-   ##
=============================================
- Coverage   75.690%   75.689%   -0.001%     
=============================================
  Files          653       653               
  Lines       169873    169884       +11     
  Branches     40059     40059               
=============================================
+ Hits        128577    128584        +7     
- Misses       35686     35689        +3     
- Partials      5610      5611        +1     

@jksuom jksuom merged commit 2182b0c into sympy:master Jun 9, 2020
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.

limit(subfactorial(n)/factorial(n), n, oo) returns wrong result
3 participants