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/d63042b5-7e10-4aa7-a472-7462d5c05473n%40googlegroups.com.

Reply via email to