[sympy] KroneckerDelta in discrete summations and products (#1697)

71 views
Skip to first unread message

Julien Rioux

unread,
Dec 19, 2012, 10:06:21 AM12/19/12
to sympy/sympy

This is a little bit like deltaintegrate is to DiracDelta. Fixes the following issues:

Handle KroneckerDelta in Sum
http://code.google.com/p/sympy/issues/detail?id=3481

Handle KroneckerDelta in Product
http://code.google.com/p/sympy/issues/detail?id=3482


You can merge this Pull Request by running:

  git pull https://github.com/jrioux/sympy concrete

Or view, comment on, or merge it at:

  https://github.com/sympy/sympy/pull/1697

Commit Summary

  • KroneckerDelta is 0 or 1, thus any power returns itself.
  • Handle KroneckerDelta in summations.
  • Handle KroneckerDelta in products.

File Changes

  • M sympy/concrete/__init__.py (1)
  • A sympy/concrete/delta.py (223)
  • M sympy/concrete/products.py (5)
  • M sympy/concrete/summations.py (5)
  • A sympy/concrete/tests/test_delta.py (180)
  • M sympy/functions/special/tensor_functions.py (3)
  • M sympy/functions/special/tests/test_tensor_functions.py (5)

Patch Links


Reply to this email directly or view it on GitHub.

Aaron Meurer

unread,
Dec 19, 2012, 2:11:49 PM12/19/12
to sympy/sympy

Is it possible to reuse the exact same code from deltaintegrate?

Julien Rioux

unread,
Dec 19, 2012, 6:16:43 PM12/19/12
to sympy/sympy

That code was indeed my starting point, and it has morphed into what I pushed here. There are differences that allows to simplify the algorithm. I should add that this is work in progress; the code handles most examples I could come up with, but there are at least a couple wrong results to fix.

Aaron Meurer

unread,
Dec 19, 2012, 7:44:31 PM12/19/12
to sympy/sympy

That code was indeed my starting point, and it has morphed into what I pushed here. There are differences that allows to simplify the algorithm.

Well, at least for the summation case, you should be able to make them exactly the same, if I'm not mistaken, since a summation is an integral when viewed correctly (and the Kronecker delta is the Dirac delta). The biggest difference is that KroneckerDelta takes two arguments whereas DiracDelta takes one. But KroneckerDelta(n - m, 0) is the same as KroneckerDelta(n, m), no?

For products, it probably can't generalize, but the delta formula for products doesn't even seem useful, unless you have something a little more complicated, like Product((1 - KroneckerDelta(n, m))).

I should add that this is work in progress; the code handles most examples I could come up with, but there are at least a couple wrong results to fix.

Maybe add those as tests so that this won't be merged until they are fixed. And by the way, I wouldn't be surprised if there aren't similar issues in deltaintegrate.

Julien Rioux

unread,
Dec 19, 2012, 9:55:37 PM12/19/12
to sympy/sympy

SymPy Bot Summary: :eight_spoked_asterisk: Passed after merging jrioux/concrete (e86edd6) into master (d503614).
:eight_spoked_asterisk:PyPy 2.0.0-beta-1; 2.7.3-final-42: pass
:eight_spoked_asterisk:Python 2.7.2-final-0: pass
:eight_spoked_asterisk:Python 3.2.1-final-0: pass
:eight_spoked_asterisk:Sphinx 1.1.3: pass
Docs build command: make clean && make html-errors && make latex && cd _build/latex && xelatex sympy-*.tex

Aaron Meurer

unread,
Dec 23, 2012, 11:18:17 AM12/23/12
to sympy/sympy

SymPy Bot Summary: :red_circle: Failed after merging jrioux/concrete (e86edd6) into master (8083428).
@jrioux: Please fix the test failures.
:eight_spoked_asterisk:Python 2.5.0-final-0: pass
:eight_spoked_asterisk:Python 2.6.6-final-0: pass
:red_circle:Python 2.7.2-final-0: fail
:eight_spoked_asterisk:Python 2.6.8-final-0: pass
:red_circle:Python 2.7.3-final-0: fail


:eight_spoked_asterisk:PyPy 2.0.0-beta-1; 2.7.3-final-42: pass

:eight_spoked_asterisk:Python 3.2.2-final-0: pass
:eight_spoked_asterisk:Python 3.3.0-final-0: pass
:eight_spoked_asterisk:Python 3.2.3-final-0: pass
:eight_spoked_asterisk:Python 3.3.0-final-0: pass
:eight_spoked_asterisk:Python 3.3.0-final-0: pass
:eight_spoked_asterisk:**Sphinx 1.1.3:** pass

Reply all
Reply to author
Forward
0 new messages