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

Derivatives of indexed objects #11144

Merged
merged 7 commits into from
Jun 3, 2016
Merged

Derivatives of indexed objects #11144

merged 7 commits into from
Jun 3, 2016

Conversation

Upabjojr
Copy link
Contributor

@Upabjojr Upabjojr commented May 21, 2016

This PR provides derivatives for indexed objects.

It is roughly based on #9314 , except that

  • here the standard KroneckerDelta is used (no secondary class to represent the Kronecker delta).
  • no implicit summation of repeated indices is assumed for the derivative, the code printer instead behaves exactly the same. That is, no API breaks.
  • Derivatives of Sum objects of indexed symbols are supported.

@Upabjojr
Copy link
Contributor Author

#9314

@Upabjojr
Copy link
Contributor Author

@bjodah @moorepants @jcrist @asmeurer

What do you think? This partially includes stuff from the PR by @joshburkart .

Unlike in @joshburkart 's PR, code printers have not been changed (this may be done in the future). Support for derivatives of indexed objects has been added. Sum objects are also supported.

@bjodah
Copy link
Member

bjodah commented May 23, 2016

Excellent! +1

@Upabjojr
Copy link
Contributor Author

I would like to merge this as soon as possible. Are there objections?

@Upabjojr
Copy link
Contributor Author

If no objections arise, I'll merge this in one week.

@Upabjojr Upabjojr merged commit 816c3b7 into sympy:master Jun 3, 2016
@Upabjojr Upabjojr mentioned this pull request Jun 8, 2016
if symbol_set.difference(expr.free_symbols):
from sympy import IndexedBase
symbol_set = set(sc[0].base if sc[0].is_Indexed else sc[0] for sc in variable_count if sc[0].is_Symbol)
if symbol_set.difference(expr.free_symbols).difference(expr.atoms(IndexedBase)):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmeurer this was the trick to allow A[i].diff(A[j]). This is an optimization, it checks whether the deriving varible is contained in the expression, otherwise return zero (i.e. deriving a constant).

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.

3 participants