mehdi jafari

774 Reputation

13 Badges

12 years, 103 days

MaplePrimes Activity


These are replies submitted by mehdi jafari

@Carl Love you are perfect. i am really thankful since it was a very major problem for me. really thank u.

@Carl Love you are perfect. i am really thankful since it was a very major problem for me. really thank u.

@eifan in the third line from the last , just change "traceMM:= Trace(MM)" to "TraceMM:= Trace(MM)"

actually just change the small "t" to captial "T" . it gives the answer :



with(LinearAlgebra):

with(ArrayTools):
#--------------------------------------------------------------------------
fA:= x->Matrix([[0,1],[-x^2,0]]):
fW:= (x,j)->sin(j*Pi*x):
fm:= j->int(fW(x,j)^2,x=0..1):
fB:= (b,m,j)->Matrix(1,m,[seq(fW(b[i],j)/fm(j),i=1..m)]):
#--------------------------------------------------------------------------
n:= 2:
m:= 2:
b:= [0.1,0.2]:
w:= Matrix(1,m):
for i from 1 to n do
w[1,i]:= i*Pi;
od:
#--------------------------------------------------------------------------
A:= Matrix(2*n,2*n):
B:= Matrix(2*n,m):
for i from 1 to n do
ATem:= fA(w[1,i]);
BTem:= fB(b,m,i);
BlockCopy(ATem,0,2,2,2,A,(i-1)*(4*n+2),2*n,2,2);
BlockCopy(BTem,0,1,1,m,B,2*i-1,2*n,1,m);
od:
#--------------------------------------------------------------------------
M:= Matrix(2*n,2*m*n):
for i from 1 to 2*n do
MTem:= MatrixMatrixMultiply(A^(i-1),B);
BlockCopy(MTem,0,2*n,2*n,m,M,(i-1)*2*m*n,2*n,2*n,m);
od:
MM:= MatrixMatrixMultiply(M,Transpose(M)):
#--------------------------------------------------------------------------
detMM:= Determinant(MM):
TraceMM:= Trace(MM):
J:= TraceMM*detMM^(1/n):
evalf(%);

(1)

 

 



@eifan in the third line from the last , just change "traceMM:= Trace(MM)" to "TraceMM:= Trace(MM)"

actually just change the small "t" to captial "T" . it gives the answer :



with(LinearAlgebra):

with(ArrayTools):
#--------------------------------------------------------------------------
fA:= x->Matrix([[0,1],[-x^2,0]]):
fW:= (x,j)->sin(j*Pi*x):
fm:= j->int(fW(x,j)^2,x=0..1):
fB:= (b,m,j)->Matrix(1,m,[seq(fW(b[i],j)/fm(j),i=1..m)]):
#--------------------------------------------------------------------------
n:= 2:
m:= 2:
b:= [0.1,0.2]:
w:= Matrix(1,m):
for i from 1 to n do
w[1,i]:= i*Pi;
od:
#--------------------------------------------------------------------------
A:= Matrix(2*n,2*n):
B:= Matrix(2*n,m):
for i from 1 to n do
ATem:= fA(w[1,i]);
BTem:= fB(b,m,i);
BlockCopy(ATem,0,2,2,2,A,(i-1)*(4*n+2),2*n,2,2);
BlockCopy(BTem,0,1,1,m,B,2*i-1,2*n,1,m);
od:
#--------------------------------------------------------------------------
M:= Matrix(2*n,2*m*n):
for i from 1 to 2*n do
MTem:= MatrixMatrixMultiply(A^(i-1),B);
BlockCopy(MTem,0,2*n,2*n,m,M,(i-1)*2*m*n,2*n,2*n,m);
od:
MM:= MatrixMatrixMultiply(M,Transpose(M)):
#--------------------------------------------------------------------------
detMM:= Determinant(MM):
TraceMM:= Trace(MM):
J:= TraceMM*detMM^(1/n):
evalf(%);

226903800.7

(1)

 

 



Download answer2.mws

 

@Alejandro Jakubi i had this problem too,i think maple should provide a facility like other softwares that the software itself make a backup save every 10 minute . so that if it crashes, we can have the missed code.

i am really thankful for your help,it was exactly what i wanted. u really helped me in the case.thnx alot my dear friend. maple is really a powerfull tool for mathematics. nice helper. thnx, if i could,i voted this answer up more than ten times ... 

i wonder what is the procedure done with this commands u used ? it gives the matrix really fast . can we know how this command is programmed?

i am really thankful for your help,it was exactly what i wanted. u really helped me in the case.thnx alot my dear friend. maple is really a powerfull tool for mathematics. nice helper. thnx, if i could,i voted this answer up more than ten times ... 

i wonder what is the procedure done with this commands u used ? it gives the matrix really fast . can we know how this command is programmed?

@maypay it is ok,i think u maybe need to reinstall your maple product. my operations system is windows 7, but i do not think the problem is the operating system. uninstall it completely and just reinstal. i hope it works.

