I need to subs a numpy.array into an indexed symbol of Sympy expression to numerically calculate the sum. (1+2+3+4+5=15). My below code still produce symbolic expression. Please help~
from sympy import *
import numpy as np
i = Symbol("i")
y = Symbol("y")
y_ = np.array([1,2,3,4,5])
h = Sum(Indexed("y","i"),(i,0,4))
h.subs([(y,y_)])
y, is not the same as the Indexedy[i]. They may look related, but they have no connection. As a general rull, usingnumpyandsympydoes not work well. The best tool is to usesympy.lambdifyto generate a numpy compatible function.