Question: Simplify an expression in special way

Dear Users!

Hope everything going find with you. I want to generate sequence of Spline[i,p], p=1…M as given bellow

restart; M := 3;
for p while p <= M do
(x-x[i])*B[i, p-1]/(x[i+p]-x[i])+(x[i+p+1]-x)*B[i+1, p-1]/(x[i+p+1]-x[i+1]);
B[i, p] := collect(%, [`$`(B[i+s, 0], s = 0 .. M)]);
B[i+1, p] := eval(%, i = i+1)
end do;
for p while p <= M do
Spline[i, p] := B[i, p]
end do

The expression for Spline[i,1] and Spline[i,2] are fine but the expressions of Spline [i,p] p>2 is not in simplified form I got the its simplification like given bellow for Spline[i,3]

Spline[i, 3]:=(x-x[i])^3*B[i, 0]/((x[i+3]-x[i])*(x[i+2]-x[i])*(x[i+1]-x[i]))+(((x-x[i])*(x-x[i]))*(x[i+2]-x)/((x[i+3]-x[i])*(x[i+2]-x[i])*(x[i+2]-x[i+1]))+(x-x[i])*(x[i+3]-x)*(x-x[i+1])/((x[i+3]-x[i])*(x[i+3]-x[i+1])*(x[i+2]-x[i+1]))+(x[i+4]-x)*(x-x[i+1])^2/((x[i+4]-x[i+1])*(x[i+3]-x[i+1])*(x[i+2]-x[i+1])))*B[i+1, 0]+((x-x[i])*(x[i+3]-x)^2/((x[i+3]-x[i])*(x[i+3]-x[i+1])*(x[i+3]-x[i+2]))+(x[i+4]-x)*(x-x[i+1])*(x[i+3]-x)/((x[i+4]-x[i+1])*(x[i+3]-x[i+1])*(x[i+3]-x[i+2]))+((x[i+4]-x)*(x[i+4]-x))*(x-x[i+2])/((x[i+4]-x[i+1])*(x[i+4]-x[i+2])*(x[i+3]-x[i+2])))*B[i+2, 0]+(x[i+4]-x)^3*B[i+3, 0]/((x[i+4]-x[i+1])*(x[i+4]-x[i+2])*(x[i+4]-x[i+3]));

I am waiting for positive respone. Please take care and thanks in advance

Please Wait...