Question: Error - final value in loop must be numeric or character

The x region is z<x<1 and y region is 0<y<pi//3, I think there is an error in the j values in the loop

Can anyone assist please?

#Clear memory.
restart;

#Initialise variables and arrays.
h:=0.1;
k:=Pi/30;
c:=1:
iter:=0:
tol:=1e-5;
w:=1.5;
u:=Array(0..10,0..10):
U:=Array(0..10,0..10):

#Calculate boundary u values.
for i from 0 to 10 do

   u[i,Pi/3]:=0;
   u[i,0]:=0;
end do:

for j from 0 to Pi/3 do
   u[0,j]:=0;   
   u[10,j]:=sin(3*j*k)/2;
end do:
#Perform the Gauss-Seidel method.
while c>tol do
   iter:=iter+1;
   if iter>99 then
      printf("\nGauss-Seidel method did not converge,change w.\n");
   break;
end if:
for i from 1 to 9 do
  for j from 0 to Pi/3 do
     U[i,j]:=u[i,j];
     u[i,j]:=(10*Pi^2*u[i-1,j]+9*u[i,j-1]+9*u[i,j+1]+2*Pi^2*u[i+1,j])/20;
     u[i,j]:=w*u[i,j]+(1-w)*U[i,j];
  end do:
end do:
c:=max(abs(u[1..9,1..9]-U[1..9,1..9]));
printf("After iteration %2d,the maximum change in u is %7.1e\n",iter,c);
end do:

#Display the final u values if method converged.
if iter<100 then
    printf("\nGauss-Seidel Method\n");
    printf("-------------------\n");
    for j from 10 by -1 to 0 do
      for i from 0 to 10 do
        printf("%6.4f",u[i,j]);
    end do:
    printf("\n");
end do:
end if:

.1

 

(1/30)*Pi

 

0.1e-4

 

1.5

 

Error, bad index into Array

 

Error, final value in for loop must be numeric or character

 

Error, final value in for loop must be numeric or character

 


Gauss-Seidel Method
-------------------
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000
0.00000.00000.00000.00000.00000.00000.00000.00000.00000.00000.0000

 

NULL

Download Asst_3_Q3c.mw

Please Wait...