Question: How do I fix the (fprintf) number expected for floating point format?

#Clear memory.
restart;

#Initialise variables and arrays.
h:=0.1;
n:=10;
x:=Array(0..n):
y:=Array(0..n):
x[0]:=0;
y[0]:=2;
yd:=-1;

#Initialise the x array.
for i from 1 to n do
    x[i]:=x[0]+i*h;
end do:

#Calculate the first y value.
y[1]:=(203*y[0]-22*yd+4)/220:

#Calculate the remaining y values.
for i from 1 to n-1 do
    y[i+1]:=203*y[i]-110*y[i-1]+4*exp^(-3*x[i])/110;
end do:

#Display the x and y arrays.
printf("1D Explicit Finite Difference Method\n");
printf("------------------------------------\n");
printf("x\t\ty\n");
for i from 0 to n do
     printf("%f\t %f\n",x[i],y[i]);
end do;

 

.1

 

10

 

0

 

2

 

-1

 

1D Explicit Finite Difference Method
------------------------------------
x                y
0.000000         2.000000
0.100000         1.963636
0.200000         

 

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

 

NULL

Download Asst_2_Q1c.mw

I dont understand the cause of this error, can anyone please assist?

Please Wait...