Question: how i can reduce the runtime of the program ?

hi..how i can rewrite section of this code as another form i,e ''for section''

I have a lot of line as this and runnig cise is time consuming.

is there another way to write this section in order to the runtime of the program is reduced??

thanks

for.mw
 

restart;

with(LinearAlgebra):

with(VectorCalculus):

#Digits:=5:
k:=6:

l:=0:

h:=1:

m:=4:

n:=4:

l1:=2*h:

l2:=2*h:

N:=0.5:

nu:=.3:

E_m:=70e9:

E_c:=380e9:

rho_m:=2702:

rho_c:=3800:

lambda_m:=nu*E_m/((1+nu)*(1-2*nu)):

lambda_c:=nu*E_c/((1+nu)*(1-2*nu)):

mu_m:=E_m/(2*(1+nu)):

mu_c:=E_c/(2*(1+nu)):

with(orthopoly):

for i from 0 to 5 do:
L(i):=sqrt((2*i+1)/2)*P(i,z):
end do:

Z:=rho_m+(rho_c-rho_m)*((1/2)+(z/h))^N;

2702+1098*(1/2+z)^.5

(1)

U:=lambda_m+(lambda_c-lambda_m)*((1/2)+(z/h))^N;

0.4038461538e11+0.1788461538e12*(1/2+z)^.5

(2)

S:=mu_m+(mu_c-mu_m)*((1/2)+(z/h))^N;

0.2692307692e11+0.1192307692e12*(1/2+z)^.5

(3)

d:=Matrix([[0,0,0,0,0,0,0,0],[sqrt(3),0,0,0,0,0,0,0],[0,sqrt(15),0,0,0,0,0,0],[sqrt(7),0,sqrt(35),0,0,0,0,0],[0,sqrt(27),0,sqrt(63),0,0,0,0],[sqrt(11),0,sqrt(55),0,sqrt(99),0,0,0],[0,sqrt(39),0,sqrt(91),0,sqrt(143),0,0],[sqrt(15),0,sqrt(75),0,sqrt(135),0,sqrt(195),0]]);

d := Matrix(8, 8, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (2, 1) = 3^(1/2), (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (2, 7) = 0, (2, 8) = 0, (3, 1) = 0, (3, 2) = 15^(1/2), (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 0, (3, 8) = 0, (4, 1) = 7^(1/2), (4, 2) = 0, (4, 3) = 35^(1/2), (4, 4) = 0, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 0, (5, 1) = 0, (5, 2) = 3*3^(1/2), (5, 3) = 0, (5, 4) = 3*7^(1/2), (5, 5) = 0, (5, 6) = 0, (5, 7) = 0, (5, 8) = 0, (6, 1) = 11^(1/2), (6, 2) = 0, (6, 3) = 55^(1/2), (6, 4) = 0, (6, 5) = 3*11^(1/2), (6, 6) = 0, (6, 7) = 0, (6, 8) = 0, (7, 1) = 0, (7, 2) = 39^(1/2), (7, 3) = 0, (7, 4) = 91^(1/2), (7, 5) = 0, (7, 6) = 143^(1/2), (7, 7) = 0, (7, 8) = 0, (8, 1) = 15^(1/2), (8, 2) = 0, (8, 3) = 5*3^(1/2), (8, 4) = 0, (8, 5) = 3*15^(1/2), (8, 6) = 0, (8, 7) = 195^(1/2), (8, 8) = 0})

(4)

``

``

e2 := 0;

0

 

-0.3192307692e12*W(1)+0.4396880662e12*W(3)-0.1474586301e12*W(5)-0.9235575669e11*W(2)+0.1979090105e12*W(4)

(5)

``


 

Download for.mw

 

Please Wait...