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

Make binomial(x,m) work for symbolic expressions when x-m is an integer #628

Closed
pdenapo mannequin opened this issue Sep 9, 2007 · 9 comments
Closed

Make binomial(x,m) work for symbolic expressions when x-m is an integer #628

pdenapo mannequin opened this issue Sep 9, 2007 · 9 comments

Comments

@pdenapo
Copy link
Mannequin

pdenapo mannequin commented Sep 9, 2007

Currently binomial(x,m) works for symbolic expressions if m is integer, for example

sage: n=var('n')
sage: binomial(n,2)
(n - 1)*n/2 

but binomial (n,n-2) or binomial(n+1,n-1) does not work.

I'm submitting a patch for making this work, by defining

binomial(x,m) = binomial (x,x-m)

when x-m is an integer.

This would be consistent with the way in which maxima handles the binomial function
(see http://maxima.sourceforge.net/docs/manual/en/maxima_31.html#SEC126)

Note that the proposed rule makes sense when x is an integer. However, Sage does not have
a way to specify a domain for a symbolic variable (as for example Axiom does).

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/628

@pdenapo pdenapo mannequin added this to the sage-2.9 milestone Sep 9, 2007
@pdenapo
Copy link
Mannequin Author

pdenapo mannequin commented Sep 9, 2007

Attachment: binomial_symbolic.patch.gz

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Sep 9, 2007

comment:1

This seems pretty nice, it has doctests, so let's shoot for 2.8.4.2.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-2.9, sage-2.8.4.2 Sep 9, 2007
@sagetrac-jbmohler
Copy link
Mannequin

sagetrac-jbmohler mannequin commented Sep 10, 2007

comment:3

Yes, I'll referee this patch...and comment after I'm done.

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Sep 10, 2007

comment:4

I'm slightly concerned about overheads on this one. By far the most common case for binomials is integer arguments. Already PARI beats Magma on the actual hard part of the computation, e.g.

> time for i := 1 to 10000 do x := Binomial(500, 250); end for;  
Time: 1.550
sage: time for i in range(10000): x = binomial(500, 250)
Wall time: 0.52

BUT the overheads are already an issue for smaller problems:

> time for i := 1 to 100000 do x := Binomial(20, 13); end for; 
Time: 0.070
sage: time for i in range(100000): x = binomial(20, 13)
Wall time: 2.82

Perhaps this should be a new ticket, "add fast pathway for binomials of integer arguments"?

@sagetrac-jbmohler
Copy link
Mannequin

sagetrac-jbmohler mannequin commented Sep 10, 2007

comment:5

I import'ed this patch and made a few tweaks to the doc-string.

  • Doc-tests pass
  • Speed does not suffer for the "fast path" integer case (and I can't see why it should from the changes)

The only thing that gives me cause for pause is
sage: binomial(5/2,3/2)
5/2
but that only potential complaint is that this should be undefined so I don't think this is a big issue. You could have already done similar tricks with symbolic inputs and substitution.

dmharvey's speed comments are legit, but are not affected by this patch and are not at all unique to this function. I'm going to write sage-devel about that.

I've attached my patches with revised doc-strings and they pass my referee inspection.

--
Joel

@sagetrac-jbmohler
Copy link
Mannequin

sagetrac-jbmohler mannequin commented Sep 10, 2007

comment:6

Oops, sorry about the bad formatting:

This is the only code snippet which concerned me in the post-patch sage, but I've explained above why I don't think this matters.

sage: binomial(5/2,3/2)
5/2

@sagetrac-jbmohler
Copy link
Mannequin

sagetrac-jbmohler mannequin commented Sep 10, 2007

Attachment: binomial_patch.hg.gz

hg bundle including the patch file and my doc-string revisions

@williamstein

This comment has been minimized.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Sep 11, 2007

comment:8

At least some of this has been merged. See

http://www.sagemath.org/hg/sage-main/rev/8def8d03e4a2

Is there more to come or can we close this ticket?

Cheers,

Michael

vbraun pushed a commit that referenced this issue Mar 26, 2023
    
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-
action) from 2 to 3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/codecov/codecov-
action/releases">codecov/codecov-action's releases</a>.</em></p>
<blockquote>
<h2>v3.0.0</h2>
<h3>Breaking Changes</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/689">#689</a> Bump to node16 and small fixes</li>
</ul>
<h3>Features</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/688">#688</a> Incorporate <code>gcov</code> arguments for
the Codecov uploader</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/548">#548</a> build(deps-dev): bump jest-junit from 12.2.0
to 13.0.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/603">#603</a> [Snyk] Upgrade <code>@​actions/core</code>
from 1.5.0 to 1.6.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/628">#628</a> build(deps): bump node-fetch from 2.6.1 to
3.1.1</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/634">#634</a> build(deps): bump node-fetch from 3.1.1 to
3.2.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/636">#636</a> build(deps): bump openpgp from 5.0.1 to
5.1.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/652">#652</a> build(deps-dev): bump
<code>@​vercel/ncc</code> from 0.30.0 to 0.33.3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/653">#653</a> build(deps-dev): bump
<code>@​types/node</code> from 16.11.21 to 17.0.18</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/659">#659</a> build(deps-dev): bump
<code>@​types/jest</code> from 27.4.0 to 27.4.1</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/667">#667</a> build(deps): bump actions/checkout from 2 to
3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/673">#673</a> build(deps): bump node-fetch from 3.2.0 to
3.2.3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/683">#683</a> build(deps): bump minimist from 1.2.5 to
1.2.6</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/685">#685</a> build(deps): bump
<code>@​actions/github</code> from 5.0.0 to 5.0.1</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/681">#681</a> build(deps-dev): bump
<code>@​types/node</code> from 17.0.18 to 17.0.23</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/682">#682</a> build(deps-dev): bump typescript from 4.5.5
to 4.6.3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/676">#676</a> build(deps): bump
<code>@​actions/exec</code> from 1.1.0 to 1.1.1</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/675">#675</a> build(deps): bump openpgp from 5.1.0 to
5.2.1</li>
</ul>
<h2>v2.1.0</h2>
<h2>2.1.0</h2>
<h3>Features</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/515">#515</a> Allow specifying version of Codecov
uploader</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/499">#499</a> build(deps-dev): bump
<code>@​vercel/ncc</code> from 0.29.0 to 0.30.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/508">#508</a> build(deps): bump openpgp from 5.0.0-5 to
5.0.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/514">#514</a> build(deps-dev): bump
<code>@​types/node</code> from 16.6.0 to 16.9.0</li>
</ul>
<h2>v2.0.3</h2>
<h2>2.0.3</h2>
<h3>Fixes</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/464">#464</a> Fix wrong link in the readme</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/485">#485</a> fix: Add override OS and linux default to
platform</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/447">#447</a> build(deps): bump openpgp from 5.0.0-4 to
5.0.0-5</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/458">#458</a> build(deps-dev): bump eslint from 7.31.0 to
7.32.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/465">#465</a> build(deps-dev): bump <code>@​typescript-
eslint/eslint-plugin</code> from 4.28.4 to 4.29.1</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/466">#466</a> build(deps-dev): bump <code>@​typescript-
eslint/parser</code> from 4.28.4 to 4.29.1</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/468">#468</a> build(deps-dev): bump
<code>@​types/jest</code> from 26.0.24 to 27.0.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/470">#470</a> build(deps-dev): bump
<code>@​types/node</code> from 16.4.0 to 16.6.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/472">#472</a> build(deps): bump path-parse from 1.0.6 to
1.0.7</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/473">#473</a> build(deps-dev): bump
<code>@​types/jest</code> from 27.0.0 to 27.0.1</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/codecov/codecov-
action/blob/main/CHANGELOG.md">codecov/codecov-action's
changelog</a>.</em></p>
<blockquote>
<h2>3.1.1</h2>
<h3>Fixes</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/661">#661</a> Update deprecation warning</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/593">#593</a> Create codeql-analysis.yml</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/712">#712</a> README: fix typo</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/725">#725</a> fix: Remove a blank row</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/726">#726</a> Update README.md with correct badge
version</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/633">#633</a> Create scorecards-analysis.yml</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/747">#747</a> fix: add more verbosity to validation</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/750">#750</a> Regenerate scorecards-analysis.yml</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/774">#774</a> Switch to v3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/783">#783</a> Fix network entry in table</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/791">#791</a> Trim arguments after splitting them</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/769">#769</a> Plumb failCi into verification
function.</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/713">#713</a> build(deps-dev): bump typescript from 4.6.3
to 4.6.4</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/714">#714</a> build(deps): bump node-fetch from 3.2.3 to
3.2.4</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/724">#724</a> build(deps): bump github/codeql-action from
1 to 2</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/717">#717</a> build(deps-dev): bump
<code>@​types/jest</code> from 27.4.1 to 27.5.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/729">#729</a> build(deps-dev): bump
<code>@​types/node</code> from 17.0.25 to 17.0.33</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/734">#734</a> build(deps-dev): downgrade
<code>@​types/node</code> to 16.11.35</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/723">#723</a> build(deps): bump actions/checkout from 2 to
3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/733">#733</a> build(deps): bump
<code>@​actions/github</code> from 5.0.1 to 5.0.3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/732">#732</a> build(deps): bump
<code>@​actions/core</code> from 1.6.0 to 1.8.2</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/737">#737</a> build(deps-dev): bump
<code>@​types/node</code> from 16.11.35 to 16.11.36</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/749">#749</a> build(deps): bump ossf/scorecard-action from
1.0.1 to 1.1.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/755">#755</a> build(deps-dev): bump typescript from 4.6.4
to 4.7.3</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/759">#759</a> build(deps-dev): bump
<code>@​types/node</code> from 16.11.36 to 16.11.39</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/762">#762</a> build(deps-dev): bump
<code>@​types/node</code> from 16.11.39 to 16.11.40</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/746">#746</a> build(deps-dev): bump
<code>@​vercel/ncc</code> from 0.33.4 to 0.34.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/757">#757</a> build(deps): bump ossf/scorecard-action from
1.1.0 to 1.1.1</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/760">#760</a> build(deps): bump openpgp from 5.2.1 to
5.3.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/748">#748</a> build(deps): bump actions/upload-artifact
from 2.3.1 to 3.1.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/766">#766</a> build(deps-dev): bump typescript from 4.7.3
to 4.7.4</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/799">#799</a> build(deps): bump openpgp from 5.3.0 to
5.4.0</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/798">#798</a> build(deps): bump
<code>@​actions/core</code> from 1.8.2 to 1.9.1</li>
</ul>
<h2>3.1.0</h2>
<h3>Features</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/699">#699</a> Incorporate <code>xcode</code> arguments for
the Codecov uploader</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/694">#694</a> build(deps-dev): bump
<code>@​vercel/ncc</code> from 0.33.3 to 0.33.4</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/696">#696</a> build(deps-dev): bump
<code>@​types/node</code> from 17.0.23 to 17.0.25</li>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/698">#698</a> build(deps-dev): bump jest-junit from 13.0.0
to 13.2.0</li>
</ul>
<h2>3.0.0</h2>
<h3>Breaking Changes</h3>
<ul>
<li><a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/689">#689</a> Bump to node16 and small fixes</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="codecov/codecov-action@d9f34f8cd5
cb3b3eb79b3e4b5dae3a16df499a70"><code>d9f34f8</code></a> release: update
changelog and version to 3.1.1 (<a href="https://github-
redirect.dependabot.com/codecov/codecov-
action/issues/828">#828</a>)</li>
<li><a href="codecov/codecov-action@0e9e7b4e8a
4cbde89b1d36ffe91a812536089d02"><code>0e9e7b4</code></a> Plumb failCi
into verification function. (<a href="https://github-
redirect.dependabot.com/codecov/codecov-
action/issues/769">#769</a>)</li>
<li><a href="codecov/codecov-action@7f20bd4c41
51750a1d013be0901b7e35a46c2aad"><code>7f20bd4</code></a> build(deps):
bump <code>@​actions/core</code> from 1.8.2 to 1.9.1 (<a
href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/798">#798</a>)</li>
<li><a href="codecov/codecov-action@13bc2536ab
285b021e72dfb3cd53e56f5c1f4e26"><code>13bc253</code></a> build(deps):
bump openpgp from 5.3.0 to 5.4.0 (<a href="https://github-
redirect.dependabot.com/codecov/codecov-
action/issues/799">#799</a>)</li>
<li><a href="codecov/codecov-action@5c0da1b28f
1c589bf17db0088d610ae638f4ccb7"><code>5c0da1b</code></a> Trim arguments
after splitting them (<a href="https://github-
redirect.dependabot.com/codecov/codecov-
action/issues/791">#791</a>)</li>
<li><a href="codecov/codecov-action@68d5f6d0be
32fb7f92b47e97218cf01690e6e3b5"><code>68d5f6d</code></a> Fix
<code>network</code> entry in table (<a href="https://github-
redirect.dependabot.com/codecov/codecov-
action/issues/783">#783</a>)</li>
<li><a href="codecov/codecov-action@2a829b95de
aeea2d11d127cc0358005714ff35ea"><code>2a829b9</code></a> Switch to v3
(<a href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/774">#774</a>)</li>
<li><a href="codecov/codecov-action@8e09eaf1b4
7fbb5da0e32a27bf08cd11929a1b4a"><code>8e09eaf</code></a> build(deps-
dev): bump typescript from 4.7.3 to 4.7.4 (<a href="https://github-
redirect.dependabot.com/codecov/codecov-
action/issues/766">#766</a>)</li>
<li><a href="codecov/codecov-action@39e222921f
d6f8ff1aae5c56948ff1599a2b57d1"><code>39e2229</code></a> build(deps):
bump actions/upload-artifact from 2.3.1 to 3.1.0 (<a
href="https://github-redirect.dependabot.com/codecov/codecov-
action/issues/748">#748</a>)</li>
<li><a href="codecov/codecov-action@b2b7703473
2e1f073c09521d4f31f4db18b099e2"><code>b2b7703</code></a> build(deps):
bump openpgp from 5.2.1 to 5.3.0 (<a href="https://github-
redirect.dependabot.com/codecov/codecov-
action/issues/760">#760</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/codecov/codecov-action/compare/v2...v3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-
badges.githubapp.com/badges/compatibility_score?dependency-
name=codecov/codecov-action&package-manager=github_actions&previous-
version=2&new-version=3)](https://docs.github.com/en/github/managing-
security-vulnerabilities/about-dependabot-security-updates#about-
compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
    
URL: #35183
Reported by: dependabot[bot]
Reviewer(s): Tobias Diez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant