Do you think this is something I could work on and help out with? Is it of 
interest to the maintainers? If so I could create a GH issue about it.

As an alternavice could anyone suggest a nice dynamical systems focused 
libraries based on sympy that could improve on this?

On Tuesday, February 11, 2025 at 12:14:40 PM UTC+8 Plamen Dimitrov wrote:

> One more important observation here: sympy can in fact handle different 
> index symbols in the case of differentiation just fine
> ```
> expr1 = x*y + sp.sin(x)**2
> der1ij = sp.diff(expr1, x.subs(i, j))
> # result: 2*sin(x[i])*cos(x[i])*KroneckerDelta(i, j) + KroneckerDelta(i, 
> j)*y[i]
> ```
> as I guess it will assume any "x" symbol can still depend on "x_i" even if 
> we differentiate with respect to "x_j". In other words, it supports the 
> possibility of i=j while integration does not. This means that there is 
> lack of symmetry in expectation of supported functionality between 
> integration and differentiation, I assume mostly because the Kroenecker 
> delta approach is only possible for differentiation. I assume there is no 
> way we can achieve something similar for integration here?
> On Tuesday, February 11, 2025 at 11:28:48 AM UTC+8 Plamen Dimitrov wrote:
>
>> > You have to explicitly tell that indexed variables can overlap and 
>> intersect.
>>
>> I see, I had similar thoughts for explicit splits but was hoping there 
>> might be some automation on the side of sympy for this way. Indeed I guess 
>> this could stretch too much what sympy should do for us and a split remains 
>> viable solution for simple enough cases. I believe there could be more 
>> complex equations out there where such explicit split might not be easily 
>> possible (in addition to slightly harmed readability from a shorter form of 
>> each equation) but have to reach this point first to confirm. In any case, 
>> thanks for the quick reply!
>>
>> On Saturday, February 1, 2025 at 5:13:24 AM UTC+8 [email protected] 
>> wrote:
>>
>>> You have to explicitly tell that indexed variables can overlap and 
>>> intersect. Maybe this code fetches you the desired result,
>>> Try to split the sum into parts 
>>>
>>> dF_dxi = x[i] + sp.Sum(x[j], (j, 1, i-1)) + sp.Sum(x[j], (j, i+1, C)) + 
>>> x[i]
>>> #outpur: (Sum(x[j], (j, 1, i - 1)) + Sum(x[j], (j, i + 1, C)))*x[i] + 
>>> x[i]**2
>>>
>>> On Tuesday, 28 January 2025 at 15:10:22 UTC+5:30 [email protected] wrote:
>>>
>>>> Hi, does anyone know how to properly integrate this indexed sum for an 
>>>> xi term that is also present in the sum indexed by j below?
>>>> ```
>>>> i, j, C = sp.symbols('i, j, k, C', integer=True)
>>>> x = sp.IndexedBase('x')
>>>> dF_dxi = x[i] + sp.Sum(x[j], (j, 1, C))
>>>> Fxi = sp.integrate(dF_dxi, x[i])
>>>> # result: x[i]**2/2 + x[i]*Sum(x[j], (j, 1, C))
>>>> ```
>>>> It seems the integration does not realize that one of the xj terms in 
>>>> the sum is an xi since it assumes the indices don't ever intersect even 
>>>> though these are both defined as integers.
>>>>
>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/sympy/309d7b45-89f0-422c-b890-dc1c031c79ean%40googlegroups.com.

Reply via email to