# Question:how to reduce code

## Question:how to reduce code

Maple 13

f:=x->x^3:
y[1]:=0.5:
y[3]:=subs(x=y[1],f(x)):
i := 2:
y[i] := y[i-1]-(y[1]-y[2+1])*(1/2):
i:=1:
g[i] := (y[i+1]-y[i+2])*x/(y[i]-y[i+1])+(y[i+2]*y[i]-y[i+1]*y[i+1])/(y[i]-y[i+1]):
g[i] := unapply(g[i], x):
h[i] := unapply(solve(y = g[i](x), x), y):
for i from 2 by 1 to 7 do
g[i]:=(f@h[i-1])(x);
g[i]:=unapply(g[i],x);
y[i+2]:=subs(x=y[i+1],g[i](x));
s:=solve(z=g[i](x),x);
h[i]:=unapply(s[1],z);
end do:

for i from -1 by -1 to -8 do
if (i=-1)then
g[i]:=(h[i+2]@f)(x);
g[i]:=unapply(g[i],x);
s:=solve(z=g[i](x),x);
h[i]:=unapply(s[1],z);
y[i]:=subs(x=y[i+2],h[i](x));
else
g[i]:=(h[i+1]@f)(x);
g[i]:=unapply(g[i],x);
s:=solve(z=g[i](x),x);
h[i]:=unapply(s[1],z);
y[i]:=subs(x=y[i+1],h[i](x));
end if:
end do:

for i from -8 by 1 to -1 do
printf("g[%d](x)=%a \t", i, g[i](x));
printf("y[%d]=%e \n", i, y[i]);
end do;

for i from 1 by 1 to 7 do
printf("g[%d](x)=%a \t", i, g[i](x));
printf("y[%d]=%e \n", i, y[i]);
end do;

if i take f is x^10 it will take so much time how to reduce code and how exute succussfully. its taking so much time. i dont want much time

i want genaralise and out put in less time

﻿