Question: Improving time consuming code

Hi

The following code is time consuming. Please improve the code, if it is possible. Thanks for taking your time

restart;

T := time(): 
M := 50: 
Digits := 30: 
L := 500: 
R := (1/2): 
nu := 0.3: 
Em := 0.70e11: 
N := 1: 
Ec := 0.380e12: 
E:= Em*(1-(y/h+1/2)^N)+Ec*(y/h+1/2)^N: 
X :=(int(E*(z+(1/2)*R), [z = y-(1/2)*R .. 0, y = -(1/2)*R .. (1/2)*R]))/(int(E, [z = y-(1/2)*R .. 0, y = -(1/2)*R .. (1/2)*R])): 
beta := Pi^2/L^2: 
G := E/(2*(1+nu)): 
phi := add(b[n]*y^n, n = 0 .. M): 
Eq := diff(phi, y$2)+(diff(E, y))*(diff(phi, y))/E+((diff(E, y$2))/E-((diff(E, y))/E)^2)*phi-2*beta*(1+nu)*(phi-1): 
st := [seq(coeftayl(Eq, y = 0, j), j = 0 .. M-2)]: 
for k to M-1 do 
b[k+1] := solve(st[k], b[k+1]) 
end do: 
phi := subs(y = y-X, phi): 
phi := subs(solve({eval(phi, y = -(1/2)*R+X), subs(y = f, phi)}, {b[0], b[1]}), phi): 
f := piecewise(`and`(z >= -R, z <= 0), z+(1/2)*R+X, -z+(1/2)*R+X): 
Digits := 4: 
int(phi*G, [z = y-(1/2)*R .. 0, y = -(1/2)*R .. (1/2)*R], numeric)+int(phi*G, [z = 0 .. -y+(1/2)*R, y = -(1/2)*R .. (1/2)*R], numeric);

Time = Time()-T;

Note that the calculation of the integration requires alot of time. Both returns a similar result (calculation of an integration is sufficient)

Please Wait...