u mean u can not open the file by double clicking on the file?
i think if u upload it here,maybe we can find the problem,

@Carl Love First,i should thank u specially,for your notifying me,helping me,and giving your precious time to me.really thank u.

actully it was a mistake,i correct it in the second reply,both a[1](t) and a[1] are a[1](t).

the matrix A can be function of the coefficients, so that it can be many of As, such as :


restart;

with(LinearAlgebra):

eq1:=convert(a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3,rational);

eq1 := a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3

(1)

eq2:=convert(a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3,rational);

eq2 := a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3

(2)

eq3:=convert(a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t),rational);

eq3 := a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)

(3)

b:=;

b := Vector(3, {(1) = a[1](t), (2) = a[2](t), (3) = a[3](t)})

(4)

A:=<,<(a[1](t)*a[2](t))^2|(a[2](t))^2|a[2](t)>,<(a[1](t)*a[3](t))^2|1|a[1](t)*a[3](t)>>;

A := Matrix(3, 3, {(1, 1) = a[2](t)^2, (1, 2) = a[1](t)*a[3](t), (1, 3) = a[3](t)^2, (2, 1) = a[1](t)^2*a[2](t)^2, (2, 2) = a[2](t)^2, (2, 3) = a[2](t), (3, 1) = a[1](t)^2*a[3](t)^2, (3, 2) = 1, (3, 3) = a[1](t)*a[3](t)})

(5)

W:=;

W := Vector(3, {(1) = a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3, (2) = a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3, (3) = a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)})

(6)

A.b;

Vector(3, {(1) = a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3, (2) = a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3, (3) = a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)})

(7)

 

 

 

 

 


as u can see,two matrices are equal. 

Download matrix_A.mws

@Carl Love First,i should thank u specially,for your notifying me,helping me,and giving your precious time to me.really thank u.

actully it was a mistake,i correct it in the second reply,both a[1](t) and a[1] are a[1](t).

the matrix A can be function of the coefficients, so that it can be many of As, such as :


restart;

with(LinearAlgebra):

eq1:=convert(a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3,rational);

eq1 := a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3

(1)

eq2:=convert(a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3,rational);

eq2 := a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3

(2)

eq3:=convert(a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t),rational);

eq3 := a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)

(3)

b:=;

b := Vector(3, {(1) = a[1](t), (2) = a[2](t), (3) = a[3](t)})

(4)

A:=<,<(a[1](t)*a[2](t))^2|(a[2](t))^2|a[2](t)>,<(a[1](t)*a[3](t))^2|1|a[1](t)*a[3](t)>>;

A := Matrix(3, 3, {(1, 1) = a[2](t)^2, (1, 2) = a[1](t)*a[3](t), (1, 3) = a[3](t)^2, (2, 1) = a[1](t)^2*a[2](t)^2, (2, 2) = a[2](t)^2, (2, 3) = a[2](t), (3, 1) = a[1](t)^2*a[3](t)^2, (3, 2) = 1, (3, 3) = a[1](t)*a[3](t)})

(5)

W:=;

W := Vector(3, {(1) = a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3, (2) = a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3, (3) = a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)})

(6)

A.b;

Vector(3, {(1) = a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3, (2) = a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3, (3) = a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)})

(7)

 

 

 

 

 


as u can see,two matrices are equal. 

Download matrix_A.mws

when i use select i face :

i have extract do procedures so that it can obvious what happens

restart;

eq1:=convert(a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3,rational);

eq1 := a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3

(1)

eq2:=convert(a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3,rational);

eq2 := a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3

(2)

eq3:=convert(a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t),rational);;

eq3 := a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)

(3)

 

 i:=1;
A || i := Vector[row](3);
j:=1;

if select(has,eq || i,a[j](t))=undefined
then

A || i[j]:=0;

else
 
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);

end if;

i := 1

A1 := Vector[row](3, {(1) = 0, (2) = 0, (3) = 0})

j := 1

A1[1] := (a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t))/a[1](t)

eq1 := a[3](t)^3

(4)

j:=2;

j := 2

(5)


if select(has,eq || i,a[j](t))=undefined
then

A || i[j]:=0;

else
 
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);

end if;
eq1;

A1[2] := 0

a[3](t)^3

(6)

j:=3;


if select(has,eq || i,a[j](t))=undefined
then

A || i[j]:=0;

else
 
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);

end if;
eq1;

j := 3

A1[3] := 1

eq1 := a[3](t)^3-a[3](t)

a[3](t)^3-a[3](t)

(7)

 


as u can see,when we have a[3](t)^3 ,select just gives a[3](t) back and not a[3](t)^3. which make me in trouble. can we do sth for this ?

Download problem_4.mws

:


when i use select i face :

i have extract do procedures so that it can obvious what happens

restart;

eq1:=convert(a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3,rational);

eq1 := a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t)+a[3](t)^3

(1)

eq2:=convert(a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3,rational);

eq2 := a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3

(2)

eq3:=convert(a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t),rational);;

eq3 := a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)

(3)

 

 i:=1;
A || i := Vector[row](3);
j:=1;

if select(has,eq || i,a[j](t))=undefined
then

A || i[j]:=0;

else
 
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);

end if;

i := 1

A1 := Vector[row](3, {(1) = 0, (2) = 0, (3) = 0})

j := 1

A1[1] := (a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1](t))/a[1](t)

eq1 := a[3](t)^3

(4)

j:=2;

j := 2

(5)


if select(has,eq || i,a[j](t))=undefined
then

A || i[j]:=0;

else
 
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);

end if;
eq1;

A1[2] := 0

a[3](t)^3

(6)

j:=3;


if select(has,eq || i,a[j](t))=undefined
then

A || i[j]:=0;

else
 
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);

end if;
eq1;

j := 3

A1[3] := 1

eq1 := a[3](t)^3-a[3](t)

a[3](t)^3-a[3](t)

(7)

 


as u can see,when we have a[3](t)^3 ,select just gives a[3](t) back and not a[3](t)^3. which make me in trouble. can we do sth for this ?

Download problem_4.mws

:


beacuse when i use select, i face ths problem, so i can not achieve what i want : 

restart;

eq1:=convert(a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1]+a[3](t)^3,rational);

eq1 := a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1]+a[3](t)^3

(1)

eq2:=convert(a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3,rational);

eq2 := a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3

(2)

eq3:=convert(a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t),rational);;

eq3 := a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)

(3)

 

for i to 3 do
 A || i := Vector[row](3);
for j to 3 do
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);
end do:
end do:
A:= Matrix([seq(convert(A || s, list), s = 1 .. 3)]);

A:=[[[(a[2](t))^2,a[3](t) a[1],1],[(a[1](t))^2 (a[2](t))^2,(a[2](t) a[3](t)+(a[2](t))^3)/(a[2](t)),()/(a[3](t))],[(a[1](t) (a[3](t))^2+(a[3](t))^2 (a[1](t))^3)/(a[1](t)),(a[2]())/(a[2](t)),0]]]

(4)

 

 

 

 

 


as u can see the processe do not give what i wanted.

as u see if i can select a special variable in an expression,thus i can solve the problem, the problem with select(has,..) is when the expresion gives back undefined,as u seein the matrix. some terms with nothing.

i define an if procedure,that is select(has,...) gives undefined,consider that 0.

but in does not solve the problem either. 

i am really thankful for your help and attention but it does not solved the problem,since :

p:= collect(eq1, a[1](t));    

           p := a[1](t) a[2](t)  + a[2](t) a[3](t) a[1] + a[3](t)


p-tcoeff(eq1,a[1](t));              

          a[1](t) a[2](t)


as u see,it does not give back just the coeffiecnts containing a[1]. 

Download problem_3.mws 

beacuse when i use select, i face ths problem, so i can not achieve what i want : 

restart;

eq1:=convert(a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1]+a[3](t)^3,rational);

eq1 := a[1](t)*a[2](t)^2+a[2](t)*a[3](t)*a[1]+a[3](t)^3

(1)

eq2:=convert(a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3,rational);

eq2 := a[1](t)^3*a[2](t)^2+a[2](t)*a[3](t)+a[2](t)^3

(2)

eq3:=convert(a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t),rational);;

eq3 := a[1](t)*a[3](t)^2+a[3](t)^2*a[1](t)^3+a[2](t)

(3)

 

for i to 3 do
 A || i := Vector[row](3);
for j to 3 do
A || i[j] := select(has,eq || i,a[j](t))/a[j](t) ; eq || i := eq || i-A || i[j]*a[j](t);
end do:
end do:
A:= Matrix([seq(convert(A || s, list), s = 1 .. 3)]);

A:=[[[(a[2](t))^2,a[3](t) a[1],1],[(a[1](t))^2 (a[2](t))^2,(a[2](t) a[3](t)+(a[2](t))^3)/(a[2](t)),()/(a[3](t))],[(a[1](t) (a[3](t))^2+(a[3](t))^2 (a[1](t))^3)/(a[1](t)),(a[2]())/(a[2](t)),0]]]

(4)

 

 

 

 

 


as u can see the processe do not give what i wanted.

as u see if i can select a special variable in an expression,thus i can solve the problem, the problem with select(has,..) is when the expresion gives back undefined,as u seein the matrix. some terms with nothing.

i define an if procedure,that is select(has,...) gives undefined,consider that 0.

but in does not solve the problem either. 

i am really thankful for your help and attention but it does not solved the problem,since :

p:= collect(eq1, a[1](t));    

           p := a[1](t) a[2](t)  + a[2](t) a[3](t) a[1] + a[3](t)


p-tcoeff(eq1,a[1](t));              

          a[1](t) a[2](t)


as u see,it does not give back just the coeffiecnts containing a[1]. 

Download problem_3.mws 

First 15 16 17 18 19 20 21 Page 17 of 23