Question: How do I handle the Rational Expression to obtain the desired result?

The rational expression at the beginning of the code is approximant. p1-p5 are conditions imposed on t, and are to be solved simultaneously to obtain a[0]-a[4] which are then substituted into t to obtain Cf. S1-S4 are to be obtained from Cf and its derivative.

However, I observed that Cf is not providing the desired results. What have I done wrong? Please Can someone be of help?

Thank you and kind regards

 

restart:
t:=sum(a[j]*x^j,j=0..2)/sum(a[j]*x^j,j=3..4):
F:=diff(t,x,x):
p1:=simplify(eval(t,x=q))=y[n]:
p2:=simplify(eval(t,x=q+h))=y[n+1]:
p3:=simplify(eval(F,x=q))=f[n]:
p4:=simplify(eval(F,x=q+h))=f[n+1]:
p5:=simplify(eval(F,x=q+2*h))=f[n+2]:
vars:= seq(a[i],i=0..4):
Cc:=eval(<vars>, solve({p||(1..5)}, {vars}));
for i from 1 to 5 do
	a[i-1]:=Cc[i]:
end do:
Cf:=t;
M:=diff(Cf,x):
s4:=y[n+2]=collect(simplify(eval(Cf,x=q+2*h)),[y[n],y[n+1],f[n],f[n+1],f[n+2]], recursive);
s3:=h*delta[n]=collect(h*simplify(eval(M,x=q)),{y[n],y[n+1],f[n],f[n+1],f[n+2]},factor);
s2:=h*delta[n+1]=collect(h*simplify(eval(M,x=q+h)),{y[n],y[n+1],f[n],f[n+1],f[n+2]},factor):
s1:=h*delta[n+1]=collect(h*simplify(eval(M,x=q+2*h)),{y[n],y[n+1],f[n],f[n+1],f[n+2]},factor):

 

Please Wait...