Question: How do I fix error in Array?

Can anyone please assist with these errors?

#Clear memory.
restart;

#Initialise variables and arrays.
h:=Pi/10;
n:=10;
k:=0.1;  
m:=6;
t:=Array(0..m):
x:=Array(0..n):
u:=Array(0..n,0..m):

#Initialise the x array and the initial u(x,0) boundary.
for i from 0 to n do
    x[i]:=i*h;
    u[i,0]:=0;
end do:

#Initialise the t array and the u(x,t) side boundaries.
for j from 0 to m do
   t[j]:=j*k;
   u[0,j]:=0;
   u[n,j]:=3*sin*t[j];
end do:

#Use the 2D CTCS explicit wave method.
for i from 1 to n-1 do
   u[i,1]:=(u[i-1,0]/2*Pi^2+sin(x)/10*Pi^2+u[i+1,0]/2*Pi^2)-1;
end do:
 
for j from 1 to m-1 do
  for i from 1 to n-1 do
   u[i,j+1]:=(((u[i-1,j]+u[i+1,j]-u[i,j-1])/Pi^2)-2);
  end do;
end do:

#Display the u(x,t)values.
printf("2D CTCS Explicit Wave Method\n");
printf("----------------------------\n");
printf("x\t\t t\t\t u\n");
for i from 0 to n do
   printf("% f\t% f\t% f\n",x[i],t[m],u[i,m]);
end do;

(1/10)*Pi

 

10

 

.1

 

6

 

Error, invalid input: sin expects its 1st argument, x, to be of type algebraic, but received Array(0..10, [0,1/10*Pi,1/5*Pi,3/10*Pi,2/5*Pi,1/2*Pi,3/5*Pi,7/10*Pi,4/5*Pi,9/10*Pi,Pi])

 

2D CTCS Explicit Wave Method
----------------------------
x                 t                 u
 0.000000         0.600000         0.000000
 0.314159         0.600000        -2.015556
 0.628319         0.600000        -2.198509
 0.942478         0.600000        -2.215724
 1.256637         0.600000        -2.218015
 1.570796         0.600000        

 

Error, (in fprintf) number expected for floating point format

 

NULL


Download Asst_4_Question_2c.mw

Please Wait...