shafay :
I am trying to pass image1 in my code when i copy and paste this as text it looks like this ∑(i=1,n)(a+m*x*(i)-y*(i))^2
.
but it does not work.
following is my code which is working with a different syntax:
from sympy import symbols,sympify,solve,Eq,Symbol
from sympy import symbols,Eq,sympify,summation
expr = **('summation((m * x*(i) + a - y*(i))^2, (i, 0, n))')**
Eq1 = Eq(sympify(expr))
print(Eq1)
values = {2001,10,2,3,5}
arr_symbols = list(Eq1.free_symbols)
print(arr_symbols)
Method1(arr_symbols,values,expr)
def Method1(arr_symbols,Values,expr):
from sympy import symbols, Eq, solve, pprint, integrate, sympify
z = symbols('z')
Formula = Eq(sympify(expr),z)
print(Formula)
index = 0
for i in Values:
Formula = Formula.subs(arr_symbols[index],i)
index+=1
print(solve(Formula))
but what i want to do is to use ∑(i=1,n)(a+m*x*(i)-y*(i))^2
and ask sympy to convert it for me.
shafay :
it cannot be done. we have to pass latex code.
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=220280&siteId=1