ARTICLE AD BOX
I'm coding with python for sympy and I need help. I need to add a value which will be on one index into another index of my sympy summation. If the value that needs to be added is not calculated then I just want it to return 0.
My code is:
from sympy import * # Define the symbolic variable x = symbols('x') # Define the expression to sum expr = x+2 expr2 = Piecewise( (1, Eq(expr, 10)), (0, True) ) summation = Sum(expr2, (x, 1, 5)) print("Symbolic Sum:", summation)This is my code so far. I'm trying to make code to better understand algebraic conversions with sympy.
When x is 8 it will be 1. So since only on that index it will be 1 I want to add 1 to a different index of my choosing (let's just say index 2). I don't want to do it mathematically where you just use a formula and mathematically calculate 1 on that index. I want to actually take the 1 on index 8 and put it on index 2.
So basically if any index equals 1 then index 2 also becomes 1. ANd guys I can't use any loops or recursion.
2
