Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

error while assigning variables

Hi. I have the following coding of iteration where I want to find the values of u[1,1], u[1,2], u[1,3] and u[1,4].

u,t,x = var('u t x')
u[1]=x;u[1]
u[2]=x^2-1;u[2]
u[3]=2*x^2+3;u[3]
u[4]=x^3-5;u[4]
g[1]=-x^3-x;g[1]
g[2]=(1/4)*x^5-(1/4)*x^4-(1/2)*x^3-3*x^2-1;g[2]
g[3]=(1/2)*x^6-(31/6)*x^3+2*x^2+3;g[3]
g[4]=x^3-5;g[4]
K2[1,1]=1;K2[1,1]
K2[1,2]=0;K2[1,2]
K2[1,3]=1;K2[1,3]
K2[1,4]=1;K2[1,4]
K2[2,1]=x-1;K2[2,1]
K2[2,2]=t;K2[2,2]
K2[2,3]=0;K2[2,3]
K2[2,4]=-x;K2[2,4]
K2[3,1]=x-t;K2[3,1]
K2[3,2]=0;K2[3,2]
K2[3,3]=0;K2[3,3]
K2[3,4]=-3*t^2;K2[3,4]
K2[4,1]=2*x-3;K2[4,1]
K2[4,2]=0;K2[4,2]
K2[4,3]=0;K2[4,3]
K2[4,4]=0;K2[4,4]
for i in range(1,4):
    u[i,1]=-h*sum(integrate(K2[i,j]*g[j]),j,1,4);u[i,1]
for i in range(1,4):
        u[i,2]=(1+h)*u[i,1]-h*sum(integrate(K2[i,j]*u[j,1]),j,1,4);u[i,2]

But it gave me an error saying that: 'sage.symbolic.expression.Expression' object does not support item assignment Can someone explain to me what I might be doing wrong here.