Question: How do I correct this code?

restart;
Digits:=30:

f:=proc(n)
	x[n]-y[n];
	
end proc:


e1:=y[n] = (15592/1575)*h*f(n+5)+(35618816/99225)*h*f(n+9/2)-(4391496/15925)*h*f(n+13/3)-(2035368/13475)*h*f(n+14/3)-(212552/121275)*h*f(n+1)+(10016/11025)*h*f(n+2)-(31672/4725)*h*f(n+3)+(19454/315)*h*f(n+4)-(351518/1289925)*h*f(n)+y[n+4]:
e2:=y[n+1] = -(34107/22400)*h*f(n+5)-(212224/3675)*h*f(n+9/2)+(92569149/2038400)*h*f(n+13/3)+(82333989/3449600)*h*f(n+14/3)-(568893/1724800)*h*f(n+1)-(459807/313600)*h*f(n+2)+(1189/22400)*h*f(n+3)-(50499/4480)*h*f(n+4)+(32951/6115200)*h*f(n)+y[n+4]:
e3:=y[n+2] = (69/175)*h*f(n+5)+(1466368/99225)*h*f(n+9/2)-(13851/1225)*h*f(n+13/3)-(60507/9800)*h*f(n+14/3)+(43/3675)*h*f(n+1)-(3509/9800)*h*f(n+2)-(6701/4725)*h*f(n+3)+(871/420)*h*f(n+4)-(247/396900)*h*f(n)+y[n+4]:
e4:=y[n+3] = -(31411/201600)*h*f(n+5)-(745216/99225)*h*f(n+9/2)+(13557213/2038400)*h*f(n+13/3)+(9737253/3449600)*h*f(n+14/3)-(20869/15523200)*h*f(n+1)+(36329/2822400)*h*f(n+2)-(202169/604800)*h*f(n+3)-(100187/40320)*h*f(n+4)+(14669/165110400)*h*f(n)+y[n+4]:
e5:=y[n+13/3] = -(3364243/1322697600)*h*f(n+5)-(134364928/651015225)*h*f(n+9/2)+(19955023/55036800)*h*f(n+13/3)+(5577703/93139200)*h*f(n+14/3)-(910757/101847715200)*h*f(n+1)+(1336457/18517766400)*h*f(n+2)-(2512217/3968092800)*h*f(n+3)+(31844549/264539520)*h*f(n+4)+(690797/1083289334400)*h*f(n)+y[n+4]:
e6:=y[n+14/3] = -(29107/10333575)*h*f(n+5)+(7757824/651015225)*h*f(n+9/2)+(180667/429975)*h*f(n+13/3)+(342733/2910600)*h*f(n+14/3)-(7253/795685275)*h*f(n+1)+(42467/578680200)*h*f(n+2)-(19853/31000725)*h*f(n+3)+(993749/8266860)*h*f(n+4)+(22037/33852791700)*h*f(n)+y[n+4]:
e7:=y[n+9/2] = -(115447/51609600)*h*f(n+5)-(21389/198450)*h*f(n+9/2)+(231041241/521830400)*h*f(n+13/3)+(43797591/883097600)*h*f(n+14/3)-(32833/3973939200)*h*f(n+1)+(48323/722534400)*h*f(n+2)-(91493/154828800)*h*f(n+3)+(1220071/10321920)*h*f(n+4)+(24863/42268262400)*h*f(n)+y[n+4]:
e8:=y[n+5] = (1989/22400)*h*f(n+5)-(61184/99225)*h*f(n+9/2)+(1496637/2038400)*h*f(n+13/3)+(2458917/3449600)*h*f(n+14/3)+(73/5174400)*h*f(n+1)-(31/313600)*h*f(n+2)+(359/604800)*h*f(n+3)+(1079/13440)*h*f(n+4)-(179/165110400)*h*f(n)+y[n+4]:



h:=0.01:
N:=solve(h*p = 8/8, p):
#N := 10:
#n:=0:
#exy:= [seq](eval(i+exp(-i)-1), i=h..N,h):
c:=1:
inx:=0:
iny:=0:

mx := proc(t,n):
   t + 0.01*n:
end proc:

exy := (x - 1.0 + exp(-x)):

vars := y[n+1],y[n+2],y[n+3],y[n+4],y[n+13/3],y[n+14/3],y[n+9/2],y[n+5]:

printf("%6s%20s%20s%20s\n", "h","numy1","Exact", "Error");
#for k from 1 to N/8 do
for c from 1 to N do

	par1:=x[n]=map(mx,(inx,0)),x[n+1]=map(mx,(inx,1)),
		x[n+2]=map(mx,(inx,2)),x[n+3]=map(mx,(inx,3)),
		x[n+4]=map(mx,(inx,4)),x[n+5]=map(mx,(inx,5)),
		x[n+13/3]=map(mx,(inx,13/3)),x[n+14/3]=map(mx,(inx,14/3)),
		x[n+9/2]=map(mx,(inx,9/2)):
	par2:=y[n]=iny:
	res:=eval(<vars>, fsolve(eval({e||(1..8)},[par1,par2]), {vars}));
	
	printf("%7.3f%22.10f%20.10f%17.3g\n", 
		h*c,res[8],(exy,[x=c*h]),abs(res[8]-eval(exy,[x=c*h]))):
		#c:=c+1:
	
	iny:=res[8]:
	inx:=map(mx,(inx,5)):
end do:

Dear all,

Please Kindly help to correct or modify the code above

Thank you and best regards
 

 

 

Please Wait...